IBM Support

Datadog Consul and Envoy Metrics Monitoring | VM Edition

Troubleshooting


Problem

The information contained in this article has been verified as up-to-date on the date of the original publication of the article.  HashiCorp endeavors to keep this information up-to-date and correct, but it makes no representations or warranties of any kind, express or implied, about the ongoing completeness, accuracy, reliability, or suitability of the information provided.

All information contained in this article is for general information purposes only.  Any reliance you place on such information as it applies to your use of your HashiCorp product is therefore strictly at your own risk.

Introduction

This article is intended to be used as a guide outlining the major configuration changes necessary to configure Consul and Envoy to be monitored using Datadog agent.

Table of Contents

Prerequisites

  • Datadog Account and Login Info
  • Linux OS Administrative User Access
  • Running Consul Cluster using VMs
  • Consul Connect Enabled
  • Envoy Running as Sidecar Proxy for Connect Environment
  • Shell Access to VMs hosting Consul

Datadog Configuration Files

FileDefault PathDescription
datadog.yaml/etc/datadog-agent/datadog.yamlHolds Datadog's central configuration options for root agent configuration parameters.
consul.d/conf.yaml/etc/datadog-agent/conf.d/consul.d/conf.yamlHouses Consul specific Datadog configurations to capture /v1/agent/metrics data and Logs.
envoy.d/conf.yaml/etc/datadog-agent/conf.d/envoy.d/conf.yamlHouses Envoy specific Datadog configurations to capture /stats and /stats/prometheus metrics data and Envoy logs.

Enable Consul Telemetry

Configure each Consul agent to expose and capture local agent metrics with Prometheus and DogstatsD:

telemetry = {
prometheus_retention_time = "1h"
dogstatsd_addr = "127.0.0.1:8125"
}

If agent configuration entry for telemetry required updating, restart of Consul agent is required. Ensure, if restarting servers, to perform rolling-reboot of servers ensuring that the current Raft leader is restarted last.

sudo systemctl restart consul

Enable Consul and Envoy Logging to File

Consul Agent Configuration File

Ensure the following entries are set in any Consul agent configuration files that are desired for log exports to Datadog.

log_level          = "DEBUG"
syslog_facility = "LOCAL1"
log_file = "/var/log/consul/consul.log"

Envoy Extra Args 

Ensure any Envoy sidecar proxies are set to log at the desired level and to a known accessible log location. Below example uses the following extra arguments as an amendment to the consul connect envoy command:

-- --log-level trace --log-path /var/log/envoy/web-proxy.log --component-log-level upstream:trace,http:trace,router:trace,config:trace

# Example Sidecar Extra Config for Logging

consul connect envoy -sidecar-for web-1 -- --log-level trace --log-path /var/log/envoy/backend-proxy.log --component-log-level upstream:trace,http:trace,router:trace,config:trace

 

Expose Envoy Sidecar Proxy Metrics

Proxy Defaults

# File: proxy-defaults.hcl
Kind = "proxy-defaults"
Name = "global"
Config = {
envoy_prometheus_bind_addr = "127.0.0.1:9102"
envoy_dogstatsd_url = "udp://127.0.0.1:8125"
}

Sidecar Specific

