Integrate with Datadog
Lunar Proxy can export metrics to Datadog for monitoring and alerting purposes. To do so, you need to configure Lunar Proxy to expose the metrics, and configure Datadog Agent to scrape the metrics.
1. Configure Lunar Proxy to Expose Metrics
To configure Lunar Proxy to expose metrics, you need to configure a metrics collector diagnosis plugin.
This is done by adding the following to your /etc/lunar-proxy/policies.yaml
file (see Customize & Configure for more information):
diagnosis:
- enabled: true
name: "Global Metrics Collector"
export: "prometheus"
config:
metrics_collector: {}
The diagnosis plugin should be configured either under the global
section or under a specific endpoint in the endpoints
section.
See the Metrics Collector documentation for more information.
Some metrics will only appear if a specific remedy plugin is enabled (see the Metrics section below).
- Docker
- K8S
2. Configure Datadog Agent to Scrape Metrics
To configure Datadog Agent to scrape Lunar Proxy metrics, you need to configure the Datadog Agent's conf.d/openmetrics.d/conf.yaml
file to include the following:
instances:
- prometheus_url: http://<lunar-proxy-hostname>:3000/metrics
namespace: <lunar-proxy-namespace>
metrics: ["*"]
See the Datadog documentation for more information.
2. Configure Datadog Agent to Scrape Metrics
In order to use the metrics exposed by Lunar Proxy, you will need to make sure that your Datadog Agent's configuration contains the following:
prometheusScrape:
enabled: true
serviceEndpoints: true
3. Set Annotations on Lunar Proxy Deployment
To configure Datadog Agent to scrape Lunar Proxy metrics, you need to add the following annotations to the Lunar Proxy deployment:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "3000"
prometheus.io/path: "/metrics"
See the Datadog documentation for more information.
Companion Datadog Dashboard
The following dashboard can be imported into your Datadog account to visualize the metrics exported by Lunar Proxy:
Download the Datadog dashboard JSON from here.
To import the dashboard, follow the instructions here.
Some of the metrics will only appear if the relevant plugin is enabled. All metrics require traffic to flow through Lunar Proxy in order to appear.
Metrics
The following metrics are exposed by Lunar Proxy:
Metric Name | Description | Labels | Depends On |
---|---|---|---|
General | |||
lunar_transaction_count | The number of transactions that have passed through Lunar Proxy | method , normalized_url , status_code , request_<header_name> | Metrics Collector |
lunar_transaction_sum | Sum of transaction durations | method , normalized_url , status_code , request_<header_name> | Metrics Collector |
lunar_transaction_bucket | Buckets of transaction durations | method , normalized_url , status_code , request_<header_name> | Metrics Collector |
Throttling | |||
lunar_remedies_strategy_based_throttling_quota_limit | The quota limit of a strategy-based throttling remedy | remedy_name | Strategy-Based Throttling |
lunar_remedies_strategy_based_throttling_quota_used | The quota used of a strategy-based throttling remedy | remedy_name , group_id | Strategy-Based Throttling |
Queue | |||
lunar_remedies_strategy_based_queue_requests_total | The total number of requests that have been queued and handled | priority , remedy , ttl_passed | Queue |
lunar_remedies_strategy_based_queue_requests_in_queue | The number of requests that are currently in the queue | priority , remedy | Queue |