Cloud Monitoring ListTimeSeries Request Builder

Cloud Monitoring ListTimeSeries Request Builder

Generates valid Cloud Monitoring ListTimeSeries requests, filters and aggregations from metric descriptors and resource details, asking for a project ID when it is missing.

Skill files3 files

references/

SKILL.md226 lines
1
---
2
name: cloud-monitoring-list-time-series-request
3
metadata:
4
version: "1.0.1"
5
category: CloudObservabilityAndMonitoring
6
description: >-
7
Generates valid Cloud Monitoring ListTimeSeries requests and aggregation
8
specifications from metric descriptors and resource parameters. Use when asked
9
to create, generate, format, or build ListTimeSeries requests, JSON payloads,
10
filter expressions, or aligner/reducer aggregations for Cloud Monitoring
11
metrics and charts. Don't use for metric discovery or metric selection.
12
---
13
14
# Cloud Monitoring ListTimeSeries Request Generator
15
16
Use this skill to translate any Cloud Monitoring metric descriptor into valid,
17
production-ready `ListTimeSeries` REST API query parameters (`name`, `filter`,
18
`interval.startTime`, `interval.endTime`, `aggregation.*`, `view`).
19
20
## Attribution
21
22
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
23
MUST read [Usage Attribution](references/attribution.md). For commands executed
24
directly in the terminal (never in generated scripts, Terraform, or user code),
25
prefix `gcloud` with
26
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:cloud-monitoring-list-time-series-request)"`
27
and append `agent-skills/1.0 (skill:cloud-monitoring-list-time-series-request)` to `User-Agent` headers.
28
29
## CRITICAL RULES
30
31
* **Mandatory Project ID Clarification**: You MUST ensure the GCP Project ID
32
is present in the user prompt, input payload, or environment context (such
33
as via `gcloud config get-value project`). If the Project ID is missing and
34
cannot be resolved, you MUST ask the user to clarify it before generating or
35
executing `ListTimeSeries` requests. Do NOT use placeholders for project
36
names.
37
38
## Workflow
39
40
### Inspect Metric Metadata
41
42
1. **Use Provided Metric Metadata First**: If the user's prompt already
43
includes metric metadata such as `metric.type`, `metricKind`, `valueType`,
44
resource types, or label keys, use those values directly instead of calling
45
API tools.
46
2. **Discover Missing Metadata**: If exact metric descriptors including
47
`metric.type`, `metricKind`, and `valueType` are missing or underspecified,
48
resolve the target metric's descriptor using one of these paths:
49
* **Vague Query**: If the prompt is vague, such as asking for VM CPU
50
usage, use the `cloud-monitoring-metric-selection` skill first to
51
identify the specific metric type.
52
* **Known Metric Type**: If you already have the specific metric type name
53
such as `compute.googleapis.com/instance/cpu/utilization`, but need its
54
descriptor, call the `list_metric_descriptors` MCP tool. If the tool is
55
missing, refer to the `cloud-monitoring-metric-selection` skill to
56
configure the Cloud Monitoring MCP server.
57
* **Fallback**: If the MCP tool cannot be configured, fall back to making
58
a direct Cloud Monitoring API call.
59
3. **Identify Key Fields**: From the retrieved descriptor, identify key schema
60
attributes:
61
* **`type`**: The Cloud Monitoring metric type string.
62
* **`metricKind`**: `GAUGE`, `DELTA`, or `CUMULATIVE`.
63
* **`valueType`**: `INT64`, `DOUBLE`, `DISTRIBUTION`, or `BOOL`.
64
* **`monitoredResourceTypes`**: Compatible `resource.type` strings, for
65
example `["cloudsql_database", "cloudsql_instance"]`. If multiple
66
resource types are listed, select the specific `resource.type` that
67
matches the target granularity of the user's request.
68
69
--------------------------------------------------------------------------------
70
71
### Construct Monitoring Filter
72
73
The `filter` parameter is a mandatory string in Cloud Monitoring syntax that
74
restricts the query to a single `metric.type` and optional resource and metric
75
labels:
76
77
1. **Single Metric Type Restriction**: Every `filter` MUST specify exactly one
78
`metric.type` clause using an equality operator. For example:
79
* `metric.type = "compute.googleapis.com/instance/cpu/utilization"`
80
2. **Monitored Resource Type Filter**: MUST include the `resource.type` filter
81
when the target resource granularity is known, preventing collisions across
82
services that share metric types or sub-resources. For example:
83
* `metric.type = "cloudsql.googleapis.com/database/cpu/utilization" AND
84
resource.type = "cloudsql_database"`
85
3. **Preserve User Literals and IDs**: You MUST use literal resource names,
86
IDs, zones, and project parameters provided by the user without alteration.
87
Do NOT override or replace user-specified identifiers with active resources
88
found during metric metadata discovery unless explicitly requested.
89
90
4. **Label Type Prefixing**:
91
92
* Prefix resource-level dimensions, such as instance ID, zone, project,
93
database ID, or subscription ID, with the `resource.labels.` prefix. For
94
example:
95
* `resource.labels.instance_id = "123456789"`
96
* `resource.labels.database_id = "my-project:my-instance"`
97
* Prefix metric-level dimensions, such as state, command, response code,
98
or instance name metadata when stored on the metric, with the
99
`metric.labels.` prefix. For example:
100
* `metric.labels.state != "free"`
101
* `metric.labels.instance_name = "instance-1"`
102
103
5. **Resource Name versus ID Resolution**:
104
105
* If the user specifies a human-readable GCE VM instance name such as
106
`"instance-1"`, but `resource.labels.instance_id` expects a numeric ID,
107
you MUST filter using either `metric.labels.instance_name =
108
"instance-1"` or `metadata.system_labels.name = "instance-1"`.
109
* Do NOT use `resource.metadata.name` or `resource.metadata.*`. This
110
prefix is invalid in Cloud Monitoring filter syntax.
111
* Do NOT assign a string instance name directly to
112
`resource.labels.instance_id` unless the resource type explicitly uses
113
string IDs.
114
115
6. **Database Identifier Labels**: Database labels such as `database_id` for
116
Cloud SQL and Spanner, or `dataset_id` for BigQuery, use composite keys
117
formatted as `<project_id>:<instance_name>`. For example:
118
`resource.labels.database_id = "my-project:foo"`.
119
120
7. **Ops Agent Metrics State Label Filtering**: For
121
`agent.googleapis.com/memory/percent_used` and
122
`agent.googleapis.com/disk/percent_used` metrics, you MUST use
123
`metric.labels.state != "free"`. Do NOT filter by `metric.labels.state =
124
"used"`.
125
126
--------------------------------------------------------------------------------
127
128
### Choose Aggregation Structure
129
130
Select the `perSeriesAligner`, `crossSeriesReducer`, `groupByFields`, and
131
`alignmentPeriod` according to the metric properties and visualization goal:
132
133
1. **Consult the Aggregations Reference**: You MUST include both
134
`perSeriesAligner` and `crossSeriesReducer` in the `aggregation` query
135
parameters of every request. Read and follow the
136
[Cloud Monitoring ListTimeSeries Basic Aggregations Reference](references/basic_aggregations.md)
137
to select the exact `perSeriesAligner` and `crossSeriesReducer` combinations
138
for your metric's Metric Kind and Value Type pairing, and to apply mandatory
139
SRE rules for utilization metrics, counters, distributions, and state-based
140
gauges such as memory filtered by `state != "free"`.
141
2. **Grouping Fields and Resource Granularity**: When `crossSeriesReducer` is
142
specified as anything other than `REDUCE_NONE`, list the exact labels to
143
preserve. When querying multi-instance resources like VMs, databases, or
144
subscriptions, include the primary resource identifier in `groupByFields`.
145
For example, use `resource.labels.instance_id` for VMs or
146
`resource.labels.database_id` for databases. This prevents collapsing
147
separate resource streams into a single global aggregate.
148
3. **Alignment Period Determination**: Calculate the query lookback duration
149
from `endTime` minus `startTime`, ensuring `startTime` precedes `endTime`.
150
If `endTime <= startTime`, flag an error before computing duration. Set
151
`alignmentPeriod` according to Cloud Console default fine granularity
152
standards:
153
* **Duration <= 110 minutes**: Set `alignmentPeriod = "60s"`.
154
* **Duration <= 23 hours**: Set `alignmentPeriod = "300s"`.
155
* **Duration <= 6 days**: Set `alignmentPeriod = "3600s"`.
156
* **Duration <= 23 days**: Set `alignmentPeriod = "10800s"`.
157
* **Duration <= 80 days**: Set `alignmentPeriod = "21600s"`.
158
* **Duration <= 180 days**: Set `alignmentPeriod = "43200s"`.
159
* **Duration <= 350 days**: Set `alignmentPeriod = "86400s"`.
160
* **Duration <= 500 days**: Set `alignmentPeriod = "172800s"`.
161
* **Omission Rule**: `alignmentPeriod` is omitted only when
162
`perSeriesAligner` is set to `ALIGN_NONE`.
163
164
--------------------------------------------------------------------------------
165
166
### Format Valid Request
167
168
Present the generated `ListTimeSeries` REST query parameters. For example:
169
170
```json
171
{
172
"name": "projects/<project_id>",
173
"filter": "metric.type = \"<metric_type>\" AND resource.type = \"<resource_type>\"",
174
"interval": {
175
"startTime": "<iso_8601_start>",
176
"endTime": "<iso_8601_end>"
177
},
178
"aggregation": {
179
"alignmentPeriod": "60s",
180
"perSeriesAligner": "ALIGN_RATE",
181
"crossSeriesReducer": "REDUCE_SUM",
182
"groupByFields": [
183
"resource.labels.zone"
184
]
185
},
186
"view": "FULL"
187
}
188
```
189
190
* **Aggregation Requirements**: Populate the `aggregation` parameters with the
191
`perSeriesAligner`, `crossSeriesReducer`, `alignmentPeriod`, and optional
192
`groupByFields` values determined during aggregation selection.
193
* **Interval Requirements**: `startTime` and `endTime` MUST be valid RFC 3339
194
and ISO 8601 timestamps such as `"YYYY-MM-DDTHH:MM:SSZ"`. If not explicitly
195
provided by the user, dynamically compute a one-hour lookback interval
196
ending at the current time, where `endTime` is the present moment and
197
`startTime` is one hour prior. Do NOT hardcode static dates from examples.
198
* **Alignment Period Requirement**: Determine `alignmentPeriod` from the
199
lookback duration of `endTime` minus `startTime` using the mapping above.
200
For the default one-hour lookback interval, `alignmentPeriod` is `"60s"`.
201
* **View Requirement**: MUST default to `"FULL"` when time series data points
202
are needed, or `"HEADERS"` when inspecting metadata and series identities
203
only.
204
205
--------------------------------------------------------------------------------
206
207
### Validate Request via list_timeseries MCP Tool
208
209
You MUST validate the generated request parameters against live Cloud Monitoring
210
telemetry before returning the final output. Call the `list_timeseries` MCP tool
211
passing all generated query parameters (`name`, `filter`, `interval`,
212
`aggregation`). When validating you MUST set `view="HEADERS"` to minimize
213
latency and payload size while verifying request structure. A response without
214
API errors confirms that your filter and aggregation settings are valid.
215
216
If the `list_timeseries` tool is unavailable, fall back to a direct API call.
217
218
--------------------------------------------------------------------------------
219
220
## References
221
222
* [Cloud Monitoring ListTimeSeries Basic Aggregations Reference](references/basic_aggregations.md)
223
* [Cloud Monitoring Monitored Resource Types Reference](https://docs.cloud.google.com/monitoring/api/resources.md.txt)
224
* [Cloud Monitoring Filter Syntax](https://docs.cloud.google.com/monitoring/api/v3/filters.md.txt)
225
* [Cloud Monitoring REST API Reference: projects.timeSeries.list](https://docs.cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list.md.txt)
226

© Google LLC · Apache 2.0 · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…