Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Use Prometheus and Grafana to do a sample analysis of a monitoring system for HiveMQ

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the use of Prometheus and Grafana for HiveMQ to do a set of example analysis of monitoring system, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

System monitoring is an essential part of any production software deployment. Monitoring MQTT brokers is critical, especially in a clustered environment.

An effective monitoring difficulty lies in choosing the right tools and the right way of thinking.

Like the monitoring tools we use today, HiveMQ can also use Prometheus to monitor its metrics.

Prometheus is one of the most popular solutions for monitoring distributed systems on the market today. We think it is the perfect tool for HiveMQ monitoring.

To support the integration of integrated monitoring tools, HiveMQ exposes a large number of metrics through JMX, so that tools such as JConsole can be used for JMX monitoring.

Using a tool such as JConsole for real-time monitoring is certainly better than none, but there are some drawbacks. HiveMQ is usually deployed with Docker, so you may not be able to access the HiveMQ process directly

Time series monitoring solutions such as Prometheus can also be used as excellent debugging tools when you need to find the root cause of a problem in a production environment.

HiveMQ provides an InfluxDB Extension and Prometheus Extension extension to save HiveMQ timing data.

We are often asked to recommend surveillance tools. So far, we have good experience in Prometheus. However, the tool you choose to use is ultimately your decision and needs to reflect your personal preferences.

Prometheus is very flexible. You can use Prometheus as a time series database to collect and store existing or preferred metrics visualizers that can be used as metrics for data sources.

Alternatively, you can use Prometheus for an all-in-one solution that collects metrics and generates metrics visualization.

Here's how to use Prometheus to collect and visualize HiveMQ metrics. We will also show you how to use Prometheus as a data source in Grafana to create a monitoring dashboard.

In this installation, we want our HiveMQ cluster to report its metrics to Prometheus. We can then set up a Grafana dashboard to monitor our HiveMq metrics in real time.

In order to implement our plan, we need three pieces of software in addition to the HiveMQ cluster:

The HiveMQ Prometheus Monitoring Extension

Prometheus

Grafana

Install the Prometheus HiveMQ extension

HiveMQ provides a wide range of pre-built and ready-to-use extensions. One of these extensions is the HiveMQ Prometheus Monitoring extension. As with all HiveMQ extensions, the installation of this extension is simple:

Download the distribution

Extract the zip file

Move the hivemq-prometheus-extension folder to the extensions folder

Note: be sure to adjust the hivemq- Prometheus extension folder in the prometheusConfiguration.properties file to meet your personalized needs and ensure that the IP address of the network interface can be accessed by your Prometheus server.

12 3 4 5 6 7 8 9101112131 Prometheus Monitoring Extension Configuration##-# The ip where the servlet will be hostedip=# The port where the servlet will work onport=9399# The path for the servlet which gets called by prometheus# For example 127.0.0.1:9399/metricsmetric_path=/metrics install Prometheus

The next step is to install the Prometheus application on the computer of your choice. In our experience, you should not run Prometheus on the same computer running HiveMQ.

To install Prometheus, follow the Prometheus guidelines.

A valid prometheus.yml file based on the HiveMQ Prometheus Extension configuration in this article is as follows:

123456789global: scrape_interval: 15sscrape_configs:-job_name: 'hivemq'scrape_interval: 5smetrics_path:' / metrics'static_configs: # using port 9399 because we configured it the HiveMQ Prometheus Extension-targets: [': 9399 because we configured it the HiveMQ Prometheus Extension,': 9399']

Note: this example is tailored to a 2-node cluster. If you need more nodes, you need to add additional nodes to the target.

Use Prometheus to display metrics

Prometheus is more than just a data source for monitoring dashboards such as Grafana. In addition, Prometheus has a built-in function that can display metrics in real time. This feature is especially useful when you want to learn more about specific metrics that you don't monitor very often. To view, browse to http://:9090 /. Once the Prometheus and HiveMQ Prometheus extensions are configured correctly, you can access the HiveMQ metrics in the expression field.

Display HiveMQ metrics in Prometheus

Install Grafana

The next step in building a monitoring dashboard is to install and start Grafana. Grafana is available out of the box and can be accessed through localhost:3000.

Once Grafana is up and running, we can configure Prometheus as the data source for Grafana.

Step 1: add a data source

Step 2: configure Prometheus

Now, we can focus on the dashboard. In response to the large number of questions we received about the dashboard, the HiveMQ team compiled a great dashboard template that showed the key metrics for most MQTT deployments. Use templates as a convenient starting point for building dashboards that are well suited to your personal use cases.

Download the template here. JSON files within zip can be imported into Grafana.

Step 3: import the information home page

That's all. We now have a working dashboard that displays our metrics and provides the types of monitoring that have proven critical in many MQTT deployments.

This is just one possibility of monitoring MQTT use cases. Your personal requirements may be different. We recommend that you read Grafana's getting started guide to determine the solution that works best for you and your deployment.

Monitoring is an important part of any application operation, and HiveMQ is no exception. As you can see from this blog, it is not difficult to create monitoring settings for HiveMQ using Prometheus and Grafana. We hope that our dashboard template will provide you with a good start, and we strongly recommend that you fine-tune the dashboard to meet the personalized needs of each deployment.

Thank you for reading this article carefully. I hope the article "using Prometheus and Grafana to do a sample analysis of a monitoring system for HiveMQ" shared by the editor will be helpful to everyone. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report