By the end of this tutorial, you will have reported a snapshot of your Cloud Run environment to Kosli, making its running services and jobs visible and trackable.Documentation Index
Fetch the complete documentation index at: https://docs.kosli.com/llms.txt
Use this file to discover all available pages before exploring further.
kosli snapshot cloud-run covers a specific set of GCP deploy methods. See the kosli snapshot cloud-run reference for the current list of what’s supported.
There are two ways to do this:
- Kosli CLI — quick to run, suitable for testing only
- — runs the reporter inside GCP on a schedule for continuous, production-grade reporting
Prerequisites
- Have access to a Google Cloud project and region with Cloud Run resources.
- Create a Cloud Run Kosli environment named
cloud-run-tutorial. - Get a Kosli API token.
Report using Kosli CLI
This approach is suitable for testing only. Install Kosli CLI if you have not done so, then authenticate to GCP with Application Default Credentials:--resolve-names makes Cloud Run services display their image tags (for example the commit SHA) instead of bare digests by reverse-resolving the deployed digest against Artifact Registry. The forward digest lookup for tag-pinned Jobs runs automatically whether you pass the flag or not.
See kosli snapshot cloud-run for the full flag reference.
Report using a scheduled Cloud Run Job
For production, run the reporter inside GCP as a Cloud Run Job triggered by Cloud Scheduler.Grant the reporter project-level access to Cloud Run
roles/run.viewer is the minimum needed to list services and jobs in the project.Store the Kosli API token in Secret Manager
Create a secret and add your token as the first version:Grant the reporter service account read access to that specific secret:
Grant Artifact Registry read access
Grant Repeat the command for every Artifact Registry repository that holds images deployed to Cloud Run in this project.
roles/artifactregistry.reader to the reporter on each Artifact Registry repository that holds your application images. This is what lets the reporter resolve digests and tags so artifact names are useful on Kosli.If you deploy any Cloud Functions 2nd-gen functions in this project, also grant the same role on the Google-managed
gcf-artifacts repository in the same region. 2nd-gen functions store their backing images there, and the reporter needs read access to resolve them.Deploy the reporter as a Cloud Run Job
Cloud Run Jobs are created with
deletionProtection=true by default. You will need to disable it (gcloud run jobs update kosli-reporter --no-deletion-protection --region=<your-gcp-region>) before you can delete or replace the Job later.Schedule the reporter with Cloud Scheduler
Create a Cloud Scheduler job that triggers the Cloud Run Job every five minutes, and grant its service account permission to invoke the Job:
What you’ve accomplished
You have reported a snapshot of your Cloud Run environment to Kosli. Kosli now tracks the running services and jobs in that environment and will record changes as they happen. From here you can:- Query your environment with
kosli list snapshotsandkosli get snapshot - Compare snapshots to see what changed
- Trace a running artifact back to its git commit with the From commit to production tutorial