Skip to main content
Version: 0.10.x

Prometheus

Lunar can be easily set up to export comprehensive metrics on the traffic passing through it. This exporter is meant to be attached to the Metrics Collector diagnosis plugin.

Exporter Configuration

Lunar will bring up a Prometheus Metrics Server even if this exporter is not configured; However, for Lunar-specific Prometheus instruments (such as the one used by the Metrics Collector diagnosis plugin), you may supply your own bucket boundaries. These is the same configuration you'd supply for Prometheus histogram buckets. Here's an example:

exporters:
prometheus:
bucket_boundaries:
- 100
- 500
- 1000
- 3000
# your own bucket boundaries...

In case bucket_boundaries are not declared, the following default ones will be used: [0, 100), [100, 200), [200, 500), [500, 750), [750, 1000), [1000, 2000), [2000, 5000), [5000, 10000].

Scraping Exported Metrics

In order to use the metrics exposed by this Metrics Server, you will need to add a new scrape_config job to your Prometheus scraper. This is often the prometheus.yml file that is responsible for other scrape jobs you might have in your system.

Here's a possible example:

scrape_configs:
- job_name: "lunar-proxy"
scrape_interval: 5s
static_configs:
- targets: ["lunar-proxy-address:3000"]
labels:
group: "production"
# further labels...

Of course the address of Lunar should be adjusted in the targets array. The scrape_interval value is for you to decide, we recommend keeping it equal to or below 5s.

Scraping Exported Metrics in K8s

To enable metrics scraping from the Metrics Server using Prometheus in a Kubernetes environment with Helm installation, you can use the serviceMonitor resource provided by the Prometheus Operator. The serviceMonitor allows you to configure Prometheus to automatically discover and scrape services that match specified criteria.

To enable serviceMonitor in the Helm chart's values.yaml file, you can specify the enabled field as true:

serviceMonitor:
enabled: true

Companion Grafana Dashboard

Download the dashboard JSON from here.

In your Grafana instance, go to Dashboards, and click New. There, choose Import.

You will be prompted to choose a Prometheus data source - this should be the same one that handles the metrics scraping from Lunar.