Select to view content in your preferred language

Querying server logs does not work when filtering on Services

141
0
a month ago
Labels (1)
epugliano
New Contributor

I'm creating a process where I can query the server logs for activity on certain feature services.  The code loops through the services on a server and tries to use the LogManager.query function to query the logs with a filter on a specific service name.

 

from arcgis.gis import GIS
import arcgis.gis.admin
import pandas as pd

gis = GIS(url, username, password, verify_cert=False)

gis_servers = gis.admin.servers.list()

#To list all services
for server in gis_servers:
    # Create the LogManager object on the server to get the logs
    log_manager = server.logs
    folders = [f for f in server.services.folders if f.lower() != "system"]
    for folder in folders:
        for service in server.services.list(folder=folder):
            
            service_name = service.properties.serviceName

            log_query = log_manager.query(start_time=None,
            end_time=None, 
            since_server_start=False, 
            level='VERBOSE', 
            services=service_name, 
            machines='*', 
            server='*', 
            codes=None, 
            process_IDs=None, 
            export=False, 
            export_type='CSV', 
            out_path=None, 
            max_records_return=10)
            print(pd.DataFrame.from_records(log_query))

 

 

But whenever I run the code above, I get the first ten results from all of the server logs with no filter on services.  I have tried running it with the following formats for the service_name variable (this is entered as a string):

[ServiceName]

[ServiceName].MapServer

[FolderName].[ServiceName].MapServer

I get the same results every time.

Is there something I should be doing differently when trying to filter using the LogManager.query function?

 

0 Kudos
0 Replies