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 Lightstep Observability. This integration also requires Varnish Prometheus exporter to expose the metrics.

To complete the integration, you will:

  • Configure Varnish to use the Prometheus exporter
  • Configure Varnish Prometheus exporter to expose metrics
  • Configure the Collector to use the Varnish endpoint as a scrape target for the Prometheus receiver
  • Enable the integration by adding it to a pipeline

Prerequisites

Configure Varnish reporting

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.

Configure the Collector receiver

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.

Enable the Collector receiver

After the Varnish receiver is configured, enable it by adding it to one or more pipelines as described in the Collector configuration documentation.

Validate metrics are reporting to Lightstep

You can validate that the metrics are reporting to Lightstep from the Metric details section of the Project Settings page.

  1. Open the Project settings page and scroll to the Metric details section.

  2. Search for Varnish metric names. Search for metric

    See the Varnish documentation for a complete list of emitted metrics.

  3. If needed, select the metric to edit the description and how the units are displayed in Lightstep.

Create a dashboard for the metrics

Use the Lightstep Terraform Provider to create a dashboard for the metrics.

Additional resources

  • For a complete example that’s ready to run, see the Varnish integration in Lightstep OpenTelemetry Examples.