ArangoDB v3.10 reached End of Life (EOL) and is no longer supported.

This documentation is outdated. Please see the most recent stable version.

The @arangodb/aql/queries module of the JavaScript API

The query module provides the infrastructure for working with currently running AQL queries via arangosh

const queries = require('@arangodb/aql/queries')

Properties Returns the servers current query tracking configuration; we change the slow query threshold to get better results:

var queries = require("@arangodb/aql/queries");;{slowQueryThreshold: 1});{slowStreamingQueryThreshold: 1});
Show output

Currently running queries

We create a task that spawns queries, so we have nice output. Since this task uses resources, you may want to increase period (and not forget to remove it… afterwards):

var theQuery = 'FOR sleepLoooong IN 1..5 LET sleepLoooonger = SLEEP(1000) RETURN sleepLoooong';
var tasks = require("@arangodb/tasks");
  id: "mytask-1",
  name: "this is a sample task to spawn a slow aql query",
  command: "require('@arangodb').db._query('" + theQuery + "');"
Show output

Slow queries

The function returns the last AQL queries that exceeded the slow query threshold as an array:


Clear slow queries

Clear the list of slow AQL queries:

Show output


Kill a running AQL query:

var runningQueries = queries.current().filter(function(query) {
  return query.query === theQuery;
Show output