Back in the day, I posted a question about how to pull Caddy stats into the Datadog monitoring platform. Because the original thread is closed, I will post the solution in this new thread..
- Datadog offers an agent that can read OpenMetrics API
- Caddy offers OpenMetrics compatible API, which is usually consumed by Prometheus
- Note that Datadog/statds is “push style metrics” while Prometheus / OpenMetrics is pull style metrics
Caddy Metrics
Metrics are exposed on http://127.0.0.1:6000/metrics
. Note that the port binding works on Linux only.
To test the metrics endpoint:
curl http://127.0.0.1:6000/metrics
Datadog integration instructions
You can make Datadog agent to read OpenMetrics from Caddy endpoint.
On the reverse proxy host, Go to DataDog OpenMetrics plugin directory and enable OpenMetrics:
/etc/datadog-agent/conf.d/openmetrics.d
mv conf.yaml.example conf.yaml
Edit conf.yaml
:
instances:
- openmetrics_endpoint: http://127.0.0.1:6000/metrics
namespace: caddy
metrics: ["caddy*"]
Restart agent:
sudo service datadog-agent restart
Give it 1 minute. Then check the OpenMetrics plugin is running:
datadog-agent status|grep -C 30 openmetrics
It should be running:
openmetrics (1.15.2)
--------------------
Instance ID: openmetrics:caddy:17dd45bf18763b62 [OK]
Configuration Source: file:/etc/datadog-agent/conf.d/openmetrics.d/conf.yaml
Total Runs: 41
Metric Samples: Last Run: 657, Total: 26,937
Events: Last Run: 0, Total: 0
Service Checks: Last Run: 1, Total: 41
Average Execution Time : 27ms
Last Execution Date : 2022-01-09 21:11:18 CET / 2022-01-09 20:11:18 UTC (1641759078000)
Last Successful Execution Date : 2022-01-09 21:11:18 CET / 2022-01-09 20:11:18 UTC (1641759078000)
After this create a new dashboard in Datadog using these metrics.