Introducing’s New Metrics Integration for HashiCorp Consul with OpenTelemetry

HashiCorp Consul began as an open-source project for service discovery. It has evolved to provide  other valuable functionality like secure service mesh to help secure microservice architectures based on service identity, but also the ability to achieve repeatable application deployment lifecycles via Network Infrastructure Automation and control access to the service mesh via Consul API Gateway. These features are considered the four core pillars of Consul service networking. 

We use Consul today here at, as do hundreds of our customers. Increasingly, we see our customers adopting HashiCorp Cloud Platform (HCP) Consul to automate service networking across their multi-cloud environments. 

At, we focus on helping customers achieve visibility in their complex distributed environments by consolidating logging, tracing, and metrics using open-source technologies. With our newest integration with HCP Consul, we are excited to announce we are now a Premier Partner. 

Our new integration leveraging Prometheus and OpenTelemetry collects data from Consul. Consul exposes Prometheus metrics when configured to do so. All you need to do is configure it to expose the Prometheus metrics on an endpoint to be scraped:

How to Expose Prometheus Metrics with Consul

  1. Navigate to the Consul server and create a new file called prometheus.json under the Consul config library at /etc/consul.d.
  2. Add the following telemetry stanza to the prometheus.json:
 "telemetry": {
   "disable_hostname": true,
   "prometheus_retention_time": "72h"  

Once this is configured, you can verify that the endpoint is exposing Prometheus metrics by connecting to this URL:

If you do not have the OpenTelemetry collector on your host, then create a directory on your host and download the OpenTelemetry collector that is relevant to the operating system of your host.

After downloading the collector, create a configuration file config.yaml

       - job_name: 'consul-metrics'
         scrape_interval: 15s
         metrics_path: "/v1/agent/metrics"
           - targets: ['localhost:8500']
   collection_interval: 1m
     cpu: ##All execpt Mac
     disk: ##All execpt Mac
     process: ##Linux & Windows
   detectors: ["system"]
     hostname_sources: ["os"]
   endpoint: https://<<LISTENER-HOST>>:8053
     Authorization: Bearer <<PROMETHEUS-METRICS-SHIPPING-TOKEN>>
     receivers: [prometheus,hostmetrics]
     processors: [resourcedetection/system]
       - prometheusremotewrite
     level: "debug"

In the exporter section, you must replace the placeholders to match your account specifics. (They are indicated by the double angle brackets << >>):

  • Replace <<PROMETHEUS-METRICS-SHIPPING-TOKEN>> with a token for the Metrics account you want to ship to.
    Here’s how to look up your Metrics token.
  • Replace <<LISTENER-HOST>> with the Listener URL for your region, configured to use port 8052 for http traffic, or port 8053 for https traffic. For example, if your account is hosted on AWS US East, or if hosted on Azure West Europe.

Finally you can run the collector:
<path/to>/otelcol-contrib --config ./config.yaml

Replace <path/to> with the path to the directory where you downloaded the collector. 

Login to your account and look on the bottom of the page to send the metrics to auto install the dashboard. Your data should look something like this. You are welcome to customize the dashboard from this point. 

Expect more great content as we continue to support more HashiCorp’s products, our Terraform operator has been very popular with customers to automate the platform. 

You can find our partner page on the HashiCorp site, | HashiCorp Tech Partner. Also don’t forget to star and download the Github page for Consul

Get started for free

Completely free for 14 days, no strings attached.