Skip to main content

VM Monitoring

Find VM by Name

Search for a VM instance by name across all projects and zones.

Path Parameters

vm_name
string
required
Name of the VM to search for

Example Request

curl -X GET https://api.example.com/api/gcp/vm/by-name/my-vm-instance/details \
  -H "Cookie: session=your-session-token"

Response

projectId
string
Project ID containing the VM
zone
string
Zone where the VM is located
vmName
string
VM instance name
instanceId
string
Unique instance ID
status
string
Current VM status
machineType
string
VM machine type
resourceId
string
Full resource identifier
{
  "projectId": "my-project-123",
  "zone": "us-central1-a",
  "vmName": "my-vm-instance",
  "instanceId": "1234567890123456789",
  "status": "RUNNING",
  "machineType": "e2-medium",
  "resourceId": "projects/my-project-123/zones/us-central1-a/instances/my-vm-instance"
}

Get Available Metrics

Retrieve all available monitoring metrics for a VM instance.

Path Parameters

project_id
string
required
GCP project ID
instance_id
string
required
VM instance ID

Response

metrics
array
Array of available metrics

Example Response

{
  "metrics": [
    {
      "type": "compute.googleapis.com/instance/cpu/utilization",
      "displayName": "Użycie CPU",
      "unit": "%"
    },
    {
      "type": "compute.googleapis.com/instance/network/received_bytes_count",
      "displayName": "Sieć (Odebrane)",
      "unit": "bajty"
    },
    {
      "type": "agent.googleapis.com/memory/percent_used",
      "displayName": "Użycie pamięci (Agent)",
      "unit": "%"
    }
  ]
}

Get Metric Time Series

Retrieve time-series data for a specific metric.

Path Parameters

project_id
string
required
GCP project ID
instance_id
string
required
VM instance ID

Request Body

metricType
string
required
Metric type to query (e.g., “compute.googleapis.com/instance/cpu/utilization”)
timespanMinutes
number
default:60
Time range in minutes to query (default: 60)

Example Request

curl -X POST https://api.example.com/api/gcp/vm/my-project-123/1234567890123456789/metrics \
  -H "Content-Type: application/json" \
  -H "Cookie: session=your-session-token" \
  -d '{
    "metricType": "compute.googleapis.com/instance/cpu/utilization",
    "timespanMinutes": 60
  }'

Response

data
array
Array of data points
{
  "data": [
    {
      "timestamp": "2024-02-20T14:30:00Z",
      "average": 0.2541
    },
    {
      "timestamp": "2024-02-20T14:35:00Z",
      "average": 0.3102
    }
  ]
}

Check Ops Agent Status

Check if the Ops Agent is installed and running on a VM.

Path Parameters

project_id
string
required
GCP project ID
instance_id
string
required
VM instance ID

Response

hasOpsAgent
boolean
Whether the Ops Agent is active
message
string
Status message
{
  "hasOpsAgent": true,
  "message": "Ops Agent jest aktywny."
}

Install Ops Agent

Install the Ops Agent on a VM instance.

Path Parameters

project_id
string
required
GCP project ID
instance_id
string
required
VM instance ID

Response

{
  "message": "Zainicjowano instalację Ops Agent (LINUX) na VM 'my-vm-instance'.",
  "operation_name": "projects/my-project-123/locations/us-central1-a/guestPolicyAssignments/..."
}

Query VM Logs

Query logs for a specific VM using LQL (Logging Query Language).

Path Parameters

project_id
string
required
GCP project ID
instance_id
string
required
VM instance ID

Request Body

lqlQuery
string
required
LQL query string (must include resource.labels.instance_id="{instance_id}")

Example Request

curl -X POST https://api.example.com/api/gcp/vm/my-project-123/1234567890123456789/logs/query \
  -H "Content-Type: application/json" \
  -H "Cookie: session=your-session-token" \
  -d '{
    "lqlQuery": "resource.type=gce_instance AND resource.labels.instance_id=\"1234567890123456789\" AND severity>=ERROR"
  }'

Response

columns
array
Array of column names
rows
array
Array of row data (each row is an array matching columns)
{
  "columns": ["timestamp", "severity", "logName", "message"],
  "rows": [
    ["2024-02-20T14:30:00Z", "ERROR", "syslog", "Connection timeout"]
  ]
}

VM Alerts

List VM Alerts

