The OpenTelemetry Collector, when configured with a Prometheus receiver, provides an integration with Varnish to scrape Prometheus metrics. The Collector uses the Prometheus Receiver to fetch metrics from the configured path in the Varnish configuration file. From there, the metrics are processed and exported to Cloud Observability. This integration also requires Varnish Prometheus exporter to expose the metrics.
To complete the integration, you will:
The details of your configuration will vary with the infrastructure that you run. See the example for an integration using a Docker compose file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
services:
otel-collector:
container_name: otel-collector
image: otel/opentelemetry-collector-contrib:0.59.0
environment:
LS_ACCESS_TOKEN: ${LS_ACCESS_TOKEN}
configs:
- source: collector_conf
target: /conf/collector.yml
command: ["--config=/conf/collector.yml"]
varnish:
container_name: varnish
build: ./
configs:
- source: varnish_conf
target: /etc/varnish/default.vcl
volumes:
- ./docker-varnish-entrypoint:/usr/local/bin/docker-varnish-entrypoint
ports:
- "9131:9131"
configs:
collector_conf:
file: ./collector.yml
varnish_conf:
file: ./varnish.vcl
Collecting metrics as shown in this example requires Varnish Prometheus exporter that exposes Varnish metrics.
Set up Varnish Prometheus exporter for all Varnish instances to provide metrics to collector.
In the Collector configuration file, configure the Prometheus receiver to use the Varnish Prometheus endpoint as a scrape target.
Targets are configured in this example to scrape the metrics endpoint exposed by the Varnish Prometheus exporter.
1
2
3
4
5
6
7
receivers:
prometheus:
config:
scrape_configs:
- job_name: otel-varnish
static_configs:
- targets: [varnish:9131]
The OpenTelemetry repository readme provides additional details about Prometheus receiver configuration.
More details about the Prometheus scrape configuration can be found in Prometheus documentation.
After the Varnish receiver is configured, enable it by adding it to one or more pipelines as described in the Collector configuration documentation.
You can validate that metrics are reporting to Cloud Observability on the Metrics details page in Settings.
In Cloud Observability, click Settings > Metric details.
Search for Varnish metric names.
See the Varnish documentation for a complete list of emitted metrics.
If needed, select the metric to edit the description and how the units are displayed in Cloud Observability.
Use the Cloud Observability Terraform Provider to create a dashboard for the metrics.
Updated Dec 1, 2022