Skip to main content

Configure Metrics

Metrics are collected from a set of web servers, so your metrics appear in our monitoring dashboards.

metrics:
  enable: true
  path: /metrics
  scrapeInterval: 60s

Options

Property Type Description Default
enable boolean Whether to collect metrics from your application. false
path string The path on your application that exposes metrics. /metrics
scrapeInterval string How often metrics are collected. An integer in seconds, or a string with units such as 30s or 5m. 60s
resources.cpu integer or string CPU allocated to the servers metrics are collected from. See Resources. http.resources
resources.memory integer or string Memory allocated to those servers. See Resources. http.resources
variables object Environment variables for those servers only. See Environment Variables. http.variables

Collecting metrics

Writing metrics at the top level runs a set of web servers that are collected from, separate from the servers handling your traffic. They run the same image as the rest of your application and are not reachable from the internet.

metrics:
  enable: true

If your application exposes metrics on a non-default path, or you want to adjust how often they are collected, write the block out:

metrics:
  enable: true
  path: /metricz
  scrapeInterval: 30s

Format

Your application's metrics endpoint must respond to a GET request with metrics in OpenMetrics format. This is the plain-text exposition format produced by Prometheus client libraries, so any library that describes itself as Prometheus-compatible already produces the right output.

Resources

The servers metrics are collected from take their resources from your http block when the metrics block states none, since they run the same image and usually need the same allocation:

metrics:
  enable: true
  resources:
    memory: 512Mi

See the YAML Schema Reference for computeResources syntax.

Collecting from an http group

Metrics can also be configured on a group of web servers, which is what you want when you need more than one thing collected from, or when the servers being collected from should be configured like any other group:

http:
  hostname: example.com

  groups:
    web:
      path: /

    metrics:
      hostname: ~
      metrics: true

metrics above is the group name; the metrics inside it is the option. hostname: ~ clears the hostname the group would otherwise inherit, so nothing routes to it from the internet.

Collecting from a group that serves traffic works, but that group serves your metrics endpoint on its own hostnames, so example.com/metrics becomes reachable by anyone. Validating your configuration reports a notice when a group you collect from has a hostname.

A group you collect from is an ordinary group of web servers, so it takes resources, replicas and variables like any other, and inherits them from the http block when it states none. See Configure HTTP for everything else a group accepts.

Writing a top-level metrics block and an http group named metrics configures the same thing twice. The group wins and the top-level block is ignored; validating your configuration reports this. Use one or the other.