{"data":{"slug":"github-google-skills-skills-cloud-cloud-monitoring-list-time-series-request-91c8133bbc1f","title":"Cloud Monitoring ListTimeSeries Request Generator","summary":"Generates valid Cloud Monitoring ListTimeSeries requests and aggregation specifications from metric descriptors and resource parameters, requiring explicit GCP Project ID clarification and adherence to specific filter syntax rules.","url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-cloud-monitoring-list-time-series-request-91c8133bbc1f","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-google-skills-skills-cloud-cloud-monitoring-list-time-series-request-91c8133bbc1f","markdown_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-cloud-monitoring-list-time-series-request-91c8133bbc1f.md","download_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-cloud-monitoring-list-time-series-request-91c8133bbc1f\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before generating or executing `ListTimeSeries` requests, ensure the GCP Project ID is explicitly provided in the user prompt, input payload, or environment context. If missing, ask the user to clarify it. Do not use placeholders for project names. For metrics like `agent.googleapis.com\/memory\/percent_used` and `agent.googleapis.com\/disk\/percent_used`, use `metric.labels.state != \"free\"` in the filter.","instructions":"---\nname: cloud-monitoring-list-time-series-request\nmetadata:\n  version: \"1.0.1\"\n  category: CloudObservabilityAndMonitoring\ndescription: >-\n  Generates valid Cloud Monitoring ListTimeSeries requests and aggregation\n  specifications from metric descriptors and resource parameters. Use when asked\n  to create, generate, format, or build ListTimeSeries requests, JSON payloads,\n  filter expressions, or aligner\/reducer aggregations for Cloud Monitoring\n  metrics and charts. Don't use for metric discovery or metric selection.\n---\n\n# Cloud Monitoring ListTimeSeries Request Generator\n\nUse this skill to translate any Cloud Monitoring metric descriptor into valid,\nproduction-ready `ListTimeSeries` REST API query parameters (`name`, `filter`,\n`interval.startTime`, `interval.endTime`, `aggregation.*`, `view`).\n\n## Attribution\n\n**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you\nMUST read [Usage Attribution](references\/attribution.md). For commands executed\ndirectly in the terminal (never in generated scripts, Terraform, or user code),\nprefix `gcloud` with\n`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION=\"agent-skills\/1.0 (skill:cloud-monitoring-list-time-series-request)\"`\nand append `agent-skills\/1.0 (skill:cloud-monitoring-list-time-series-request)` to `User-Agent` headers.\n\n## CRITICAL RULES\n\n*   **Mandatory Project ID Clarification**: You MUST ensure the GCP Project ID\n    is present in the user prompt, input payload, or environment context (such\n    as via `gcloud config get-value project`). If the Project ID is missing and\n    cannot be resolved, you MUST ask the user to clarify it before generating or\n    executing `ListTimeSeries` requests. Do NOT use placeholders for project\n    names.\n\n## Workflow\n\n### Inspect Metric Metadata\n\n1.  **Use Provided Metric Metadata First**: If the user's prompt already\n    includes metric metadata such as `metric.type`, `metricKind`, `valueType`,\n    resource types, or label keys, use those values directly instead of calling\n    API tools.\n2.  **Discover Missing Metadata**: If exact metric descriptors including\n    `metric.type`, `metricKind`, and `valueType` are missing or underspecified,\n    resolve the target metric's descriptor using one of these paths:\n    *   **Vague Query**: If the prompt is vague, such as asking for VM CPU\n        usage, use the `cloud-monitoring-metric-selection` skill first to\n        identify the specific metric type.\n    *   **Known Metric Type**: If you already have the specific metric type name\n        such as `compute.googleapis.com\/instance\/cpu\/utilization`, but need its\n        descriptor, call the `list_metric_descriptors` MCP tool. If the tool is\n        missing, refer to the `cloud-monitoring-metric-selection` skill to\n        configure the Cloud Monitoring MCP server.\n    *   **Fallback**: If the MCP tool cannot be configured, fall back to making\n        a direct Cloud Monitoring API call.\n3.  **Identify Key Fields**: From the retrieved descriptor, identify key schema\n    attributes:\n    *   **`type`**: The Cloud Monitoring metric type string.\n    *   **`metricKind`**: `GAUGE`, `DELTA`, or `CUMULATIVE`.\n    *   **`valueType`**: `INT64`, `DOUBLE`, `DISTRIBUTION`, or `BOOL`.\n    *   **`monitoredResourceTypes`**: Compatible `resource.type` strings, for\n        example `[\"cloudsql_database\", \"cloudsql_instance\"]`. If multiple\n        resource types are listed, select the specific `resource.type` that\n        matches the target granularity of the user's request.\n\n--------------------------------------------------------------------------------\n\n### Construct Monitoring Filter\n\nThe `filter` parameter is a mandatory string in Cloud Monitoring syntax that\nrestricts the query to a single `metric.type` and optional resource and metric\nlabels:\n\n1.  **Single Metric Type Restriction**: Every `filter` MUST specify exactly one\n    `metric.type` clause using an equality operator. For example:\n    *   `metric.type = \"compute.googleapis.com\/instance\/cpu\/utilization\"`\n2.  **Monitored Resource Type Filter**: MUST include the `resource.type` filter\n    when the target resource granularity is known, preventing collisions across\n    services that share metric types or sub-resources. For example:\n    *   `metric.type = \"cloudsql.googleapis.com\/database\/cpu\/utilization\" AND\n        resource.type = \"cloudsql_database\"`\n3.  **Preserve User Literals and IDs**: You MUST use literal resource names,\n    IDs, zones, and project parameters provided by the user without alteration.\n    Do NOT override or replace user-specified identifiers with active resources\n    found during metric metadata discovery unless explicitly requested.\n\n4.  **Label Type Prefixing**:\n\n    *   Prefix resource-level dimensions, such as instance ID, zone, project,\n        database ID, or subscription ID, with the `resource.labels.` prefix. For\n        example:\n        *   `resource.labels.instance_id = \"123456789\"`\n        *   `resource.labels.database_id = \"my-project:my-instance\"`\n    *   Prefix metric-level dimensions, such as state, command, response code,\n        or instance name metadata when stored on the metric, with the\n        `metric.labels.` prefix. For example:\n        *   `metric.labels.state != \"free\"`\n        *   `metric.labels.instance_name = \"instance-1\"`\n\n5.  **Resource Name versus ID Resolution**:\n\n    *   If the user specifies a human-readable GCE VM instance name such as\n        `\"instance-1\"`, but `resource.labels.instance_id` expects a numeric ID,\n        you MUST filter using either `metric.labels.instance_name =\n        \"instance-1\"` or `metadata.system_labels.name = \"instance-1\"`.\n    *   Do NOT use `resource.metadata.name` or `resource.metadata.*`. This\n        prefix is invalid in Cloud Monitoring filter syntax.\n    *   Do NOT assign a string instance name directly to\n        `resource.labels.instance_id` unless the resource type explicitly uses\n        string IDs.\n\n6.  **Database Identifier Labels**: Database labels such as `database_id` for\n    Cloud SQL and Spanner, or `dataset_id` for BigQuery, use composite keys\n    formatted as `<project_id>:<instance_name>`. For example:\n    `resource.labels.database_id = \"my-project:foo\"`.\n\n7.  **Ops Agent Metrics State Label Filtering**: For\n    `agent.googleapis.com\/memory\/percent_used` and\n    `agent.googleapis.com\/disk\/percent_used` metrics, you MUST use\n    `metric.labels.state != \"free\"`. Do NOT filter by `metric.labels.state =\n    \"used\"`.\n\n--------------------------------------------------------------------------------\n\n### Choose Aggregation Structure\n\nSelect the `perSeriesAligner`, `crossSeriesReducer`, `groupByFields`, and\n`alignmentPeriod` according to the metric properties and visualization goal:\n\n1.  **Consult the Aggregations Reference**: You MUST include both\n    `perSeriesAligner` and `crossSeriesReducer` in the `aggregation` query\n    parameters of every request. Read and follow the\n    [Cloud Monitoring ListTimeSeries Basic Aggregations Reference](references\/basic_aggregations.md)\n    to select the exact `perSeriesAligner` and `crossSeriesReducer` combinations\n    for your metric's Metric Kind and Value Type pairing, and to apply mandatory\n    SRE rules for utilization metrics, counters, distributions, and state-based\n    gauges such as memory filtered by `state != \"free\"`.\n2.  **Grouping Fields and Resource Granularity**: When `crossSeriesReducer` is\n    specified as anything other than `REDUCE_NONE`, list the exact labels to\n    preserve. When querying multi-instance resources like VMs, databases, or\n    subscriptions, include the primary resource identifier in `groupByFields`.\n    For example, use `resource.labels.instance_id` for VMs or\n    `resource.labels.database_id` for databases. This prevents collapsing\n    separate resource streams into a single global aggregate.\n3.  **Alignment Period Determination**: Calculate the query lookback duration\n    from `endTime` minus `startTime`, ensuring `startTime` precedes `endTime`.\n    If `endTime <= startTime`, flag an error before computing duration. Set\n    `alignmentPeriod` according to Cloud Console default fine granularity\n    standards:\n    *   **Duration <= 110 minutes**: Set `alignmentPeriod = \"60s\"`.\n    *   **Duration <= 23 hours**: Set `alignmentPeriod = \"300s\"`.\n    *   **Duration <= 6 days**: Set `alignmentPeriod = \"3600s\"`.\n    *   **Duration <= 23 days**: Set `alignmentPeriod = \"10800s\"`.\n    *   **Duration <= 80 days**: Set `alignmentPeriod = \"21600s\"`.\n    *   **Duration <= 180 days**: Set `alignmentPeriod = \"43200s\"`.\n    *   **Duration <= 350 days**: Set `alignmentPeriod = \"86400s\"`.\n    *   **Duration <= 500 days**: Set `alignmentPeriod = \"172800s\"`.\n    *   **Omission Rule**: `alignmentPeriod` is omitted only when\n        `perSeriesAligner` is set to `ALIGN_NONE`.\n\n--------------------------------------------------------------------------------\n\n### Format Valid Request\n\nPresent the generated `ListTimeSeries` REST query parameters. For example:\n\n```json\n{\n  \"name\": \"projects\/<project_id>\",\n  \"filter\": \"metric.type = \\\"<metric_type>\\\" AND resource.type = \\\"<resource_type>\\\"\",\n  \"interval\": {\n    \"startTime\": \"<iso_8601_start>\",\n    \"endTime\": \"<iso_8601_end>\"\n  },\n  \"aggregation\": {\n    \"alignmentPeriod\": \"60s\",\n    \"perSeriesAligner\": \"ALIGN_RATE\",\n    \"crossSeriesReducer\": \"REDUCE_SUM\",\n    \"groupByFields\": [\n      \"resource.labels.zone\"\n    ]\n  },\n  \"view\": \"FULL\"\n}\n```\n\n*   **Aggregation Requirements**: Populate the `aggregation` parameters with the\n    `perSeriesAligner`, `crossSeriesReducer`, `alignmentPeriod`, and optional\n    `groupByFields` values determined during aggregation selection.\n*   **Interval Requirements**: `startTime` and `endTime` MUST be valid RFC 3339\n    and ISO 8601 timestamps such as `\"YYYY-MM-DDTHH:MM:SSZ\"`. If not explicitly\n    provided by the user, dynamically compute a one-hour lookback interval\n    ending at the current time, where `endTime` is the present moment and\n    `startTime` is one hour prior. Do NOT hardcode static dates from examples.\n*   **Alignment Period Requirement**: Determine `alignmentPeriod` from the\n    lookback duration of `endTime` minus `startTime` using the mapping above.\n    For the default one-hour lookback interval, `alignmentPeriod` is `\"60s\"`.\n*   **View Requirement**: MUST default to `\"FULL\"` when time series data points\n    are needed, or `\"HEADERS\"` when inspecting metadata and series identities\n    only.\n\n--------------------------------------------------------------------------------\n\n### Validate Request via list_timeseries MCP Tool\n\nYou MUST validate the generated request parameters against live Cloud Monitoring\ntelemetry before returning the final output. Call the `list_timeseries` MCP tool\npassing all generated query parameters (`name`, `filter`, `interval`,\n`aggregation`). When validating you MUST set `view=\"HEADERS\"` to minimize\nlatency and payload size while verifying request structure. A response without\nAPI errors confirms that your filter and aggregation settings are valid.\n\nIf the `list_timeseries` tool is unavailable, fall back to a direct API call.\n\n--------------------------------------------------------------------------------\n\n## References\n\n*   [Cloud Monitoring ListTimeSeries Basic Aggregations Reference](references\/basic_aggregations.md)\n*   [Cloud Monitoring Monitored Resource Types Reference](https:\/\/docs.cloud.google.com\/monitoring\/api\/resources.md.txt)\n*   [Cloud Monitoring Filter Syntax](https:\/\/docs.cloud.google.com\/monitoring\/api\/v3\/filters.md.txt)\n*   [Cloud Monitoring REST API Reference: projects.timeSeries.list](https:\/\/docs.cloud.google.com\/monitoring\/api\/ref_v3\/rest\/v3\/projects.timeSeries\/list.md.txt)\n","use_cases":["Create ListTimeSeries requests for CPU utilization metrics of Compute Engine instances","Generate filter expressions for Cloud SQL database metrics","Build aggregation specifications for network utilization metrics"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/google\/skills\/blob\/e3c591afe426ea585e4c21799e5199d6d47cd1be\/skills\/cloud\/cloud-monitoring-list-time-series-request\/SKILL.md","source_commit":"e3c591afe426ea585e4c21799e5199d6d47cd1be","license":null,"version":null,"listing_approved_at":"2026-11-17","created_at":"2026-11-16T13:11:22.000000Z","updated_at":"2026-11-17T05:10:16.000000Z","seo_title":"Cloud Monitoring ListTimeSeries Request Generator","seo_description":"Generate valid Cloud Monitoring ListTimeSeries requests and aggregation specifications from metric descriptors and resource parameters, with mandatory Project ID and synt","seo_keywords":["Cloud Monitoring ListTimeSeries request","Generate Cloud Monitoring filter","Cloud Monitoring aggregation specification","Cloud Monitoring metric request","Cloud Monitoring filter expression"]}}