Tool: get_advanced_aggregated_query_stats
Fetches aggregated query execution statistics for a requested AlloyDB instance within a specified time period. Supports filtering by database name, database user, and a specific query ID, as well as pagination. Returns statistics including query ID, database name, total execution time (sum(execution_time)), average execution time (avg(execution_time)), total execution count (sum(count)), total wait time (sum(wait_time)), and normalized query text. Requires advanced query insights to be enabled.
The following sample demonstrate how to use curl to invoke the get_advanced_aggregated_query_stats MCP tool.
| Curl Request |
|---|
curl --location 'https://databaseinsights.googleapis.com/mcp' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "get_advanced_aggregated_query_stats", "arguments": { // provide these details according to the tool's MCP specification } }, "jsonrpc": "2.0", "id": 1 }' |
Input Schema
Message for fetching query execution statistics (including execution times, count, wait times, and normalized query text) for the requested instance.
FetchQueryStatsRequest
| JSON representation |
|---|
{ "parent": string, "fullResourceName": string, "startTime": string, "endTime": string, "database": string, "username": string, "queryId": string, "pageSize": integer, "pageToken": string } |
| Fields | |
|---|---|
parent |
Required. The name of the location where we request stats. Format: |
fullResourceName |
Required. Identifies the AlloyDB instance. |
startTime |
Optional. The beginning of the interval for fetching stats in RFC3339 format. |
endTime |
Optional. The end of the interval for fetching stats in RFC3339 format. |
database |
Optional. Filters results to a specific database name. |
username |
Optional. Filters results to a specific database user. |
queryId |
Optional. Fetches aggregated stats for a single, specific query ID. |
pageSize |
Optional. The maximum number of query stats to return. |
pageToken |
Optional. Token for fetching the next set of results. |
Output Schema
Response message containing query execution statistics, including query ID, database, sum and average of execution time, execution count, sum of wait time, and normalized query text.
FetchQueryStatsResponse
| JSON representation |
|---|
{
"results": [
array
],
"metadata": {
object ( |
| Fields | |
|---|---|
results[] |
Rows of data returned based on the user query. |
metadata |
List of all the fields the client has interactions for. |
nextPageToken |
Support for pagination. |
ListValue
| JSON representation |
|---|
{ "values": [ value ] } |
| Fields | |
|---|---|
values[] |
Repeated field of dynamically typed values. |
Value
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field kind. The kind of value. kind can be only one of the following: |
|
nullValue |
Represents a JSON |
numberValue |
Represents a JSON number. Must not be |
stringValue |
Represents a JSON string. |
boolValue |
Represents a JSON boolean ( |
structValue |
Represents a JSON object. |
listValue |
Represents a JSON array. |
Struct
| JSON representation |
|---|
{ "fields": { string: value, ... } } |
| Fields | |
|---|---|
fields |
Unordered map of dynamically typed values. An object containing a list of |
FieldsEntry
| JSON representation |
|---|
{ "key": string, "value": value } |
| Fields | |
|---|---|
key |
|
value |
|
ResultSetMetadata
| JSON representation |
|---|
{
"fields": [
{
object ( |
| Fields | |
|---|---|
fields[] |
Information on all columns of the result row. |
Field
| JSON representation |
|---|
{
"name": string,
"type": enum ( |
| Fields | |
|---|---|
name |
Field name according to the public schema. |
type |
Field type defined according to the public schema or depends on the aggregation method in case of an aggregation field. |
description |
Description of the value the field holds. |
NullValue
Represents a JSON null.
NullValue is a sentinel, using an enum with only one value to represent the null value for the Value type union.
A field of type NullValue with any value other than 0 is considered invalid. Most ProtoJSON serializers will emit a Value with a null_value set as a JSON null regardless of the integer value, and so will round trip to a 0 value.
| Enums | |
|---|---|
NULL_VALUE |
Null value. |
FieldType
Type of field, which will define how to read a particular key.
| Enums | |
|---|---|
FIELD_TYPE_UNSPECIFIED |
Field type is unknown. |
INT64 |
Int64 field type. |
UINT64 |
Unsigned int64 field type. |
INT32 |
Int32 field type. |
UINT32 |
Unsigned int64 field type. |
STRING |
String field type. |
DOUBLE |
Double based data type. |
ARRAY |
Trace info type. |
BOOL |
Boolean field type. |
Tool Annotations
Destructive Hint: ❌ | Idempotent Hint: ✅ | Read Only Hint: ✅ | Open World Hint: ❌