feat: add Datadog integration with dashboard and agent configuration#8
Conversation
Add support for Datadog as an alternative to Prometheus/Grafana: - Add pre-built Datadog dashboard with overview, request, latency, upstream, connection, and SSL/rate limiting widgets - Add OpenMetrics agent configuration for scraping ngxstats metrics - Update README with Datadog setup documentation
There was a problem hiding this comment.
Pull request overview
This PR adds Datadog integration support to the lua-resty-ngxstats project by providing a pre-configured OpenMetrics agent configuration and a comprehensive dashboard for visualizing NGINX metrics in Datadog.
Changes:
- Added OpenMetrics configuration file for the Datadog Agent to scrape Prometheus-format metrics from ngxstats
- Added pre-built Datadog dashboard JSON with widgets for monitoring overview, requests, latency, upstream, connections, and SSL/rate limiting
- Updated README with Datadog setup instructions including agent configuration and dashboard import steps
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| examples/datadog-openmetrics.yaml | New Datadog Agent configuration for scraping ngxstats metrics with namespace, metric filters, and optional settings |
| examples/datadog-dashboard.json | New dashboard JSON with organized widget groups for comprehensive NGINX monitoring |
| README.md | Added Datadog integration section with setup instructions for agent configuration and dashboard import |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,110 @@ | |||
| # Datadog Agent OpenMetrics configuration for lua-resty-ngxstats | |||
There was a problem hiding this comment.
The project name appears as 'lua-resty-ngxstats' in the header comment, but should be confirmed against the actual repository name for consistency.
| # Datadog Agent OpenMetrics configuration for lua-resty-ngxstats | |
| # Datadog Agent OpenMetrics configuration for NGINX stats (ngxstats /status endpoint) |
| "type": "check_status", | ||
| "check": "nginx.nginx_upstream_health", | ||
| "grouping": "cluster", | ||
| "group_by": ["upstream"], | ||
| "tags": ["$host", "$upstream"] |
There was a problem hiding this comment.
The check status widget references 'nginx.nginx_upstream_health' but the OpenMetrics configuration collects 'nginx_upstream_health' as a metric, not a service check. Datadog check status widgets require actual service checks, not metrics. This widget will not function as intended and should either be removed or replaced with a query_value widget using the metric.
| "type": "check_status", | |
| "check": "nginx.nginx_upstream_health", | |
| "grouping": "cluster", | |
| "group_by": ["upstream"], | |
| "tags": ["$host", "$upstream"] | |
| "type": "query_value", | |
| "requests": [ | |
| { | |
| "q": "avg:nginx_upstream_health{$host,$upstream} by {upstream}", | |
| "aggregator": "avg" | |
| } | |
| ] |
| - **SSL/TLS** - Low session reuse, deprecated protocol usage | ||
| - **Traffic** - Spikes, drops, high bandwidth | ||
|
|
||
| ### 6. Datadog Integration (Alternative to Prometheus) |
There was a problem hiding this comment.
The section is numbered '6' but the numbering context from previous sections is not visible in the diff. Verify that this section number is correct and follows the existing documentation structure.
| ### 6. Datadog Integration (Alternative to Prometheus) | |
| ### Datadog Integration (Alternative to Prometheus) |
Add pre-built Datadog monitors equivalent to Prometheus alerting rules: - Availability monitors (instance down, no requests) - Error rate monitors (5xx, 4xx thresholds) - Latency monitors (average latency, slow requests) - Upstream monitors (failures, error rate, latency, health) - Connection monitors (high connections, unhandled) - Cache monitors (low hit rate, high bypass) - Rate limiting monitors (rejections, active limiting) - SSL/TLS monitors (session reuse, deprecated protocols) - Traffic monitors (spikes, drops, bandwidth) Update README with monitor import instructions.
Summary
examples/datadog-dashboard.json) with widgets for overview, request metrics, latency, upstream, connections, and SSL/rate limitingexamples/datadog-openmetrics.yaml) for scraping ngxstats Prometheus-format metricsTest plan
datadog-openmetrics.yamlsyntax is valid YAMLdatadog-dashboard.jsonsyntax is valid JSON