Documentation structure for LLMs (llms.txt)

Send machine runner 3 metrics to OpenTelemetry

Cloud Server

Machine runner 3 can send metrics about task claims, task startup, and running tasks to an OpenTelemetry collector that you run. Use these metrics to watch the capacity and health of your self-hosted runners in your own monitoring tool, such as Datadog or Prometheus.

This feature is available in machine runner 3.1.15 and later. The runner sends metrics only. It does not send traces. The container runner does not send metrics.

Prerequisites

  • Machine runner 3.1.15 or later.

  • An OpenTelemetry collector that accepts OTLP over grpc or http. The runner host must be able to reach the collector.

Turn on metrics

The runner sends no metrics by default. To turn them on, set the metrics destination to otel and set the host of your collector in the machine runner configuration file.

  1. Open the machine runner configuration file. On Linux, the default location is /etc/circleci-runner/circleci-runner-config.yaml.

  2. Add the observability section. Replace <collector-host>, including the angle brackets, with the host name or IP address of your collector.

    api:
      auth_token: << AUTH TOKEN >>
    runner:
      name: runner-name-001
      working_directory: "/var/lib/circleci-runner/workdir"
      cleanup_working_directory: true
    logging:
      level: "info"
      format: "text"
      file: "-"
    observability:
      # Send metrics to an OpenTelemetry collector. The default is none.
      metrics_destination: otel
      otel:
        # The host name or IP address of your collector. This setting is required.
        host: <collector-host>
        # The default is 4317, the usual port for grpc. Use 4318 for http.
        port: 4317
        # The OTLP protocol, grpc or http.
        protocol: grpc
        # Set to true to connect to the collector with TLS.
        secure: false
        # Use cumulative for a collector with a Prometheus exporter.
        temporality: delta

    Only metrics_destination and host are required. The example shows the default value of every other setting.

  3. Restart the runner. On Linux, run the following command:

    $ sudo systemctl restart circleci-runner
  4. Look for the circleci.runner.task.running metric in your monitoring tool. The runner records it every five seconds, so it is in every export, also while the runner is idle.

You can also set each value with an environment variable, such as CIRCLECI_RUNNER_OBSERVABILITY_METRICS_DESTINATION. Environment variables take priority over the YAML file. Refer to the Machine Runner 3 Configuration Reference for every setting and its environment variable.

The runner does not start if observability.metrics_destination is otel and observability.otel.host is empty.

Choose delta or cumulative temporality

Temporality sets how the runner reports a metric between exports. The setting observability.otel.temporality takes one of two values:

  • delta: The default. Each export reports the change since the last export.

  • cumulative: Each export reports the total since the runner started.

Pick the value that your backend needs:

  • Use delta for a Datadog Agent. With cumulative, a Datadog Agent drops the first data point of every series. The first claim, task startup, and task agent download of each runner process are then missing.

  • Use cumulative for a collector with a Prometheus exporter.

Metrics the runner sends

The runner sends the following metrics. Every metric name starts with circleci.runner..

Metric Type Unit Description

circleci.runner.claim

Histogram

Milliseconds

The duration of each poll that the runner makes to claim a task. Most polls find no task.

circleci.runner.task.startup

Histogram

Milliseconds

The time the runner takes to prepare the task agent for a claimed task.

circleci.runner.task.running

Gauge

Tasks

The number of tasks the runner works on, from the claim to the cleanup.

circleci.runner.download.duration

Histogram

Milliseconds

The time the runner takes to download the task agent. The runner records it only when it downloads the task agent.

The runner sends no metric about the task itself, such as its duration or result.

The runner also sends internal metrics with names that start with backplane.. These metrics can change or go away in any release without notice. Do not use them in dashboards or alerts.

To drop the internal metrics, add a filter processor to your collector:

processors:
  filter/backplane:
    error_mode: ignore
    metrics:
      metric:
        - 'IsMatch(name, "^backplane\\.")'

Then add filter/backplane to the processors list of your metrics pipeline.

Tags

The data points have the tags in the following table. A tag that does not apply to a data point is empty. The circleci.runner.download.duration metric has no tags.

Tag Metrics Description

com.circleci.runner.name

circleci.runner.claim, circleci.runner.task.startup, circleci.runner.task.running

The name of the runner, from runner.name in the configuration file.

com.circleci.runner.resource_class

circleci.runner.claim, circleci.runner.task.startup

The resource class of the task.

com.circleci.runner.no_work

circleci.runner.claim

true if the poll found no task to claim.

com.circleci.runner.at_capacity

circleci.runner.claim

true if the runner did not claim a task because it is at its task limit.

result

circleci.runner.claim

The result of the poll: success, warning, or error. A poll that finds no task is a success. A shared library adds this tag, so it does not have the com.circleci.runner. prefix.

error.type

circleci.runner.claim

A short name for the type of error, when result is warning or error. It can be empty.

The OpenTelemetry resource of the runner has the attribute service.name set to circleci-runner, and the attribute service.version set to the version of the runner.

Metrics when the runner stops

The runner sends its last metrics when it stops. If it cannot send them, for example because the collector is down, it logs a warning and exits without an error.

Next steps