Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The default login for the control center is username admin and password hivemq.

...

Advanced monitoring using Prometheus and Grafana

...

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 (cC:\prometheus), and run the following command to start Prometheus:

...

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.

  1. Stop the previous Prometheus process, a SIGTERM (CTRL+C) will exit the process gracefully.

  2. Navigate After downloading and extracting the NSSM tool, navigate the NSSM.exe path through the command prompt.Run

Code Block
cd C:\nssm\win64
  1. Then run the below command:

Code Block
nssm.exe install Prometheus "cC:\prometheus\prometheus.exe --config.file=prometheus.yml"

...

  1. 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

  1. Download the HiveMQ Prometheus Monitoring Extension from the HiveMQ Marketplace (free of charge).

  2. Unpack the hivemq-prometheus-extension-<version>.zip file.

  3. Move the entire hivemq-prometheus-extension folder to the extensions folder of your HiveMQ installation (eg. C:\hivemq\extensions\hivemq-prometheus-extension).

  4. Adjust the prometheusConfiguration.properties file that is located in the hivemq-prometheus-extension folder to meet your individual needs.

Info

Since we are configuring Prometheus on the same HiveMQ broker server the default configurations will work great. For more information, see Configuration Options.

...

Start HiveMQ.

...

  1. 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:

Code Block
languageyaml
# my global config
global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["localhost:9090"]

  - job_name: 'hivemq'
    scrape_interval: 5s
    metrics_path: '/metrics'
    static_configs:
      # Using port 9399 because we configured it the HiveMQ Prometheus Extension
      - targets: ["localhost:9399"]
Info

Please pay close attention to the indentation in the Prometheus configuration file, as YAML requires precise spacing and is extremely strict about it.

  1. Reboot your Windows server.

After rebooting your server, if the Prometheus and the HiveMQ Prometheus extension 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 serverWindows machine. By default, Grafana will be installed in C:\Program Files\GrafanaLabs\grafana.

...

Start Grafana: Open the Services application in After successfully installing Grafana on Windows, look for the Grafana service is configured to start automatically, and start it. Alternatively, you can run Grafana using the command line from its installation directory.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

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.

...