Skip to main content

Google Cloud Backend

Uses Cloud Logging for log queries, Cloud Monitoring for metrics, and Cloud Trace for distributed tracing.

TINKR_BACKEND=gcp

Authentication

The backend uses Application Default Credentials (google-auth):

  1. Workload Identity (Cloud Run / GKE) — recommended for production
  2. Service account key file (GOOGLE_APPLICATION_CREDENTIALS) — avoid in production
  3. gcloud auth application-default login — local development

No credentials go in the Tinkr config. Attach Workload Identity to your Cloud Run service or GKE service account.


Required IAM roles

Assign to the service account:

RolePurpose
roles/logging.viewerRead Cloud Logging entries
roles/monitoring.viewerRead Cloud Monitoring metrics
roles/cloudtrace.userRead Cloud Trace data
gcloud projects add-iam-policy-binding PROJECT_ID \
--member="serviceAccount:tinker-sa@PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/logging.viewer"

gcloud projects add-iam-policy-binding PROJECT_ID \
--member="serviceAccount:tinker-sa@PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/monitoring.viewer"

gcloud projects add-iam-policy-binding PROJECT_ID \
--member="serviceAccount:tinker-sa@PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/cloudtrace.user"

Environment variables

VariableRequiredDescription
GCP_PROJECT_IDYesGCP project ID

Profile configuration

~/.tinkr/config.toml
[profiles.gcp-prod]
backend = "gcp"
project_id = "acme-prod-123456"

[profiles.gcp-prod.services.payments-api]
repo = "acme/payments"
resource_type = "cloudrun"

Log query

Tinkr uses the Cloud Logging API with a structured filter:

resource.type = "cloud_run_revision"
resource.labels.service_name = "payments-api"
severity >= ERROR
timestamp >= "2026-04-07T13:00:00Z"

Log fields are mapped to Tinkr's LogEntry schema using the jsonPayload or textPayload field.


Metrics

Tinkr calls the Cloud Monitoring timeSeries.list API. Common metric types:

ServiceMetric type
Cloud Runrun.googleapis.com/request_count
Cloud Runrun.googleapis.com/request_latencies
GKEkubernetes.io/container/cpu/request_utilization
Cloud SQLcloudsql.googleapis.com/database/queries

Distributed tracing (Cloud Trace)

Cloud Trace must be enabled in your application. Most Google Cloud services enable it automatically.

For custom applications, use the OpenTelemetry SDK with the Cloud Trace exporter:

from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
from opentelemetry.sdk.trace.export import BatchSpanProcessor

Tinkr calls cloudtrace.projects.traces.list to fetch recent traces.


Deployment

See Deploying on GCP for Cloud Run, GKE, Workload Identity, and Secret Manager setup.


Local development

gcloud auth application-default login

export TINKR_BACKEND=gcp
export GCP_PROJECT_ID=acme-dev-123456
uv run tinkr-server