Event Information
-
What the event means
google.monitoring.v3.MetricService.CreateMetricDescriptoris an API call to create a new metric descriptor in Cloud Monitoring. This defines a new metric type (usually a custom metric), including its name, labels, unit, value type, and description, which Cloud Monitoring will then accept time series data for. -
When/why it occurs operationally
It is triggered when:- You or a service run
gcloud monitoring metrics descriptors create, use the REST/Client API, or deploy something (e.g., code, Terraform, Deployment Manager) that defines a new custom metric. - Applications or agents start exporting metrics with a previously unknown type, causing automated creation (if implemented that way).
- You or a service run
-
Security & compliance relevance
- Creation of new metrics can expose new data categories (e.g., PII, system internals), so this event should be logged and monitored for change control (ISO 27001 A.12, SOC 2 CC8, PCI-DSS 10).
- Repeated or unexpected metric descriptor creation can indicate misconfiguration or abuse (e.g., noisy or data-exfil-like metrics), so consider alerting on anomalous patterns and enforcing least privilege (
monitoring.metricDescriptors.create).
Examples
-
Creation of metrics exposing sensitive data (PII/secrets/keys)
- Example: A custom metric descriptor
custom.googleapis.com/user_emailorcustom.googleapis.com/jwt_tokenis created, causing PII/tokens to be exported to logs, dashboards, and external sinks (e.g., Pub/Sub, BigQuery, Splunk), violating GDPR/CCPA or internal data-handling policies. - Mitigation: Restrict who can call
CreateMetricDescriptorvia IAM, enforce naming/labeling conventions with org policies, and use DLP scans on Monitoring exports.
- Example: A custom metric descriptor
-
Stealthy exfiltration or C2 channel via custom metrics
- Example: An attacker with limited permissions uses
CreateMetricDescriptorplus metric writes to encode and exfiltrate database query results or secrets into time-series labels/values, which then get exported to external monitoring backends, breaching data residency and confidentiality (e.g., SOC 2, ISO 27001). - Mitigation: Monitor and alert on anomalous metric descriptor creations (unused services, odd names, high-cardinality labels), review export sinks, and apply least-privilege on metric write roles.
- Example: An attacker with limited permissions uses
-
Compliance and logging blind spots through unreviewed security metrics
- Example: A team creates a metric
custom.googleapis.com/firewall_deniesbut misconfigures labels/types, leading to missing or inaccurate security telemetry required for PCI-DSS/ISO 27001 control evidence (e.g., incomplete logging of access denials). - Mitigation: Govern metric descriptor creation via change management, standardize security-related metric schemas, and periodically audit descriptors for correctness and alignment with compliance logging requirements.
- Example: A team creates a metric
Remediation
Using Console
-
Lock down who can create / write custom metrics (prevent PII & exfiltration)
- In GCP Console: go to IAM & Admin → IAM, filter for roles containing
Monitoring Metric WriterorMonitoring Admin. - For each project/folder/org, remove broad roles like
roles/monitoring.editor,roles/owner, orroles/editorfrom general groups; instead grant:roles/monitoring.metricWriteronly to service accounts that truly need to push metrics.roles/monitoring.adminorroles/monitoring.metricDescriptors.writeronly to a small SRE/Platform group.
- Under IAM & Admin → Roles, create custom roles that exclude
monitoring.metricDescriptors.createand assign them to regular developers; reserve metric descriptor creation for a controlled group (supports least-privilege for SOC 2, ISO 27001).
- In GCP Console: go to IAM & Admin → IAM, filter for roles containing
-
Review, clean up, and govern metric descriptors & exports (PII, C2, and compliance)
- In Monitoring → Metrics explorer → Query tab → Metric, type
custom.googleapis.com/to list custom metrics; look for:- PII/secrets (e.g.,
user_email,jwt_token,session_id,api_keyin names/labels). - Suspicious / high-cardinality patterns (
query_result_*,*_dump, long random strings in labels). - Misconfigured security metrics (e.g.,
firewall_deniesmissing key labels such assource_ip,action).
- PII/secrets (e.g.,
- For each problematic metric:
- Open Monitoring → Metrics scope → Metric descriptors, select the metric, and document and deprecate it (you cannot delete data, but you can:
- Stop writes by updating applications, removing the writer’s IAM, or disabling the involved service account under IAM & Admin → Service Accounts.
- Update dashboards/alerts to stop using the bad metric and migrate to a corrected schema.)
- Open Monitoring → Metrics scope → Metric descriptors, select the metric, and document and deprecate it (you cannot delete data, but you can:
- In Monitoring → Notifications & integrations → Sinks / Export (or Logging → Logs Router if you export Monitoring via logs), review all exports (Pub/Sub, BigQuery, Splunk, etc.):
- Ensure exports with Monitoring/
timeSeriesdata only go to approved locations (data residency, GDPR/CCPA). - Restrict sink service account IAM on targets (BigQuery dataset, Pub/Sub topic, bucket) to least-privilege.
- Ensure exports with Monitoring/
- In Monitoring → Metrics explorer → Query tab → Metric, type
-
Standardize metrics & add monitoring for abuse / gaps (governance & detection)
- Define a central metrics standard (name prefix, allowed labels, and data types) in your security/platform docs, e.g.:
- Names:
custom.googleapis.com/security/firewall_denieswith fixed labels (source_ip,dest_ip,action,rule_name). - Explicit rule: no PII or secrets in metric names, labels, or values (GDPR/CCPA).
- Names:
- Implement change control: require metric descriptor changes to go through a ticket/PR reviewed by security/compliance; in Console, restrict
roles/monitoring.adminto that change-control group. - In Monitoring → Alerting → Create policy:
- Add conditions on Metric: “API request count” filtered on
method="google.monitoring.v3.MetricService.CreateMetricDescriptor"to alert on:- New custom metrics in unusual projects/services.
- Metrics with suspicious names (match filters like
metric.type=starts_with("custom.googleapis.com/") AND metric.type:("token" OR "email" OR "jwt" OR "secret" OR "key")via logs-based metrics + alerting).
- Periodically export metric descriptors (via script/CSPM tool) and use DLP or regex scans on names/labels in your CI/CD or security review to catch PII/secrets and ensure key security metrics meet PCI-DSS / ISO 27001 evidence requirements.
- Add conditions on Metric: “API request count” filtered on
- Define a central metrics standard (name prefix, allowed labels, and data types) in your security/platform docs, e.g.:
Using CLI
-
Lock down who can create/write sensitive custom metrics (PII/exfil paths)
- Identify and review who currently can create descriptors and write metrics:
- List IAM on the project / folder / org for Monitoring roles:
- List IAM on the project / folder / org for Monitoring roles:
- Remove broad
monitoring.admin/monitoring.metricWriterfrom non-platform/service principals; replace with least-privilege roles or custom roles withoutmonitoring.metricDescriptors.createandmonitoring.timeSeries.create: - For sensitive environments (GDPR/CCPA/SOC 2), restrict metric descriptor creation to a small admin group and enforce approval via change management (e.g., PR + ticket) before granting:
- Create a custom role without descriptor-creation permissions:
- Bind only this role to app SAs:
- Create a custom role without descriptor-creation permissions:
- Identify and review who currently can create descriptors and write metrics:
-
Detect/clean up PII / C2-like metrics and secure exports
- Enumerate and review custom metric descriptors for PII/secrets and suspicious C2-style naming or high-cardinality labels:
- Delete offending metrics (break exfil path; document for audit):
- Delete offending metrics (break exfil path; document for audit):
- Audit and harden export sinks that could receive sensitive metric data (BigQuery, Pub/Sub, Logging):
- Restrict IAM on these sinks to least privilege and ensure data residency controls (e.g., EU-only BigQuery datasets).
- Implement anomaly detection using Monitoring or Logging for:
- Unusual descriptor creation events (names like
jwt,token,secret,query_result, high-label-cardinality, created by unexpected principals). - Use Cloud Logging queries on
protoPayload.methodName="google.monitoring.v3.MetricService.CreateMetricDescriptor"and set alerts:
- Unusual descriptor creation events (names like
- Enumerate and review custom metric descriptors for PII/secrets and suspicious C2-style naming or high-cardinality labels:
-
Standardize & continuously audit security/compliance metrics
- Define a catalog of approved security metrics (e.g.,
custom.googleapis.com/security/firewall_denies) with fixed label schemas; store definitions in source control and require change-approval before creation. Create descriptors only via automated pipelines, not ad hoc: - Periodically validate existing descriptors against your standard and compliance requirements (PCI-DSS, ISO 27001 logging controls):
- For exports used as evidence (e.g., SOC 2/PCI reporting pipelines), ensure completeness/accuracy:
- Verify that required labels (e.g.,
source_ip,dest_ip,action) exist and have correct types; fix by updating descriptor (delete + recreate) and updating producers. - Run scheduled DLP scans on BigQuery tables / logs receiving metrics containing user-related or network fields to ensure no PII or secrets leak into monitoring datasets.
- Verify that required labels (e.g.,
- Define a catalog of approved security metrics (e.g.,
Using Python
-
Lock down who can create/write custom metrics (IAM + org policy)
- Restrict roles like
roles/monitoring.metricWriterand especiallyroles/monitoring.adminto tightly controlled service accounts / groups; remove broad grants on projects/folders/org. - Use org policies / policy constraints (e.g. label/namespace conventions enforced via CI/CD) to prevent PII in metric names/labels; add pre-commit / pre-merge checks for
custom.googleapis.com/*. - Example Python helper to list and then remove overly broad IAM bindings on a project for Monitoring roles (run from an admin workstation / pipeline):
- Restrict roles like
-
Detect and respond to suspicious or non-compliant custom metrics (DLP, audits, alerts)
- Periodically scan metric descriptors for PII/secrets patterns in names and labels (GDPR/CCPA) and for stealth exfil channels (weird names, high-cardinality labels, unused services).
- Combine this with reviews of Monitoring export sinks (Pub/Sub, BigQuery, Splunk) to ensure they are approved, encrypted, and conform to data residency (SOC 2 / ISO 27001).
- Example Python script to list custom descriptors and flag risky ones (for review / auto-create tickets or break build):
-
Standardize and validate security/compliance metrics before use (governance + linting)
- Maintain approved schemas for security metrics (e.g.
custom.googleapis.com/security/firewall_denies) with mandatory labels and types aligned to PCI-DSS/ISO 27001 evidence requirements. - Enforce that all new metric descriptors are created only via CI/CD (not ad-hoc) and pass a validation step (no PII, correct label sets, no high-cardinality or free-form text).
- Example Python “lint” for metric descriptors (run in CI before
CreateMetricDescriptor):
- Maintain approved schemas for security metrics (e.g.

