What you’ll learn
- How to give both collectors the Sherlock endpoint and token
- How to select the containers whose logs you send
- How JSON log lines become a message, a severity, and a trace link
- Where the data appears in Sherlock, and how to change the configuration later
Prerequisites
- A Kubernetes cluster whose container runtime writes logs under
/var/log/pods, as containerd and CRI-O do. kubectlwith access to the cluster, and Helm 3.- The Endpoint and the Bearer Token from Settings → Collector. Click Reveal to see the token.
- The
envvalue for this cluster,prodordev. See Environments.
open-telemetry/opentelemetry-collector 0.176.1. The chart installs the image otel/opentelemetry-collector-contrib 0.162.0.
How it works
The cluster collector runs as exactly one replica, because every replica reports the same objects. Nothing sends data to the collectors, so they open no ports.
Steps
1
Store the token in a Secret
Create a namespace for the collectors and a Secret with your token. Both collectors read the token from this Secret.The collectors read the token into the environment variable
SHERLOCK_TOKEN. The token does not appear in the values files.2
Write the node collector values file
Save this file as Each
sherlock-collector-values.yaml. Then change three values:- Replace
CHANGE_ME_ENDPOINTwith the Endpoint from Settings → Collector. - Replace
CHANGE_ME_NAMESPACEwith the namespace of your application. Add oneincludeline for each namespace. - If the cluster is not production, change
prodtodev.
sherlock-collector-values.yaml
include entry is a glob:The
exclude entry stops the collector from reading its own logs. Keep it.3
Write the cluster collector values file
Save this file as
sherlock-cluster-collector-values.yaml. Make the same changes to CHANGE_ME_ENDPOINT and prod as in the previous step.sherlock-cluster-collector-values.yaml
4
Install the charts
Verify
-
Check that the collectors run and start without errors:
-
Open Logs in Sherlock and select the source for your
envvalue. New lines appear within about a minute. The collector sends only lines that your containers write after it starts. -
Open Metrics in the same source. Select
k8s.pod.memory.working_setfor usage, ork8s.pod.phasefor cluster state.
What it collects
The
transform/json processor changes log lines that start with {:
Plain-text lines keep their body and get no severity.
Change the configuration
- Edit the values file.
- Run the
helm upgrade --installcommand for that collector again.
Severity for a plain-text log format
To set the severity of plain-text lines from one container, add a statement group totransform/json after the resource group. This example reads the level of PostgreSQL lines from a container named postgres. Change the name to match your container.
Troubleshooting
The collector logs 401 or connection errors
The collector logs 401 or connection errors
Compare the endpoint in the values files and the token in the Secret with Settings → Collector. The endpoint is the full URL shown there. After you change the Secret, restart the collectors with
kubectl rollout restart.No log lines arrive
No log lines arrive
Check that an
include pattern matches. The directory is <namespace>_<pod>_<pod-uid>. The container name is the name in the pod spec, not the image name. To list the container names of a pod, run:Log lines arrive but no metrics
Log lines arrive but no metrics
Check the collector log for export errors first. If the log is clean, metrics are not enabled for your organization. Ask us to enable them. No change in the cluster is necessary.
Data lands in the wrong environment
Data lands in the wrong environment
Check the
env value in both values files. Matching is exact and case-sensitive. See Environments.Related topics
OpenTelemetry SDKs and collectors
Endpoint, header, and the env attribute for any collector.
Environments
How the env value routes the data of the cluster into a source.
Logs
Search syntax, facets, and the trace link.
Metrics
Chart a metric, group by an attribute, and the SQL tab.

