Top queries (v2)

Top queries

Operations

MethodPathDescription
GET /api/v2/top-queries/mongodb List MongoDB top queries
GET /api/v2/top-queries/mysql List MySQL top queries
GET /api/v2/top-queries/oracle List Oracle top queries
GET /api/v2/top-queries/postgresql List PostgreSQL top queries
GET /api/v2/top-queries/sql-server List SQL Server top queries

List MongoDB top queries

Returns the queries that put the most load on each requested MongoDB instance over the time range. The figures cover only the operations that MongoDB logged as slow queries, that is, operations that ran longer than the instance's slowms threshold. Each figure is an average per execution over the range. Supply one or more entity IDs (from GET /monitored-servers) to choose the servers to report on: a MongoDB instance or a host, which stands for the MongoDB instances that run on it. At least one entity ID is required. The time range must be between 15 minutes and 31 days. When startTime and endTime are both omitted, the last hour is returned.

GET /api/v2/top-queries/mongodb

curl -G https://your-host/api/v2/top-queries/mongodb \
  -H "Authorization: Bearer $TOKEN" \
  --data-urlencode "entityIds=value" \
  --data-urlencode "startTime=2024-01-01T00:00:00Z" \
  --data-urlencode "endTime=2024-01-01T00:00:00Z"

Query parameters

entityIds array · entity-id REQUIRED

One or more entity IDs naming the servers to report on. Use the entityId values returned by GET /monitored-servers. A host ID stands for the instances that run on the host. Repeat the parameter for multiple values.

startTime string · date-time OPTIONAL

Start of the time range (UTC). Defaults to one hour before endTime, or one hour before the current time when endTime is also omitted. The range must be between 15 minutes and 31 days.

endTime string · date-time OPTIONAL

End of the time range (UTC). Must be later than startTime when startTime is provided. Defaults to the current time. The range must be between 15 minutes and 31 days.

Responses

200 — The top queries of each requested server (empty array when none of them logged a slow query in the range)

Response object: TopQueriesMongoDb array

{
  "data": [
    {
      "serverEntityId": "r1,4:base,s36:4bba3b44-5634-4b33-aff8-f53c4315efe3,14:MongoDbInstance,1,4:Name,s11:mongodb-prod,",
      "serverEntityTypes": [
        "MongoDbInstance"
      ],
      "serverEntityName": "mongodb-prod",
      "databaseName": "sales",
      "queryText": "{ find: \u0022orders\u0022, filter: { customer_id: 42 } }",
      "queryHash": "3a1f9e2b7c4d5601a2b3c4d5e6f70819",
      "planCacheKey": "7c4d5601a2b3c4d5e6f708193a1f9e2b",
      "executionCount": 4200,
      "averageDurationMilliseconds": 12.4,
      "averageKeysExamined": 1288,
      "averageDocsExamined": 3.1
    }
  ],
  "status": "success"
}

Response object: JSendFailure

{
  "status": "fail",
  "data": {}
}

Response object: JSendMessageOnlyError

{
  "status": "error",
  "message": "string"
}

Response object: JSendMessageOnlyError

{
  "status": "error",
  "message": "string"
}

Response object: JSendFailure

