Code Monkey home page Code Monkey logo

hivemq-prometheus-extension's Introduction

HiveMQ Prometheus Extension

Extension Type GitHub release (latest by date) GitHub GitHub Workflow Status

Purpose

The Prometheus Monitoring extension allows HiveMQ to expose metrics to a Prometheus application.

Installation

  1. Unzip the file: hivemq-prometheus-extension-<version>-distribution.zip to the directory: <HIVEMQ_HOME>/extensions

  2. A configuration file prometheusConfiguration.properties can be found in the hivemq-prometheus-extension folder. The properties are preconfigured with standard settings and can be adapted to your needs (The meaning of the fields is explained below).

  3. Start HiveMQ.

Configuration

The extension can be configured with the prometheusConfiguration.properties file, which is part of the hivemq-prometheus-extension folder.

Table 1. Configuration Options
Name Default Description

port

9399

The port which the servlet will listen to.

ip

0.0.0.0

The bind-address which the servlet will listen to.

metric_path

/metrics

The path for the service which gets called by Prometheus. It must start with a slash.

First Steps

You can test your configuration by navigating to <ip>:<port><metric_path> (as configured in prometheusConfiguration.properties) in your browser. For example the address would be http://localhost:9399/metrics with default values.

You should see data provided by the extension:

# HELP com_hivemq_messages_incoming_publish_rate_total Generated from Dropwizard metric import (metric=com.hivemq.messages.incoming.publish.rate, type=com.codahale.metrics.Meter)
# TYPE com_hivemq_messages_incoming_publish_rate_total counter
com_hivemq_messages_incoming_publish_rate_total 0.0
...

Final Steps

  1. Load and install Prometheus

  2. Configure Prometheus to scrape from <ip>:<port><metricPath> as configured in the prometheusConfiguration.properties.

  3. Look at the website provided by your Prometheus application. You should be able to find the HiveMQ metrics.

For detailed information please visit: https://prometheus.io/docs/operating/configuration/

To enable Prometheus to gather metrics from HiveMQ, you need to add a scrape configuration to your Prometheus configuration. The following is a minimal example using the default values of the extension:

prometheus.yml
global:
  scrape_interval: 15s
scrape_configs:
  - job_name: 'hivemq'
    scrape_interval: 5s
    metrics_path: '/metrics'
    static_configs:
      - targets: ['localhost:9399']

Need Help?

If you encounter any problems, we are happy to help. The best place to get in contact is our support.

Contributing

If you want to contribute to HiveMQ Prometheus Extension, see the contribution guidelines.

License

HiveMQ Prometheus Extension is licensed under the APACHE LICENSE, VERSION 2.0. A copy of the license can be found here.

hivemq-prometheus-extension's People

Stargazers

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

Watchers

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

hivemq-prometheus-extension's Issues

Add prometheus labels and metric name suffix

What: Would like to add labels to prometheus metrics. Similar to influxDB extension tags they can be optionally configured in the configuration.
Example:
labels:host=--NODE-NAME--

