Coder Social home page Coder Social logo

emqx / emqx-exporter Goto Github PK

View Code? Open in Web Editor NEW
24.0 11.0 8.0 1.49 MB

Prometheus exporter for EMQX

Home Page: https://www.emqx.com

License: Apache License 2.0

Dockerfile 0.20% Makefile 1.26% Go 43.51% Python 55.03%
emqx grafana prometheus metrics emqx-exporter emqx-metrics

emqx-exporter's Introduction

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.

emqx-exporter's People

Contributors

jacky-xbb avatar logo306142054 avatar rory-z avatar yang-yinbo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emqx-exporter's Issues

avoid calling v4 api

this version probing will generate some suspicious logs in emqx v5.

func (c *cluster) checkNodes() {
httpClient := getHTTPClient(*emqxNodes)
var currentVersion string
for {
var client client
var err4, err5 error
client = &cluster4x{client: httpClient}
_, err4 = client.getClusterStatus()
if err4 != nil {
client = &cluster5x{client: httpClient}
_, err5 = client.getClusterStatus()
}
if err4 != nil && err5 != nil {
_ = level.Warn(c.logger).Log("check nodes", "couldn't get node info", "addr", *emqxNodes,
"err4", err4.Error(), "err5", err5.Error())
client = nil
} else if currentVersion != client.getVersion() {
currentVersion = client.getVersion()
_ = level.Info(c.logger).Log("ClusterVersion", currentVersion)
}
c.nodeLock.Lock()
c.client = client
c.nodeLock.Unlock()
select {
case <-context.Background().Done():
return
case <-time.After(5 * time.Second):
}
}
}

an alternative is to try to call the /status endpoint with ?format=json, in v4 it will return text (ignore the json arg).
in v5 it returns a json like below

curl -s 'http://127.0.0.1:18083/status?format=json'
{"rel_vsn":"e5.1.1","node_name":"[email protected]","broker_status":"started","app_status":"running"}

Path not found for API v5

I tried to configure emqx-exporter following the readme steps but when starting the service it is not collecting any metrics and instead it's only logging the following error:

ts=2023-09-04T07:33:47.430Z caller=collector.go:101 level=error msg="collector failed" name=license duration_seconds=0.071967078 err="/api/v5/license: Not Found"

Any config I might have wrong? to be mentioned that I have emqx.5.0.26 open-source installed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.