List all alert policies configured for a specific VM.

Path Parameters

project_id
string
required
GCP project ID
instance_id
string
required
VM instance ID

Response

value
array
Array of alert policies
{
  "value": [
    {
      "name": "1234567890123456789",
      "displayName": "High CPU Alert",
      "enabled": true,
      "description": "Alert when CPU usage exceeds 80%"
    }
  ]
}

Create VM Alert

Create a new alert policy for a VM.

Path Parameters

project_id
string
required
GCP project ID
instance_id
string
required
VM instance ID

Request Body

alertName
string
required
Display name for the alert
metricType
string
required
Metric type to monitor
threshold
number
required
Threshold value to trigger the alert

Example Request

curl -X POST https://api.example.com/api/gcp/vm/my-project-123/1234567890123456789/create-alert \
  -H "Content-Type: application/json" \
  -H "Cookie: session=your-session-token" \
  -d '{
    "alertName": "High CPU Alert",
    "metricType": "compute.googleapis.com/instance/cpu/utilization",
    "threshold": 0.8
  }'

Response

{
  "message": "Utworzono alert 'High CPU Alert'. (Uwaga: nie skonfigurowano kanałów notyfikacji).",
  "name": "1234567890123456789",
  "displayName": "High CPU Alert"
}

Delete VM Alert

Delete an alert policy for a VM.

Path Parameters

project_id
string
required
GCP project ID
alert_name
string
required
Alert policy ID to delete

Example Request

curl -X DELETE https://api.example.com/api/gcp/vm/my-project-123/alerts/1234567890123456789 \
  -H "Cookie: session=your-session-token"

Response

{
  "message": "Alert '1234567890123456789' został pomyślnie usunięty."
}

Container Monitoring

Find Container by Name

Search for a Cloud Run service by name across all projects.

Path Parameters

container_name
string
required
Name of the Cloud Run service

Response

{
  "projectId": "my-project-123",
  "region": "europe-west1",
  "serviceName": "my-service",
  "resourceName": "https://europe-west1-run.googleapis.com/...",
  "url": "https://my-service-abc123-ew.a.run.app"
}

Get Container Available Metrics

Retrieve available metrics for a Cloud Run service.

Path Parameters

project_id
string
required
GCP project ID
region
string
required
Service region
container_name
string
required
Cloud Run service name

Response

{
  "metrics": [
    {
      "type": "run.googleapis.com/request_count",
      "displayName": "Liczba żądań",
      "unit": "count"
    },
    {
      "type": "run.googleapis.com/request_latencies",
      "displayName": "Opóźnienia żądań",
      "unit": "ms"
    },
    {
      "type": "run.googleapis.com/container/instance_count",
      "displayName": "Liczba instancji",
      "unit": "count"
    }
  ]
}

Get Container Metric Data

Retrieve time-series data for a Cloud Run metric.

Path Parameters

project_id
string
required
GCP project ID
region
string
required
Service region
container_name
string
required
Cloud Run service name

Request Body

metricType
string
required
Metric type to query
timespanMinutes
number
default:60
Time range in minutes

Response

{
  "data": [
    {
      "timestamp": "2024-02-20T14:30:00Z",
      "average": 42.5
    }
  ]
}

Query Container Logs

Query logs for a Cloud Run service.

Path Parameters

project_id
string
required
GCP project ID
container_name
string
required
Cloud Run service name

Request Body

lqlQuery
string
required
LQL query (must include resource.labels.service_name="{container_name}")

Response

{
  "columns": ["timestamp", "severity", "payload"],
  "rows": [
    ["2024-02-20T14:30:00Z", "INFO", "Request processed successfully"]
  ]
}

Container Alerts

List Container Alerts

List alert policies for a Cloud Run service.

Path Parameters

project_id
string
required
GCP project ID
container_name
string
required
Cloud Run service name

Create Container Alert

Create an alert policy for a Cloud Run service.

Path Parameters

project_id
string
required
GCP project ID
region
string
required
Service region
container_name
string
required
Cloud Run service name

Request Body

alertName
string
required
Alert display name
metricType
string
required
Metric type to monitor
threshold
number
required
Threshold value

Delete Container Alert

Delete an alert policy for a Cloud Run service.

Path Parameters

project_id
string
required
GCP project ID
alert_name
string
required
Alert policy ID

Build docs developers (and LLMs) love