Query Log Database
This page discusses the Query Log Database which preserves information about queries which have been executed by Stardog over time.
Page Contents
Overview
The Query Log database allows users to see the history of queries executed along with metadata such as query execution time, user, database, etc. Stardog has extensive audit logging capabilities that includes a logger to identify slow queries. However these logs are only accessible to the infrastructure operators and is not in a form easy to analyze.
The Query Log Database stores that information as RDF and makes it queryable with SPARQL similar to the Data Catalog database. The feature has to be enabled by setting the server’s option query.log.enabled
to true
. After that the server will automatically log all SPARQL queries at predefined intervals (see the setting below).
Query Log Database works with the Stardog cluster out of the box. Each cluster node executes and logs queries independently but changes to the Query Log Database are replicated to all nodes (like changes to any user database).
Updates to the Query Log Database are batched to minimize the overhead of logging queries and replicating the log in the cluster.
Query Log Database provides built-in functionality to truncate old query log events to prevent the database size from growing continuously.
Permissions
Read access to this database must be granted manually. It is the responsibility of the Stardog administrator.
Examples
This basic query may be used to fetch the last 20 queries executed against the querylog
database
prefix : <tag:stardog:api:query:>
select * {
[] a :Query;
:user ?user;
:type ?query_type;
:database ?db;
:start ?start_time;
:end ?end_time;
:query ?query_str;
:plan ?query_plan.
}
ORDER BY DESC(?start_time)
LIMIT 20
RDF Vocabulary for Query Log Database
Predicate | Description |
---|---|
tag:stardog:api:query:user | User who ran the query |
tag:stardog:api:query:type | Type of the query |
tag:stardog:api:query:database | Database the query ran against |
tag:stardog:api:query:start | Start datetime of the query |
tag:stardog:api:query:end | End time of the query |
tag:stardog:api:query:query | The query string |
tag:stardog:api:query:plan | The optimized query plan |
Settings
Setting | Description | Default |
---|---|---|
query.log.enabled | Enable the query log feature | false |
query.log.auto.create.db | Create the Query Log db automatically on start-up | true |
query.log.database | Name of the Query Log database | “querylog” |
query.log.update.interval | Interval at which queries are flushed to disk | “10s” |
query.log.prune.interval | Interval at which queries are pruned from the query log database | “30m” |
query.log.optimize.interval | Interval at which the Query Log database is optimized | “3d” |
query.log.prune.max.size | Maximum size of the Query Log database. Oldest queries are deleted first | 10.000 |
query.log.prune.max.age | Maximum age of queries in the Query Log database. Older queries are going to be deleted first | “30d” |
Currently query.log.enabled
is both a database and a server’s option. If set to true
for the server, queries are logged for all databases unless it’s set to false
for a specific database. All other options are server-wide.