ArcGIS server report log error

529
0
06-07-2021 07:54 AM
CliveSwan
Occasional Contributor II

Greetings,

I am trying to get the ArcGIS Server Report out to JSON, there are two issues.

1) Python loops through the reports, is expecting 4 columns? 

There is report.reportname, report.metadata, report.time-slices, report.report-data

The Python is writing out rows, this fails when it try's to write out column 2. There is no column 2, 3, 4.

The code is:

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")

 

The output per row (flattened JSON is): 

{"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]}]]}}

2) The data returned is not that useful??

0 Kudos
0 Replies