Google Artifact Registry Integration
Collect Docker and OCI images pushed to Google Artifact Registry (via audit logs and a Pub/Sub push subscription), transform them to CDEvents.
- Track images pushed from outside Google Cloud (local Docker, GitHub Actions, ...), when Cloud Build is not involved.
- cdviz-collector transforms each push to an
artifact.publishedCDEvent, identified by the image digest. - Without a Pub/Sub push endpoint, poll the Artifact Registry REST API instead.
| From event | CDEvents |
|---|---|
| UploadDockerImage / CreateDockerImage / CreateTag | artifact.published |
Only Docker and OCI images are supported. Other Artifact Registry formats (npm, Maven, generic) are ignored.
How It Works
Artifact Registry has no event topic of its own. A logging sink routes its admin activity audit logs to a Pub/Sub topic. A push subscription on that topic sends them to the cdviz-collector webhook source.
The transformer emits artifact.published for the UploadDockerImage, CreateDockerImage and CreateTag methods, and ignores the others (reads, deletes, repository management). subject.id is an OCI PURL built from the resourceName of the entry (projects/P/locations/L/repositories/R/dockerImages/NAME@sha256:DIGEST). The digest is the immutable identifier, so the same PURL links the image to its Cloud Run deployments.
Configuration
Setting Up cdviz-collector
[sources.gcp_artifactregistry_webhook]
enabled = true
transformer_refs = ["gcp_artifactregistry_webhook"]
[sources.gcp_artifactregistry_webhook.extractor]
type = "webhook"
id = "000-gcp-artifactregistry" # used as part of the webhook's url
[remote.transformers-community]
type = "github://cdviz-dev/transformers-community"
[transformers]
gcp_artifactregistry_webhook = { type = "vrl", template_rfile = "transformers-community:///gcp_artifactregistry_webhook/to_v0_5.vrl" }For more details on remote transformers, see the Transformers documentation.
Setting Up Google Cloud
- Create a Cloud Logging sink on the Artifact Registry audit logs, with a Pub/Sub topic as destination. Filter:
protoPayload.serviceName="artifactregistry.googleapis.com" AND protoPayload.methodName:("UploadDockerImage" OR "CreateDockerImage" OR "CreateTag") - Create a push subscription on that topic, with the endpoint
https://your-collector-url/webhook/000-gcp-artifactregistry.
Poll the Artifact Registry REST API
Use polling to backfill past images, or when Pub/Sub cannot reach the collector. The gcp_artifactregistry_rest_api transformer reads the responses of packages.versions.list. Every version is an artifact.published, with the same digest-based PURL as the audit logs. Polling a known version again produces an identical event, which the database deduplicates.
The driver lists the packages of a repository, then fetches the versions of each package:
[sources.gcp_artifactregistry_rest_versions]
enabled = true
transformer_refs = ["gcp_artifactregistry_rest_versions"]
[sources.gcp_artifactregistry_rest_versions.extractor]
type = "http_polling"
polling_interval = "5m"
parser = "json"
driver_vrl = """
project = "myproject"
location = "us-central1"
repository = "myrepo"
base = "https://artifactregistry.googleapis.com/v1/projects/" + project + "/locations/" + location + "/repositories/" + repository
reqs = []
if .response == null {
reqs = [{ "url": base + "/packages", "route": "feedback" }]
} else {
url = string(.request.url) ?? ""
is_versions = contains(url, "/versions")
next_token = to_string(.response.body.nextPageToken) ?? ""
if next_token != "" {
reqs = push(reqs, { "url": url, "query": {"pageToken": next_token}, "route": (if is_versions { "both" } else { "feedback" }) })
}
if !is_versions {
for_each(array!(.response.body.packages) ?? []) -> |_i, pkg| {
reqs = push(reqs, { "url": string!(pkg.name) + "/versions", "route": "both" })
}
}
}
.requests = reqs
"""
[sources.gcp_artifactregistry_rest_versions.extractor.headers]
authorization = { type = "secret", value_file = "/secrets/gcp_token", prefix = "Bearer " }
[transformers]
gcp_artifactregistry_rest_versions = { type = "vrl", template_rfile = "transformers-community:///gcp_artifactregistry_rest_api/versions_to_v0_5.vrl" }Set project, location and repository. The polling identity needs artifactregistry.repositories.downloadArtifacts and artifactregistry.versions.list on the repository (role roles/artifactregistry.reader or broader).
Access token refresh
The http_polling source has no built-in Google OAuth2 or service account token refresh. Keep /secrets/gcp_token filled with a valid access token from an external process, for example a cron job or a sidecar that runs gcloud auth print-access-token > /secrets/gcp_token.