Google Cloud Logging and Monitoring operations
v0.3.8Google Cloud Logging and Monitoring diagnostics plus governed alert control: bounded log discovery and queries, metric queries, metric descriptors, Cloud Interconnect attachment utilization, and alert-policy reads, and enable or disable of one exact alert policy. Logging and metric reads plus the alert-policy mutations use stable Google Cloud REST APIs — the mutations patch only the policy's enabled field; the alert-policy list uses the GA gcloud command.
gcloud
curl
jq
Install
emisar pack install
fetches this pack, re-validates it, and verifies its content hash against the
--hash
below — the exact bytes this page was rendered against, so a tampered copy is
rejected — before copying it into the runner's packs dir. The command reloads a
running daemon itself; no manual restart.
sudo emisar pack install gcp-monitoring --hash sha256:cd3b6050e3da2f77a299464c72d03975dba827de18b3c69425c75eb37052c7cd
Setup
Uses gcloud authentication on the runner host. The Logging, metric, and alert-policy REST actions obtain a short-lived access token from gcloud and send it only to fixed Google Cloud API endpoints without placing it in argv or output.
Environment
Set these on the runner host, then add each name to
execution.inherit_env
so the value reaches the action.
-
CLOUDSDK_CONFIGOptional gcloud configuration directory.
-
CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDEOptional path to a credential file that overrides the active gcloud account.
Notes
-
Any credential/config env you set must be allowlisted in the runner's
execution.inherit_env; attached service accounts and workload identity need no credential env. - Grant least privilege for the actions you enable: ordinary Logging reads need roles/logging.viewer; private and Data Access logs additionally need roles/logging.privateLogViewer. Monitoring reads need roles/monitoring.viewer, and alert-policy enable or disable needs roles/monitoring.alertPolicyEditor-equivalent permissions. User or quota-project credentials may also need serviceusage.services.use on the named project for the X-Goog-User-Project quota header.
-
For a credential file, populate a dedicated
CLOUDSDK_CONFIGwithgcloud auth login --cred-file=...or setCLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE; ordinary gcloud commands do not authenticate from GOOGLE_APPLICATION_CREDENTIALS. - This remote-target pack declares no host detection signal and is never auto-suggested merely because gcloud is installed.
- Metric query pageSize with view=FULL caps returned points rather than the number of time-series objects; follow next_page_cursor for another page.
Verify it works
Runs gcp.alert_policies, a low-risk
read that confirms the pack can reach its target. Run it on the host once the pack
is installed; pack install runs it for
you.
sudo emisar pack verify gcp-monitoring
Install and configure a pack walks through the whole sequence on a host.
Actions 8 total
View on GitHub-
gcp.alert_policies exec low Low — read-only or trivially reversible
gcloud monitoring policies list
List alerting policies in one Google Cloud project.
View source on GitHub -
gcp.alert_policy_disable script high High — service-affecting
Disable a Cloud Monitoring alert policy
Disable one exact alerting policy so its conditions stop evaluating and notifying. Incidents the policy would catch go unnoticed until it is re-enabled with gcp.alert_policy_enable — that is the rollback. Idempotent: disabling an already-disabled policy succeeds and changes nothing. Returns the updated policy.
View source on GitHub -
gcp.alert_policy_enable script high High — service-affecting
Enable a Cloud Monitoring alert policy
Enable one exact alerting policy so its conditions evaluate and notify again. Idempotent: enabling an already-enabled policy succeeds and changes nothing. Returns the updated policy; roll back with gcp.alert_policy_disable.
View source on GitHub -
gcp.interconnect_utilization script low Low — read-only or trivially reversible
Query Cloud Interconnect attachment utilization
Query capacity plus received and sent byte rates for one Cloud Interconnect attachment, then calculate independent ingress and egress utilization ratios. The link is full duplex, so directions are never summed. The window reaches 730 days at a coarse alignment: window / alignment_seconds must fit the 1000-point page each metric is read in.
View source on GitHub -
gcp.log_entries script medium Medium — changes state, easily reversible
Query recent Cloud Logging entries
Query the newest five recent Cloud Logging entries in a Google Cloud project, optionally narrowed by minimum severity, resource type, and exact log ID. Returns fixed, clipped diagnostic fields; log content is arbitrary application output, so redaction is best-effort and the result should be treated as sensitive diagnostics.
View source on GitHub -
gcp.log_names script low Low — read-only or trivially reversible
List Cloud Logging log names
List one bounded page of log names that contain entries in a Google Cloud project. Use the returned continuation cursor to inspect the next page.
View source on GitHub -
gcp.metric_descriptors script low Low — read-only or trivially reversible
List Cloud Monitoring metric descriptors
List active metric descriptors in one project, optionally restricted to a metric-type prefix. Returns a next_page_cursor when another page exists.
View source on GitHub -
gcp.metric_query script low Low — read-only or trivially reversible
Query Cloud Monitoring time series
Query one metric type over a trailing window ending now, optionally narrowing by a Monitoring resource filter. Returns FULL time-series data and a next_page_cursor when another page exists. The window reaches 730 days, Google's retention for Compute Engine, GKE, Cloud Storage, BigQuery, Cloud SQL, load balancer, custom, agent and Prometheus metrics (full resolution for six weeks, 10-minute points after that); every other family, including log-based metrics, keeps six weeks. Beyond a day, set an aligner (ALIGN_RATE for counters, ALIGN_MEAN for gauges) and pick alignment_seconds so window / alignment fits in one page; ALIGN_NONE returns raw samples and pages through them. Google answers a response over 200 MB with HTTP 429: raise alignment_seconds or narrow resource_filter.
View source on GitHub