This guide explains how to collect metrics from your HCP-managed Consul deployment using the OpenTelemetry Collector. The collector gathers, processes, and sends telemetry data (including metrics, logs, and traces) to various observability backends, including New Relic.
The setup example below leverages the Prometheus receiver within the collector. It retrieves service metrics directly from HCP Consul's service metrics API and exports them to New Relic's OpenTelemetry endpoint.
HCP Consul offers two types of observability metrics:
- Server metrics: These track Consul server performance and resource usage.
- Envoy proxy metrics: These monitor the Envoy service mesh within Consul.
Follow the steps below to collect and export HCP Consul metrics to New Relic.
Review the requirements
Before you start, you'll need the following:
- A running Docker daemon service
- An installed Docker Compose tool
- Your HCP Consul ACL admin token
- Your New Relic for the account you want to report data to
Download or clone the example configuration
- Download the example Configuration.
- Once downloaded, locate the directory named
hcp-consul
within theother-examples/collector
folder of the repository. This directory contains the specific configuration for collecting HCP Consul metrics. - (Optional) Refer to the README for additional details and instructions related to the HCP Consul example.
Set environment variables and run the collector
In the .env
file:
- Set the HCP Access Token and Access URL values
- Set the New Relic API key variable to your New Relic license key
$# Open the HCP Consul example directory$ cd newrelic-opentelemetry-examples/other-examples/collector/hcp-consul$
$ # Set environment variables.$
$ # run the collector in docker$ docker compose up
Environment variable information
If you need more information on the environment variables set above, see the documentation in the following table.
Variable | Description | Docs |
---|---|---|
| New Relic Ingest API Key | |
| The default US New Relic OTLP endpoint is | |
| ACL Admin token for HCP Consul | |
| URL to access your specific Consul server |
Forward HCP Consul Envoy metrics to New Relic
To monitor HCP Consul Envoy metrics in New Relic, you can configure the OpenTelemetry collector built into your HCP Consul cluster to forward metrics to your own collector. This can include the collector running in this example.
Add an HTTP receiver to the OpenTelemetry collector. You can add this into the
receivers
group in the examplecollector.yaml
file:receivers:otlp:protocols:http:This will add a receiver listening at
0.0.0.0:4318
.Configure your HCP Consul cluster to forward Envoy metrics to this receiver. This can be configured from the
telemetryCollector
stanza in your HCP Consul configuration file. For example:telemetryCollector:enabled: truecustomExporterConfig: |-{"exporter_config": {"otlphttp": {"endpoint": "0.0.0.0:4318","headers": {"authorization": "<auth>"},"timeout": "2s"}}}
View your data in New Relic
In New Relic, you can view your HCP Consul data in a few different places:
Navigate to the New Relic marketplace and search for "consul". Click one of the dashboards to quickly install it for your account.
Navigate to the metrics explorer and filter for
consul
, orenvoy
for Envoy metrics. This data can be added to any custom alert or dashboard.Tip
To view all metrics available with this HCP Consul server integration, reference the documentation here.