Step 2: Deploy Vector
Vector runs as a DaemonSet, tails every pod’s logs on its node, filters down to your CNPG instance pods, and reshapes CNPG’s JSON log envelope into the OTLP log record format using a VRL transform maintained in the pganalyze collector repository.
This page covers the quickest path to get it running. For a full breakdown of what each part of the Vector configuration does (the Kubernetes log source, the CNPG pod filter, the JSON remap, and the OTLP sink), see the Vector configuration reference.
Fetch the example values.yaml
Saved as vector-values.yaml rather than the generic values.yaml, so it doesn’t collide with
collector-values.yaml from Initial Setup if you keep both in the same directory:
wget -O vector-values.yaml https://github.com/pganalyze/collector/raw/refs/heads/main/contrib/vector/values.yamlThis file already implements the full pipeline: a kubernetes_logs source, a cnpg_route filter
(matching pods with the cnpg.io/podRole: instance label), the cnpg_remap JSON transform, and an
opentelemetry sink.
Customize it for your cluster
Three things need to change before this will work for you:
-
The cluster filter. In the
cnpg_routetransform, update the list to yourClusterresource’s name, e.g.my-cluster, not a per-instance pod name likemy-cluster-1:route: cnpg: | exists(.kubernetes.pod_labels."cnpg.io/cluster") && exists(.kubernetes.pod_labels."cnpg.io/podRole") && .kubernetes.pod_labels."cnpg.io/podRole" == "instance" && includes( [ "my-cluster", ], .kubernetes.pod_labels."cnpg.io/cluster" ) -
The sink URI. Point it at the
pganalyze-collector-otel-serviceService you created in Step 1, using its namespace-qualified form. Vector runs in its ownvectornamespace (per thehelm installcommand below), while the collector’s Service is wherever you deployed the collector, and a bare Service name only resolves via Kubernetes DNS within the same namespace as the caller. Replace<collector-namespace>with the actual namespace (defaultif you didn’t set one):sinks: pganalyze: type: opentelemetry protocol: type: http uri: "http://pganalyze-collector-otel-service.<collector-namespace>.svc.cluster.local:4318/v1/logs" # ... -
The sink’s
batch.max_events, which must be1. The downloaded file sets it higher, but Vector’sopentelemetrysink does not currently support batching more than one event per request with thejsoncodec, anything higher silently drops logs. See the Vector configuration reference for details:sinks: pganalyze: protocol: batch: max_events: 1 # ...
Deploy
Deploy Vector with its Helm chart, into its own vector namespace:
helm repo add vector https://helm.vector.dev
helm repo update
helm install vector vector/vector \
--namespace vector \
--create-namespace \
--values vector-values.yamlCheck that the Vector pods came up on every node:
kubectl get pods -n vector
NAME READY STATUS RESTARTS AGE
vector-0 1/1 Running 0 1mProceed to Step 3: Test and Verify
Couldn't find what you were looking for or want to talk about something specific?
Start a conversation with us →