Metrics from HashiCorp-managed clusters
This page describes how to scrape Consul server metrics from HashiCorp-managed clusters.
HashiCorp ensures the availability of HashiCorp-managed clusters and provides observability features through HCP Consul Central. You can set up a custom metrics collector to track cluster usage.
For opinionated, preconfigured graphs of Consul server and Envoy proxy metrics, refer to the HCP Consul observability overview.
Prerequisites
To access server metrics, you need a telemetry agent capable of both resolving a DNS record to IP addresses and scraping Prometheus-format metrics. This page provides example configurations for Prometheus and OpenTelemetry Collector using Docker.
Accessing server metrics requires the cluster's address and an ACL token with a minimum of agent:read
permission. To get the cluster's address and create an ACL token using HCP Consul, refer to Access HashiCorp-managed clusters.
Scrape server metrics
Configure your telemetry collector to scrape metrics from the cluster's /v1/agent/metrics
endpoint and then start the collector. The following examples demonstrate configurations for Prometheus and OpenTelemetry Collector.
Prometheus
To use a Prometheus metrics collector, configure it to do the following:
- Resolve the cluster's DNS address to IP addresses.
- Scrape metrics from each server's
/v1/agent/metrics
endpoint. - Call the agent endpoint with a Bearer token authorized to read metrics.
In the following example configuration, these fields are specified so that the collector scrapes agent metrics every 60 minutes by running a job named hcp-consul-cluster
.
To start the metrics collector, run the following command:
OpenTelemetry Collector
You can use the Prometheus Receiver in the OpenTelemetry Collector to scrape metrics from a HashiCorp-managed cluster.
The following example configures a metrics pipeline with a Processor and Exporter. The OTLP Exporter requires an OTLP gRPC endpoint. Observability platforms such as New Relic and Honeycomb have public endpoints for metrics ingestion. Others platforms such as Datadog have their own Exporter.
To start the Collector in a Docker container, run the following command: