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.
Stop the previous Prometheus process, a SIGTERM (CTRL+C) will exit the process gracefully.
Navigate the NSSM.exe path through the command prompt.
Run below command:
nssm.exe install Prometheus "c:\prometheus\prometheus.exe --config.file=prometheus.yml"
Check if Prometheus service is installed and running by 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 (free of charge).
Unpack the
hivemq-prometheus-extension-<version>.zip
file.Move the entire
hivemq-prometheus-extension
folder to theextensions
folder of your HiveMQ installation.Adjust the
prometheusConfiguration.properties
file that is located in thehivemq-prometheus-extension
folder to meet your individual needs. For more information, see Configuration Options.Start HiveMQ.
When 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. Run the installer and follow the instructions to install Grafana on your server. By default, Grafana will be installed in C:\Program Files\GrafanaLabs\grafana.
Start Grafana: Open the Services application in Windows, look for the Grafana service, and start it. Alternatively, you can run Grafana using the command line from its installation directory.
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 gear icon on the left panel to open the Configuration menu.
Select "Data Sources" and then click on "Add data source".
Choose "Prometheus" as the type.
In the URL field, enter the Prometheus server's address, which is usually http://localhost:9090 if running on the same server.
Click "Save & Test" to ensure Grafana can connect to Prometheus.
Step 4: Create a Dashboard in Grafana
Create a New Dashboard: From the Grafana main menu, click on the "+" icon, then select "Dashboard".
Add a Panel: Click "Add new panel". Here, you can configure the query to display data collected by Prometheus. Use the query field to specify the metric you want to visualize.
Configure and Save Your Panel: Once you've set up your query, you can customize the panel's appearance and save it to your dashboard.
View Your Data: After saving, you should see your data visualized on the dashboard.
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.