Enable monitoring on Windows
Basic Monitoring using Control Center
HiveMQ Control Center provides quick access to several useful administrative functions and some metrics.
The HiveMQ Control Center automatically ships with HiveMQ and is enabled by default. No additional installation is required. While HiveMQ broker is running on your Windows machine you can navigate to the http://localhost:8080/ URL to view Control Center.
The default login for the control center is username admin
and password hivemq
.
Advanced monitoring using Prometheus and Grafana
Setting up Prometheus and Grafana on Windows OS involves several steps. We’ll need three pieces of software in addition to our HiveMQ broker installation:
HiveMQ Prometheus Monitoring Extension
Prometheus
Grafana
We'll guide you through the process, from installing both applications and HiveMQ Prometheus Extension to configuring them to work together.
Step 1: Download and Install Prometheus
Download Prometheus for Windows: Go to the official Prometheus website and download the latest version of Prometheus for Windows. The download will be a zip file (e.g. prometheus-2.50.1.windows-amd64.zip
Extract Files: Extract the downloaded zip file to your desired location, (e.g. C:\prometheus
).
Configure Prometheus: Open the prometheus.yml
file in the extracted folder with a text editor to configure Prometheus. The default configuration is sufficient to get started, but you can adjust it according to your needs.
Run Prometheus: Open a command prompt, navigate to the Prometheus folder (C:\prometheus
), and run the following command to start Prometheus:
cd c:\prometheus
prometheus.exe --config.file=prometheus.yml
Verify Installation: Open your web browser and navigate to http://localhost:9090 to access the Prometheus Web UI. If everything is set up correctly, you should see the Prometheus interface.
Installation of Prometheus as a Service in Windows: To install Prometheus as a service you need to use NSSM tool. NSSM provides a simple way to wrap a specific executable (the main prometheus.exe
file, in this case), and make them available as a Windows service.
Stop the previous Prometheus process, a SIGTERM (CTRL+C) will exit the process gracefully.
After downloading and extracting the NSSM tool, navigate the NSSM.exe path through the command prompt.
cd C:\nssm\win64
Then run the below command:
Check if Prometheus service is installed via Run >
services.msc
and search for Prometheus Service.
Step 2: Download and Install the HiveMQ Prometheus Monitoring Extension
Download the HiveMQ Prometheus Monitoring Extension from the HiveMQ Marketplace.
Unpack the
hivemq-prometheus-extension-<version>.zip
file.Move the entire
hivemq-prometheus-extension
folder to theextensions
folder of your HiveMQ installation (eg.C:\hivemq\extensions\hivemq-prometheus-extension
).Adjust the
prometheusConfiguration.properties
file that is located in thehivemq-prometheus-extension
folder to meet your individual needs.
Since we are configuring Prometheus on the same HiveMQ broker server the default configurations will work great. For more information, see Configuration Options.
To enable Prometheus to gather metrics from HiveMQ, add a scrape configuration to your Prometheus configuration. A working
prometheus.yml
file based on the default HiveMQ Prometheus Extension configuration will look like this:
Please pay close attention to the indentation in the Prometheus configuration file, as YAML requires precise spacing and is extremely strict about it.
Reboot your Windows server.
After rebooting your server, if the Prometheus and the HiveMQ Prometheus Extension are configured correctly, you can access your HiveMQ metrics in the Expression field.
Step 2: Download and Install Grafana
Download Grafana for Windows: Visit the official Grafana website and download the latest version of Grafana for Windows.
Install Grafana: The download will be an installer (eg. grafana-10.4.0.windows-amd64.msi
). Run the installer and follow the instructions to install Grafana on your Windows machine. By default, Grafana will be installed in C:\Program Files\GrafanaLabs\grafana
.
Start Grafana: After successfully installing Grafana on Windows, the Grafana service is configured to start automatically, ensuring immediate availability for configuring and viewing dashboards without requiring manual service initiation.
Access Grafana: Open your web browser and go to http://localhost:3000. The default login is admin for both the username and password.
Step 3: Configure Grafana to Use Prometheus as a Data Source
Log into Grafana: After accessing Grafana, log in using the default or your configured credentials.
Add Prometheus as a Data Source:
Click on the hamburger icon on the left panel to open the Configuration menu.
Select Connections > Data Sources and then click on "Add data source".
Choose "Prometheus" as the type.
In the Prometheus server URL field, enter the Prometheus server's address, which is usually http://localhost:9090 since we are running all services on the same server.
Scroll down to the bottom and Click "Save & Test" to ensure Grafana can connect to Prometheus. Upon successful execution, you will receive the confirmation message: "Successfully queried the Prometheus API."
Step 4: Create a Dashboard in Grafana
HiveMQ has put together a great little dashboard template that displays the key metrics for most MQTT deployments. Use the template as a convenient starting point for building a dashboard that is perfectly tailored to your individual use case.
Download HiveMQ Dashboard template: Download the template right here. The JSON file inside the zip file can be imported to Grafana.
Import HiveMQ Dashboard: From the Grafana main menu on the top right, click on the "+" icon, then select "Import dashboard".
Click on the "Upload dashboard JSON file" button and navigate to the location of HiveMQ Dashboard JSON file on your computer.
Select the file
HiveMQ-Dashboard-Prometheus.json
and open it. This will load the dashboard configuration into Grafana.Choose a name for your Dashboard and make sure you select the right data source created previously, then click on the “Import” button.
View Your Data: After importing, the dashboard will be available in your Grafana instance. You can now view and interact with your newly imported dashboard. Make sure to select the correct time range.
Remember, this setup is basic and serves as a starting point. Depending on your environment and requirements, you might need to adjust firewall settings, configure additional Prometheus targets, or customize Grafana dashboards extensively.