How: Support for labels was added to supporting library with version 0.6.0 client_java.
--> [FEATURE] Allow mapping DropWizard metrics with Prometheus labels (#435)
The library is already updated to version 0.9.0 for the extension and therefore supports labels with the SampleBuilder.

Result: Metrics are exported with optional labels.
Example:
com_hivemq_jvm_buffer_pool_direct_used{host="host123",} 16385.0

At the same time it would be good to support the possibility for a metric name suffix as well:
Example (with cluster1 as suffix):
com_hivemq_jvm_buffer_pool_direct_used_cluster1.

Work: Have a branch ready if issue is approved.

Documation clarification.

What did you do?

Followed the install instructions located here:
( https://www.hivemq.com/extension/prometheus-extension/ )

What did you expect to see?

To see metrics located here http://xx.xx.xx.xx:9090/targets
This is my prometheus server and config for it. I get back this error.
"Get http://xx.xxxx.xx:9399/metrics: dial tcp xx.xx.xx.xx:9399: connect: connection refused"

Prometheus configuration file:

global:
  scrape_interval:     15s
  evaluation_interval: 15s
scrape_configs:
- job_name: hivemq
  - targets:
    - 'xx.xx.xx.xx:9399'

I am wondering if I have the .jar file in the right location? my hivemq lives in /opt/hivemq, but I couldn't find the /extensions directory. There was a /plugins directory and I tried that both putting the .jar file directly into it and also putting the 'hivemq-prometheus-extension' directory into the plugins directory. I was hoping for some clarification.

Extension does not start

Prometheus extension version 4.0.1 does not work with HiveMQ 4.2.0.

Error on startup:

java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
at org.eclipse.jetty.server.handler.ContextHandler.(ContextHandler.java:114)
at com.hivemq.extensions.prometheus.export.PrometheusServer.start(PrometheusServer.java:64)
at com.hivemq.extensions.prometheus.PrometheusMainClass.extensionStart(PrometheusMainClass.java:65)
at com.hivemq.extensions.HiveMQExtensionImpl.start(HiveMQExtensionImpl.java:133)
at com.hivemq.extensions.HiveMQPlugins.pluginStart(HiveMQPlugins.java:209)
at com.hivemq.extensions.loader.PluginLifecycleHandlerImpl.lambda$startPlugin$0(PluginLifecycleHandlerImpl.java:82)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContextListener
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at com.hivemq.extensions.classloader.IsolatedPluginClassloader.loadClass(IsolatedPluginClassloader.java:123)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 9 common frames omitted

This is because broker itself does not provide javax.servlet.* classes and configuration in pom.xml of the extension excludes servlet-api from being included in the package.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Pending Approval

These branches will be created by Renovate only once you click their checkbox below.

  • Update all major dependencies (major) (org.eclipse.jetty:jetty-util, org.eclipse.jetty:jetty-servlet, org.eclipse.jetty:jetty-server)

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • Update gradle/actions digest to dbbdc27

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/check.yml
  • actions/checkout v4@692973e3d937129bcbf40652eb9f2f61becf3332
  • actions/setup-java v4@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
  • gradle/actions v3@31ae3562f68c96d481c31bc1a8a55cc1be162f83
  • docker/login-action v3@0d4c9c5ea7693da7b068278f7b52bda2a190a446
.github/workflows/releaseExtension.yml
  • actions/checkout v4@692973e3d937129bcbf40652eb9f2f61becf3332
  • actions/setup-java v4@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
  • gradle/actions v3@31ae3562f68c96d481c31bc1a8a55cc1be162f83
  • actions/upload-release-asset v1@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5
gradle
gradle.properties
settings.gradle.kts
build.gradle.kts
gradle/libs.versions.toml
  • org.assertj:assertj-core 3.25.3
  • org.jetbrains:annotations 24.1.0
  • org.eclipse.jetty:jetty-server 10.0.21
  • org.eclipse.jetty:jetty-servlet 10.0.21
  • org.eclipse.jetty:jetty-util 10.0.21
  • ch.qos.logback:logback-classic 1.5.6
  • org.mockito:mockito-core 5.11.0
  • com.squareup.okhttp3:okhttp 4.12.0
  • org.aeonbits.owner:owner 1.0.12
  • io.prometheus:simpleclient 0.16.0
  • io.prometheus:simpleclient_dropwizard 0.16.0
  • io.prometheus:simpleclient_servlet 0.16.0
  • org.testcontainers:hivemq 1.19.8
  • org.testcontainers:junit-jupiter 1.19.8
  • com.hivemq.extension 3.1.0
  • io.github.sgtsilvio.gradle.defaults 0.2.0
  • com.github.hierynomus.license 0.16.1

  • Check this box to trigger a request for Renovate to run again on this repository

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.