Skip to main content

Metrics Collector

Lunar can be easily set up to collect comprehensive metrics on the traffic passing through it. These metrics can then be exported to a metric server like Prometheus for utilization in dashboards and alerts.

Set Up Metrics Collector Diagnosis Plugin

Global Example

You have the flexibility to configure the Metrics Collector diagnosis plugin either globally or per endpoint. No specific plugin configuration is required for this setup.

/etc/lunar-proxy/policies.yaml
global:
diagnosis:
- enabled: true
name: "Global Metrics Collector"
export: "prometheus"
config:
metrics_collector: {}

Endpoint-specific Example

/etc/lunar-proxy/policies.yaml
endpoints:
- url: api.com/resource/{id}
method: PUT
diagnosis:
- enabled: true
name: "api.com Metrics Collector"
export: "prometheus"
config:
metrics_collector: {}

Supported Exporters

note
  • The plugin can export data to File, S3, or Prometheus. However, the most common usage is to export to Prometheus, which seamlessly integrates with Lunar and can be accessed at :3000/metrics.
  • This diagnosis plugin has no fields to configure, it just needs to be declared in order to be turned on; hence the somewhat uncommon syntax on metrics_collector: {} (yes, this is perfectly valid YAML!)
  • This diagnosis plugin exports the normalized_url field.
    • If defined as a global policy, it will be translated to the host part of the URL of any incoming request.
    • If defined as an endpoint-specific policy, it will simply be the declared endpoint URL - in the example above, it would be api.com/resource/[id].

This is done in order to ensure low cardinality of label values which is crucial for good performance of metric systems such as Prometheus.

Click me for guidance 😀