# web.hcl - web service and sidecar proxy registration
service {
name = "web"
id = "web-1"
port = 8080

connect {
sidecar_service{
proxy = {
config = [
{
envoy_prometheus_bind_addr = "127.0.0.1:9102"
envoy_dogstatsd_url = "udp://127.0.0.1:8125"
}
]
}
}
}

If using global enablement, ensure to write configuration changes to Consul:

consul config write proxy-defaults.hcl

Re-run/restart Envoy's bootstrap from consul connect envoy command.

# systemd for web-sidecar-proxy
# ExecStart=consul connect envoy -sidecar-for web-1 -address

systemctl restart web-sidecar-proxy

Create Datadog Account

Create a Datadog account following the instructions found on Datadog's website.

Create Datadog API Key

To add a Datadog API key:

  1. Login to Datadog using your account's username and password.
  2. Navigate to Organization settings, then click the API keys tab.
  3. Click the New Key button.
  4. Enter a name for your key or token.
  5. Click Create API key.
  6. Take note of Key ID for later use when installing and configuring agent.

Official Datadog procedure found here.

 

Installing Datadog Agent on Host VM

There are two methods for installing and configuring the Datadog agent daemon on the Host Virtual Machine. Automatically using an s3 maintained script or manually. The steps below go through manually configuring Datadog to capture the concepts of configuration and generate the required Consul and Envoy specific files and directories.

  • If not already done, copy Key ID from Step 6 of Create Datadog API Key above.
  • Continue with configuration steps below.

Install and Configure Datadog for Consul and Envoy

  1. Set up apt so that it can download through https and install curl and gnupg:

    sudo apt-get update
    sudo apt-get install apt-transport-https curl gnupg
  2. Set up the Datadog deb repo on your system and create a Datadog archive keyring:

    sudo sh -c "echo 'deb [signed-by=/usr/share/keyrings/datadog-archive-keyring.gpg] https://apt.datadoghq.com/ stable 7' > /etc/apt/sources.list.d/datadog.list"
    sudo touch /usr/share/keyrings/datadog-archive-keyring.gpg
    sudo chmod a+r /usr/share/keyrings/datadog-archive-keyring.gpg
    
    curl https://keys.datadoghq.com/DATADOG_APT_KEY_CURRENT.public | sudo gpg --no-default-keyring --keyring /usr/share/keyrings/datadog-archive-keyring.gpg --import --batch
    curl https://keys.datadoghq.com/DATADOG_APT_KEY_382E94DE.public | sudo gpg --no-default-keyring --keyring /usr/share/keyrings/datadog-archive-keyring.gpg --import --batch
    curl https://keys.datadoghq.com/DATADOG_APT_KEY_F14F620E.public | sudo gpg --no-default-keyring --keyring /usr/share/keyrings/datadog-archive-keyring.gpg --import --batch
  3. Update your local apt repo and install the Agent:

    sudo apt-get update
    sudo apt-get install datadog-agent datadog-signing-keys
  4. Copy the example datadog.yaml config into place and plug in your API key

    sudo sh -c "sed 's/api_key:.*/api_key: "${DD_API_KEY}"/' /etc/datadog-agent/datadog.yaml.example > /etc/datadog-agent/datadog.yaml"
  5. Configure your Datadog region:

    sudo sh -c "sed -i 's/# site:.*/site: datadoghq.com/' /etc/datadog-agent/datadog.yaml"
  6. Ensure permissions are correct:

    sudo sh -c "chown dd-agent:dd-agent /etc/datadog-agent/datadog.yaml && chmod 640 /etc/datadog-agent/datadog.yaml"
  7. Create Consul specific Datadog configuration directory:

    sudo mkdir --parents /etc/datadog-agent/conf.d/consul.d
  8. Create Envoy specific Datadog configuration directory:

    sudo mkdir --parents /etc/datadog-agent/conf.d/envoy.d
  9. Add consul group permissions to dd-agent user to allow Datadog agent to stream Consul and Envoy logs:

    sudo usermod --append --groups=consul dd-agent
  10. Start the Agent:

    sudo systemctl restart datadog-agent.service
 

Configure Datadog for Consul Metrics Capturing

The core datadog.yaml configuration file needs some configuration before the Datadog agent can capture and export metrics to datadoghq.com.

  1. Open and configure /etc/datadog-agent/datadog.yaml for Consul metrics capturing and log capturing:

    api_key: <YOUR_API_KEY_ID_HERE>
    site: datadoghq.com
    logs_enabled: true
    histogram_percentiles: ["0.10", "0.20", "0.30", "0.40", "0.50", "0.60", "0.70", "0.80", "0.90", "0.95", "0.99"]
    dogstatsd_mapper_profiles:
    - name: consul
    prefix: "consul."
    mappings:
    - match: 'consul\.http\.([a-zA-Z]+)\.(.*)'
    match_type: "regex"
    name: "consul.http.request"
    tags:
    method: "$1"
    path: "$2"
    - match: 'consul\.raft\.replication\.appendEntries\.logs\.([0-9a-f-]+)'
    match_type: "regex"
    name: "consul.raft.replication.appendEntries.logs"
    tags:
    peer_id: "$1"
    - match: 'consul\.raft\.replication\.appendEntries\.rpc\.([0-9a-f-]+)'
    match_type: "regex"
    name: "consul.raft.replication.appendEntries.rpc"
    tags:
    peer_id: "$1"
    - match: 'consul\.raft\.replication\.heartbeat\.([0-9a-f-]+)'
    match_type: "regex"
    name: "consul.raft.replication.heartbeat"
    tags:
    peer_id: "$1"
  2. Create and configure /etc/datadog-agent/conf.d/consul.d/conf.yaml file for Consul agent metrics and logging:

    init_config:
    instances:
    - url: <https://localhost:8501|http://localhost:8500>
    self_leader_check: true
    network_latency_check: true
    catalog_checks: true
    auth_type: "basic"
    service: "consul"
    # If using ACLs and/or RPC TLS Uncomment Below and Configure
    # acl_token: <acl_token_for_metrics_access>
    # tls_ca_cert: "/etc/consul.d/tls/consul-agent-ca.pem"
    # tls_cert: "/etc/consul.d/tls/consul.pem"
    # tls_private_key: "/etc/consul.d/tls/consul-key.pem"
    logs:
    - path: /var/log/consul/*.log
    service: consul
    source: consul
    type: file

    Configure Datadog for Envoy Metrics Capturing

  3. Create and configure /etc/datadog-agent/envoy.d/conf.yaml file for Envoy metrics and logging:

    init_config:
    instances:
    - openmetrics_endpoint: http://127.0.0.1:9102/metrics
    logs:
    - path: /var/log/envoy/*.log
    service: envoy
    source: envoy
    type: file
  4. Restart the Datadog Agent:

    sudo systemctl restart datadog-agent.service
 

Verify Consul to Datadog Agent Communication

Verify UDP DogstatsD Connection is Established with Consul

sudo netstat -nup | grep "127.0.0.1:8125.*ESTABLISHED"

udp 0 0 127.0.0.1:53874 127.0.0.1:8125 ESTABLISHED 23176/consul
Verify Datadog can run Consul metrics capture
sudo -u dd-agent -- datadog-agent check consul

Verify Envoy to Datadog Agent Communication

Verify UDP DogstatsD Connection is Established with Consul

Verify Datadog can run Envoy metrics capture
sudo -u dd-agent -- datadog-agent check envoy

 

Next - Explore Datadog Integration Features

Install Consul and Envoy integrations from Integrations menu within DD UI to retrieve any preset Consul or Envoy Dashboards.

This part is somewhat customized and can get complicated. This will depend on the use-case and can be very custom to whatever needs are necessary.

References:

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB77","label":"Automation Platform"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSSJOV","label":"IBM Consul Self-Managed"},"ARM Category":[{"code":"a8mgJ0000000E9SQAU","label":"Consul-\u003EConsul Operations-\u003EObservability \u0026 Telemetry"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"1.18.0;1.18.11;1.19.0;1.19.9;1.20.0;1.20.7;1.21.0;1.21.5;1.22.0;\u003C 1.15.0;All;legacy"}]

Historical Number

14939459298579

Document Information

Modified date:
09 July 2026

UID

ibm17264208