Platform Usage and Performance Monitoring
This topic provides queries that administrators can run to monitor platform usage and performance. You can run the queries from the Query Builder (See Running SPARQL Queries in the Query Builder) or against the SPARQL endpoint (See Access the SPARQL Endpoint). Each of the queries below target the System Datasource or System Tables data source, which are accessible to the sysadmin user or users with the Anzo Administrator role.
You can generate a cURL request against the SPARQL endpoint from a query in the Query Builder. Once you have a valid query, click the More button under the query and select Copy CURL Command.
- Return the number of queries that were run in the last N hours
- Return the average and maximum runtime of the queries run in the last N hours
- Return the number of active graphmarts
- Return the number of triples that are loaded in each active graphmart
- Return the total number of dashboards
- Return file system usage details
- Return information about the last N events
- Return a list of queries that took longer than N seconds to run
- Return the number of queries run per day
- Return the number of active users per day
- Return the number of times each user logged in during the given time period
Return the number of queries that were run in the last N hours
You can run the following aggregation query against the System Tables data source (http://cambridgesemantics.com/datasource/SystemTables
) to return the number of queries that were executed in the specified number of hours:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX System: <http://openanzo.org/ontologies/2008/07/System#> SELECT (COUNT(?query) as ?Nr_Of_Queries) WHERE { # VALUES ?hour { "N" } # Example: in the last 5 hours VALUES ?hour { "05" } BIND(STRDT(CONCAT("P0Y0M0DT",?hour,"H00M00S"), xsd:duration) as ?duration) ?query a System:QueryExecution; System:dateCreated ?time . FILTER (?time + ?duration > NOW()) }
Return the average and maximum runtime of the queries run in the last N hours
You can run the following aggregation query against the System Tables data source (http://cambridgesemantics.com/datasource/SystemTables
) to return the average and maximum runtime of all of the queries that were executed in the specified number of hours:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX System: <http://openanzo.org/ontologies/2008/07/System#> SELECT (AVG(?queryTime) as ?avgQueryTime) (MAX(?queryTime) as ?maxQueryTime) WHERE { # VALUES ?hour { "N" } # Example: in the last 5 hours VALUES ?hour { "05" } BIND(STRDT(CONCAT("P0Y0M0DT",?hour,"H00M00S"), xsd:duration) as ?duration) ?query a System:QueryExecution; System:queryTime ?queryTime; System:dateCreated ?time . FILTER (?time + ?duration > NOW()) }
Return the number of active graphmarts
You can run the following query against the System Datasource (http://openanzo.org/datasource/systemDatasource
) to return the number of active graphmarts, i.e., the number of graphmarts with an active query engine:
PREFIX gmart: <http://cambridgesemantics.com/ontologies/Graphmarts#> SELECT (COUNT(?graphmart) as ?runningGraphmartCount) WHERE { ?graphmart a gmart:Graphmart ; # The running graphmarts are those with a query engine gmart:graphQueryEngineUri ?o . }
Return the number of triples that are loaded in each active graphmart
You can run the following query against the System Datasource (http://openanzo.org/datasource/systemDatasource
) to return the number of triples that are loaded in each graphmart that is active:
PREFIX System: <http://openanzo.org/ontologies/2008/07/System#> PREFIX Graphmarts: <http://cambridgesemantics.com/ontologies/Graphmarts#> PREFIX graphmartStatus: <http://cambridgesemantics.com/ontologies/GraphmartStatus#> PREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT ?graphmart ?graphmartTitle ?statementCount WHERE { ?graphmart dc:title ?graphmartTitle . SERVICE <http://cambridgesemantics.com/datasource/SystemTables> { SELECT ?graphmart ?statementCount FROM <http://openanzo.org/namedGraphs/reserved/graphs/ALL> WHERE { # Get the graphmarts that are online ?graphmart a graphmartStatus:GraphmartStatus ; graphmartStatus:status System:Online ; # Get their triple count graphmartStatus:totalStatements ?statementCount . } } }
Return the total number of dashboards
You can run the following aggregation query against the System Datasource (http://openanzo.org/datasource/systemDatasource
) to return the total number of dashboards in the system:
SELECT (COUNT(?dashboard) as ?dashboardCount) WHERE { ?dashboard a <urn:com.cambridgesemantics.application.anzoweb.lens.linkeddataset.view.GraphmartViewLens> . FILTER(?dashboard NOT IN (<urn:com.cambridgesemantics.application.anzoweb.lens.linkeddataset.view.GraphmartViewLens>)) }
Return file system usage details
You can run the following query against the System Tables data source (http://cambridgesemantics.com/datasource/SystemTables
) to return information about used and free space on the specified file system locations:
SELECT ?dir ?free_gb ?available_gb ?total_gb WHERE { ?s a <http://openanzo.org/ontologies/2008/07/System#FilesystemInfo> ; <http://openanzo.org/ontologies/2008/07/System#dirName> ?dir ; <http://openanzo.org/ontologies/2008/07/System#fsFree> ?free ; <http://openanzo.org/ontologies/2008/07/System#fsTotal> ?total ; <http://openanzo.org/ontologies/2008/07/System#fsAvailable> ?available . BIND(?free/1000000000 as ?free_gb) BIND(?total/1000000000 as ?total_gb) BIND(?available/1000000000 as ?available_gb) VALUES ?dir { # "location1" # [ "location2" ] # [ "..." ] # Example with / and /mnt as locations: "/" "/mnt" } }
Return information about the last N events
You can run the following query against the System Tables data source (http://cambridgesemantics.com/datasource/SystemTables
) to return details about the N most recent activities:
SELECT DISTINCT ?desc ?event ?user ?startTime ?completedTime ?source WHERE { ?s a <http://openanzo.org/ontologies/2008/07/System#ActivityAuditEvent> ; <http://purl.org/dc/elements/1.1/description> ?desc ; <http://openanzo.org/ontologies/2008/07/System#activitySource> ?source ; <http://openanzo.org/ontologies/2008/07/System#eventMessage> ?event ; <http://openanzo.org/ontologies/2008/07/System#userUri> ?user ; <http://openanzo.org/ontologies/2008/07/System#activityStarted> ?startTime ; <http://openanzo.org/ontologies/2008/07/System#activityCompleted> ?completedTime . } # LIMIT N LIMIT 100
Return a list of queries that took longer than N seconds to run
You can run the following query against the System Tables data source (http://cambridgesemantics.com/datasource/SystemTables
) to return a list of queries that took longer than N seconds to complete:
SELECT ?dateCreated (?queryTime/1000 as ?seconds) ?datasource WHERE { { SELECT * WHERE { ?queryEvent a <http://openanzo.org/ontologies/2008/07/System#QueryEvent> ; <http://openanzo.org/ontologies/2008/07/System#queryTime> ?queryTime ; <http://openanzo.org/ontologies/2008/07/System#dateCreated> ?dateCreated ; <http://openanzo.org/ontologies/2008/07/System#datasourceUri> ?datasource . FILTER(CONTAINS(STR(?queryEvent), "queryStack")) } ORDER BY DESC(?dateCreated) LIMIT 1000 } # FILTER(?queryTime > number_of_milliseconds) # For example, 10000 milliseconds=10 seconds: FILTER(?queryTime > 10000) }
Return the number of queries run per day
You can run the following query against the System Tables data source (http://cambridgesemantics.com/datasource/SystemTables
) to return a count of the total number of queries that were run per day since the last time Anzo was restarted:
PREFIX System: <http://openanzo.org/ontologies/2008/07/System#> SELECT ?date (COUNT(?query) as ?queryPerDayCount) WHERE { ?query a System:QueryExecution; System:dateCreated ?time . BIND(DATEPART(?time) as ?date) } GROUP BY ?date ORDER BY ?date
Return the number of active users per day
You can run the following query against the System Tables data source (http://cambridgesemantics.com/datasource/SystemTables
) to return the number of active users per day since Anzo was last restarted:
PREFIX System: <http://openanzo.org/ontologies/2008/07/System#> SELECT (COUNT(DISTINCT(?user)) as ?user_count) FROM <http://openanzo.org/namedGraphs/reserved/graphs/ALL> WHERE { { SELECT DISTINCT ?user ?date WHERE { ?event a system:QueryEvent ; System:userUri ?user ; System:dateCreated ?date . } ORDER BY DESC(?date) LIMIT 100 } }
Return the number of times each user logged in during the given time period
You can run the following query against the System Tables data source (http://cambridgesemantics.com/datasource/SystemTables
) to return the number of times each user logged in between certain dates:
PREFIX System: <http://openanzo.org/ontologies/2008/07/System#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT DISTINCT ?user (COUNT(?loginDate) as ?loginCount) WHERE { ?s a System:UserAuditEvent ; System:eventMessage ?eventMessage ; System:userUri ?user ; System:dateCreated> ?loginDate . FILTER(contains(?eventMessage, "Connect")) # BIND(xsd:date("start_date") as ?startDate) # BIND(xsd:date("end_date") as ?endDate) # Specify the start and end dates to find the total number of logins # between a range of time. For example, July 2023: BIND(xsd:date("2023-07-01") as ?startDate) BIND(xsd:date("2023-07-31") as ?endDate) FILTER(?loginDate > ?startDate && ?loginDate < ?endDate) } GROUP BY ?user