{
  "status": "fail",
  "data": {}
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

Response object: JSendFailure

{
  "status": "fail",
  "data": {}
}

Response object: ProblemDetails

{
  "type": "string",
  "title": "string",
  "status": 0,
  "detail": "string",
  "instance": "string"
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

List MySQL top queries

Returns the statement digests that put the most load on each requested MySQL instance over the time range. Each figure is an average per execution over the range. Supply one or more entity IDs (from GET /monitored-servers) to choose the servers to report on: a MySQL instance or a host, which stands for the MySQL instances that run on it. At least one entity ID is required. The time range must be between 15 minutes and 31 days. When startTime and endTime are both omitted, the last hour is returned.

GET /api/v2/top-queries/mysql

curl -G https://your-host/api/v2/top-queries/mysql \
  -H "Authorization: Bearer $TOKEN" \
  --data-urlencode "entityIds=value" \
  --data-urlencode "startTime=2024-01-01T00:00:00Z" \
  --data-urlencode "endTime=2024-01-01T00:00:00Z"

Query parameters

entityIds array · entity-id REQUIRED

One or more entity IDs naming the servers to report on. Use the entityId values returned by GET /monitored-servers. A host ID stands for the instances that run on the host. Repeat the parameter for multiple values.

startTime string · date-time OPTIONAL

Start of the time range (UTC). Defaults to one hour before endTime, or one hour before the current time when endTime is also omitted. The range must be between 15 minutes and 31 days.

endTime string · date-time OPTIONAL

End of the time range (UTC). Must be later than startTime when startTime is provided. Defaults to the current time. The range must be between 15 minutes and 31 days.

Responses

200 — The top statement digests of each requested server (empty array when none of them ran a statement in the range)

Response object: TopQueriesMySql array

{
  "data": [
    {
      "serverEntityId": "r1,4:base,s36:4bba3b44-5634-4b33-aff8-f53c4315efe3,13:MySqlInstance,1,4:Name,s10:mysql-prod,",
      "serverEntityTypes": [
        "MySqlInstance"
      ],
      "serverEntityName": "mysql-prod",
      "schemaName": "sales",
      "queryText": "SELECT * FROM \u0060orders\u0060 WHERE \u0060customer_id\u0060 = ?",
      "digest": "3a1f9e2b7c4d5601a2b3c4d5e6f70819",
      "executionCount": 4200,
      "averageDurationMilliseconds": 12.4,
      "averageCpuTimeMilliseconds": 8.1,
      "averageRowsRead": 1288,
      "averageRowsWritten": 3.1
    }
  ],
  "status": "success"
}

Response object: JSendFailure

{
  "status": "fail",
  "data": {}
}

Response object: JSendMessageOnlyError

{
  "status": "error",
  "message": "string"
}

Response object: JSendMessageOnlyError

{
  "status": "error",
  "message": "string"
}

Response object: JSendFailure

{
  "status": "fail",
  "data": {}
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

Response object: JSendFailure

{
  "status": "fail",
  "data": {}
}

Response object: ProblemDetails

{
  "type": "string",
  "title": "string",
  "status": 0,
  "detail": "string",
  "instance": "string"
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

List Oracle top queries

Returns the statements that put the most load on each requested Oracle instance over the time range. Each figure is an average per execution over the range. Supply one or more entity IDs (from GET /monitored-servers) to choose the servers to report on: an Oracle instance or a host, which stands for the Oracle instances that run on it. At least one entity ID is required. The time range must be between 15 minutes and 31 days. When startTime and endTime are both omitted, the last hour is returned.

GET /api/v2/top-queries/oracle

curl -G https://your-host/api/v2/top-queries/oracle \
  -H "Authorization: Bearer $TOKEN" \
  --data-urlencode "entityIds=value" \
  --data-urlencode "startTime=2024-01-01T00:00:00Z" \
  --data-urlencode "endTime=2024-01-01T00:00:00Z"

Query parameters

entityIds array · entity-id REQUIRED

One or more entity IDs naming the servers to report on. Use the entityId values returned by GET /monitored-servers. A host ID stands for the instances that run on the host. Repeat the parameter for multiple values.

startTime string · date-time OPTIONAL

Start of the time range (UTC). Defaults to one hour before endTime, or one hour before the current time when endTime is also omitted. The range must be between 15 minutes and 31 days.

endTime string · date-time OPTIONAL

End of the time range (UTC). Must be later than startTime when startTime is provided. Defaults to the current time. The range must be between 15 minutes and 31 days.

Responses

200 — The top statements of each requested server (empty array when none of them ran a statement in the range)

Response object: TopQueriesOracle array

{
  "data": [
    {
      "serverEntityId": "r1,4:base,s36:4bba3b44-5634-4b33-aff8-f53c4315efe3,14:OracleInstance,1,4:Name,s8:ORCLPROD,",
      "serverEntityTypes": [
        "OracleInstance"
      ],
      "serverEntityName": "ORCLPROD",
      "containerName": "SALESPDB",
      "sqlId": "7hys3h7ysgf9m",
      "planHashValue": 3724264953,
      "queryText": "SELECT o.order_id, o.total FROM orders o WHERE o.customer_id = :1",
      "executionCount": 1420,
      "averageElapsedTimeMilliseconds": 12.4,
      "averageCpuTimeMilliseconds": 8.1,
      "averageUserIoWaitMilliseconds": 3.6,
      "averageShareableMemoryBytes": 26.5
    }
  ],
  "status": "success"
}

Response object: JSendFailure

{
  "status": "fail",
  "data": {}
}

Response object: JSendMessageOnlyError

{
  "status": "error",
  "message": "string"
}

Response object: JSendMessageOnlyError

{
  "status": "error",
  "message": "string"
}

Response object: JSendFailure

{
  "status": "fail",
  "data": {}
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

Response object: JSendFailure

{
  "status": "fail",
  "data": {}
}

Response object: ProblemDetails

{
  "type": "string",
  "title": "string",
  "status": 0,
  "detail": "string",
  "instance": "string"
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

List PostgreSQL top queries

Returns the statements that put the most load on each requested PostgreSQL server over the time range. Unlike SQL Server, PostgreSQL statements are not grouped by query hash. Supply one or more entity IDs (from GET /monitored-servers) to choose the servers to report on: a PostgreSQL server or a host, which stands for the PostgreSQL servers that run on it. At least one entity ID is required. The time range must be between 15 minutes and 31 days. When startTime and endTime are both omitted, the last hour is returned.

GET /api/v2/top-queries/postgresql

curl -G https://your-host/api/v2/top-queries/postgresql \
  -H "Authorization: Bearer $TOKEN" \
  --data-urlencode "entityIds=value" \
  --data-urlencode "queryTextFragment=value" \
  --data-urlencode "startTime=2024-01-01T00:00:00Z" \
  --data-urlencode "endTime=2024-01-01T00:00:00Z"

Query parameters

entityIds array · entity-id REQUIRED

One or more entity IDs naming the servers to report on. Use the entityId values returned by GET /monitored-servers. A host ID stands for the instances that run on the host. Repeat the parameter for multiple values.

queryTextFragment string OPTIONAL

Optional search term. Only statements whose text matches the term are returned. Omit to return the top statements regardless of their text.

startTime string · date-time OPTIONAL

Start of the time range (UTC). Defaults to one hour before endTime, or one hour before the current time when endTime is also omitted. The range must be between 15 minutes and 31 days.

endTime string · date-time OPTIONAL

End of the time range (UTC). Must be later than startTime when startTime is provided. Defaults to the current time. The range must be between 15 minutes and 31 days.

Responses

200 — The top statements of each requested server (empty array when none of them ran a statement in the range)

Response object: TopQueriesPostgresql array

{
  "data": [
    {
      "serverEntityId": "r1,4:base,s36:4bba3b44-5634-4b33-aff8-f53c4315efe3,15:PostgresInstance,1,4:Name,s8:instance,",
      "serverEntityTypes": [
        "PostgresInstance"
      ],
      "serverEntityName": "prod-postgres-01",
      "databaseName": "sales",
      "queryHash": "3F2A9B1C7D4E5F60718293A4B5C6D7E8F90112233445566778899AABBCCDDEEFF",
      "queryText": "SELECT * FROM orders WHERE customer_id = $1",
      "executionCount": 1420,
      "averageDurationMilliseconds": 12.4,
      "averageIoTimeMilliseconds": 3.1,
      "averageBlocksRead": 37.5,
      "averageCacheBlocksHit": 2048,
      "averageBlocksWritten": 16
    }
  ],
  "status": "success"
}

Response object: JSendFailure

{
  "status": "fail",
  "data": {}
}

Response object: JSendMessageOnlyError

{
  "status": "error",
  "message": "string"
}

Response object: JSendMessageOnlyError

{
  "status": "error",
  "message": "string"
}

Response object: JSendFailure

{
  "status": "fail",
  "data": {}
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

Response object: JSendFailure

{
  "status": "fail",
  "data": {}
}

Response object: ProblemDetails

{
  "type": "string",
  "title": "string",
  "status": 0,
  "detail": "string",
  "instance": "string"
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

List SQL Server top queries

Returns the statements that put the most load on each requested SQL Server instance over the time range, with the query plans each statement ran under. Redgate Monitor samples the server's plan cache, so the figures cover the statements the server still held a plan for when each sample was taken. Supply one or more entity IDs (from GET /monitored-servers) to choose the servers to report on: a SQL Server instance, a database in one, a cluster or availability group, or a host, which stands for the SQL Server instances that run on it. At least one entity ID is required. The time range must be between 15 minutes and 31 days. When startTime and endTime are both omitted, the last hour is returned.

GET /api/v2/top-queries/sql-server

curl -G https://your-host/api/v2/top-queries/sql-server \
  -H "Authorization: Bearer $TOKEN" \
  --data-urlencode "entityIds=value" \
  --data-urlencode "queryTextFragment=value" \
  --data-urlencode "startTime=2024-01-01T00:00:00Z" \
  --data-urlencode "endTime=2024-01-01T00:00:00Z"

Query parameters

entityIds array · entity-id REQUIRED

One or more entity IDs naming the servers to report on. Use the entityId values returned by GET /monitored-servers. A host ID stands for the instances that run on the host. Repeat the parameter for multiple values.

queryTextFragment string OPTIONAL

Optional search term. Only statements whose text matches the term are returned. Omit to return the top statements regardless of their text.

startTime string · date-time OPTIONAL

Start of the time range (UTC). Defaults to one hour before endTime, or one hour before the current time when endTime is also omitted. The range must be between 15 minutes and 31 days.

endTime string · date-time OPTIONAL

End of the time range (UTC). Must be later than startTime when startTime is provided. Defaults to the current time. The range must be between 15 minutes and 31 days.

Responses

200 — The top statements of each requested server (empty array when none of them ran a statement in the range)

Response object: TopQueriesSqlServer array

{
  "data": [
    {
      "serverEntityId": "r1,4:base,s36:4bba3b44-5634-4b33-aff8-f53c4315efe3,7:Cluster,1,4:Name,s15:dev-prod,9:SqlServer,1,4:Name,s8:instance,",
      "serverEntityTypes": [
        "SqlServerInstance"
      ],
      "serverEntityName": "PROD-SQL-01\\instance",
      "databaseName": "AdventureWorks",
      "queryHash": "0x6b3e2f1a8c4d5e70",
      "queryText": "SELECT TOP 10 * FROM Sales.SalesOrderHeader WHERE CustomerID = @p0",
      "queryPlanGroups": [
        {
          "planHandle": "0x0600050027f1a20f10a1c58b0100000001000000000000000000000000000000",
          "databaseObjectName": "Sales.uspGetOrderSummary",
          "executionCount": 1420,
          "averageDurationMilliseconds": 12.4,
          "averageCpuTimeMilliseconds": 8.1,
          "averageLogicalReads": 2048,
          "averageLogicalWrites": 16,
          "averagePhysicalReads": 37.5,
          "averageMemoryGrantKilobytes": 1024,
          "averageUsedMemoryGrantKilobytes": 768,
          "impactScore": 7.32
        }
      ]
    }
  ],
  "status": "success"
}

Response object: JSendFailure

{
  "status": "fail",
  "data": {}
}

Response object: JSendMessageOnlyError

{
  "status": "error",
  "message": "string"
}

Response object: JSendMessageOnlyError

{
  "status": "error",
  "message": "string"
}

Response object: JSendFailure

{
  "status": "fail",
  "data": {}
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

Response object: JSendFailure

{
  "status": "fail",
  "data": {}
}

Response object: ProblemDetails

{
  "type": "string",
  "title": "string",
  "status": 0,
  "detail": "string",
  "instance": "string"
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

Response object: JSendError

{
  "status": "error",
  "message": "string"
}

This documentation contains proprietary information and is protected by copyright law.
Copyright © 2026 Red Gate Software Limited. All rights reserved


Didn't find what you were looking for?