Skip to content

emqx/emqx-exporter

Repository files navigation

EMQX Exporter

GitHub Release Docker Pulls codecov

The `emqx-exporter` is designed to expose partial metrics that are not included in the EMQX Prometheus API.

It is compatible with EMQX 4.4 and EMQX 5, both open-source and enterprise.

Dashboard

Structure

Structure

Metrics

See the documentation Instruction for an explanation of the metrics on the dashboard

Building and running

The emqx-exporter listens on HTTP port 8085 by default. See the --help output for more options.

Required

EMQX exporter requires access to the EMQX dashboard API with basic auth, so you need to sign in to the dashboard to create an API secret Note that it is different to create a secret between EMQX 5 and EMQX 4.4 on the dashboard.

Build

make build

Running

./bin/emqx-exporter <flags>

Docker Compose

Refer to the example to deploy a complete demo by docker compose.

Kubernetes

Refer to the example to learn how to deploy emqx-exporter on the Kubernetes.

Configuration

Sample config file like this

metrics:
  target: 127.0.0.1:18083
  api_key: "some_api_key"
  api_secret: "some_api_secret"
probes:
  - target: 127.0.0.1:1883

The metrics and the probes are not required configuration items, if not set metrics, the metrics feature will disable, and if not set probes, the probe feature will disable.

Prometheus Config

The scrape config below is available for EMQX 5

scrape_configs:
- job_name: 'emqx-self-metrics'
  metrics_path: /api/v5/prometheus/stats
  scrape_interval: 5s
  honor_labels: true
  static_configs:
    # a list of addresses of all EMQX nodes
    - targets: [${your_emqx_addr}:18083]
      labels:
        # label the cluster name of where the metrics data from
        cluster: ${your_emqx_addr}
        # fix value, don't modify
        from: emqx
- job_name: 'exporter-metrics'
  metrics_path: /metrics
  scrape_interval: 5s
  static_configs:
    - targets: [${your_exporter_addr}:8085]
      labels:
        # label the cluster name of where the metrics data from
        cluster: ${your_cluster_name}
        # fix value, don't modify
        from: exporter
- job_name: 'exporter-probe'
  metrics_path: /probe
  params:
    target:
      # must equal the `probes[$index].taget` in config file
      - "127.0.0.1:1883"
  scrape_interval: 5s
  static_configs:
    - targets: [${your_exporter_addr}:8085]
      labels:
        # label the cluster name of where the metrics data from
        cluster: ${your_cluster_name}
        # fix value, don't modify
        from: exporter

Grafana Dashboard

Import all templates to your Grafana, then browse the dashboard EMQX and enjoy yourself!

The templates of dashboard ares JSON files, about how to upload a dashboard JSON file, you can check out here.

TLS endpoint

EXPERIMENTAL

The exporter supports TLS via a new web configuration file.

./emqx-exporter --web.config.file=web-config.yml

See the exporter-toolkit https package for more details.