<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ArcGIS server report log error in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-server-report-log-error/m-p/1065643#M6174</link>
    <description>&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;I am trying to get the ArcGIS Server Report out to JSON, there are two issues.&lt;/P&gt;&lt;P&gt;1) Python loops through the reports, is expecting 4 columns?&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is report.reportname,&amp;nbsp;report.metadata,&amp;nbsp;report.time-slices,&amp;nbsp;report.report-data&lt;/P&gt;&lt;P&gt;The Python is writing out rows, this fails when it try's to write out column 2. There is no column 2, 3, 4.&lt;/P&gt;&lt;P&gt;The code is:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with open(outFile, 'w', newline='') as json_file:
    for service in srv.services.list():
        if service.properties.serviceName != " ":
            for report in service:
                qk_report = srv.usage.quick_report(since="LAST_DAY",   metrics="error")                     
                df = DataFrame(qk_report, columns=['report' ])    
                flat = pd.json_normalize(qk_report)   
                flatten = flat.to_json()
                print(flatten)
                json.dump(flatten, json_file)

        print("End of Report")
    json_file.close
    print("END REPORT")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output per row (flattened JSON is):&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{"report.reportname":{"0":"3da3d646cf434b9c838a822cd5c75d06"},"report.metadata":{"0":"{\"temp\":true,\"title\":\"3da3d646cf434b9c838a822cd5c75d06\",\"managerReport\":false}"},"report.time-slices":{"0":[1622989800000,1622991600000,1622993400000,1622995200000,1622997000000,1622998800000,1623000600000,1623002400000,1623004200000,1623006000000,1623007800000,1623009600000,1623011400000,1623013200000,1623015000000,1623016800000,1623018600000,1623020400000,1623022200000,1623024000000,1623025800000,1623027600000,1623029400000,1623031200000,1623033000000,1623034800000,1623036600000,1623038400000,1623040200000,1623042000000,1623043800000,1623045600000,1623047400000,1623049200000,1623051000000,1623052800000,1623054600000,1623056400000,1623058200000,1623060000000,1623061800000,1623063600000,1623065400000,1623067200000,1623069000000,1623070800000,1623072600000,1623074400000]},"report.report-data":{"0":[[{"resourceURI":"services\/","metric-type":"error","data":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]}]]}}&lt;/LI-CODE&gt;&lt;P&gt;2) The data returned is not that useful??&lt;/P&gt;</description>
    <pubDate>Mon, 07 Jun 2021 14:54:10 GMT</pubDate>
    <dc:creator>CliveSwan</dc:creator>
    <dc:date>2021-06-07T14:54:10Z</dc:date>
    <item>
      <title>ArcGIS server report log error</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-server-report-log-error/m-p/1065643#M6174</link>
      <description>&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;I am trying to get the ArcGIS Server Report out to JSON, there are two issues.&lt;/P&gt;&lt;P&gt;1) Python loops through the reports, is expecting 4 columns?&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is report.reportname,&amp;nbsp;report.metadata,&amp;nbsp;report.time-slices,&amp;nbsp;report.report-data&lt;/P&gt;&lt;P&gt;The Python is writing out rows, this fails when it try's to write out column 2. There is no column 2, 3, 4.&lt;/P&gt;&lt;P&gt;The code is:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with open(outFile, 'w', newline='') as json_file:
    for service in srv.services.list():
        if service.properties.serviceName != " ":
            for report in service:
                qk_report = srv.usage.quick_report(since="LAST_DAY",   metrics="error")                     
                df = DataFrame(qk_report, columns=['report' ])    
                flat = pd.json_normalize(qk_report)   
                flatten = flat.to_json()
                print(flatten)
                json.dump(flatten, json_file)

        print("End of Report")
    json_file.close
    print("END REPORT")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output per row (flattened JSON is):&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{"report.reportname":{"0":"3da3d646cf434b9c838a822cd5c75d06"},"report.metadata":{"0":"{\"temp\":true,\"title\":\"3da3d646cf434b9c838a822cd5c75d06\",\"managerReport\":false}"},"report.time-slices":{"0":[1622989800000,1622991600000,1622993400000,1622995200000,1622997000000,1622998800000,1623000600000,1623002400000,1623004200000,1623006000000,1623007800000,1623009600000,1623011400000,1623013200000,1623015000000,1623016800000,1623018600000,1623020400000,1623022200000,1623024000000,1623025800000,1623027600000,1623029400000,1623031200000,1623033000000,1623034800000,1623036600000,1623038400000,1623040200000,1623042000000,1623043800000,1623045600000,1623047400000,1623049200000,1623051000000,1623052800000,1623054600000,1623056400000,1623058200000,1623060000000,1623061800000,1623063600000,1623065400000,1623067200000,1623069000000,1623070800000,1623072600000,1623074400000]},"report.report-data":{"0":[[{"resourceURI":"services\/","metric-type":"error","data":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]}]]}}&lt;/LI-CODE&gt;&lt;P&gt;2) The data returned is not that useful??&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jun 2021 14:54:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-server-report-log-error/m-p/1065643#M6174</guid>
      <dc:creator>CliveSwan</dc:creator>
      <dc:date>2021-06-07T14:54:10Z</dc:date>
    </item>
  </channel>
</rss>

