Versions Compared

Key

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

This article is outdated. For the latest version please refer to https://docs.hivemq.com/hivemq-platform-operator/observability.html#monitoring

This article will guide you through the process of installing a Prometheus server in your Kubernetes cluster to monitor HiveMQ. We'll walk you through the steps to configure Prometheus to scrape metrics from HiveMQ, ensuring smooth and efficient monitoring.

...

  1. Add the Prometheus repository to Helm:

    Code Block
    languagebash
    helm repo add 'prometheus-community' 'https://prometheus-community.github.io/helm-charts'
    helm repo update
  2. Get default values and save to the prometheus-values.yaml file:

    Code Block
    languagebash
    helm show values prometheus-community/prometheus > prometheus-values.yaml
  3. Open the prometheus-values.yaml file and disable unnecessary sub-charts by setting prometheus-pushgateway.enabled and alertmanager.enabled to false.

    Code Block
    languageyaml
    prometheus-pushgateway:
      ## If false, pushgateway will not be installed
      ##
      enabled: false
    Code Block
    languageyaml
    alertmanager:
      ## If false, alertmanager will not be installed
      ##
      enabled: false
  4. Add a scrape job for HiveMQ: In the prometheus-values.yaml file, locate the prometheus.yml section, and add a new scraping job for HiveMQ:

    Code Block
    languageyaml
      prometheus.yml:
        ...
        scrape_configs:
        ...
        ...
          - job_name: 'hivemq'
            scrape_interval: 5s
            metrics_path: '/metrics'
            static_configs:
              - targets: [ 'hivemq:9399' ]
  5. Deploy Prometheus in your Kubernetes cluster using the updated configuration file:

    Code Block
    languagebash
    helm upgrade 'prometheus' \
      --install 'prometheus-community/prometheus' \
      --values 'prometheus-values.yaml' \
      --namespace 'hivemq-namespace'
  6. You can access the Prometheus server within your cluster via port 80 using the following DNS name: prometheus-server.hivemq.svc.cluster.local
    To forward the port to the localhost:80, use the following command:

    Code Block
    languagebash
    kubectl port-forward svc/prometheus-server 80:80
  7. To expose the metrics endpoint for Prometheus, update your HiveMQ deployment with monitoring.enabled=true:

    Code Block
    languagebash
    helm upgrade 'hivemq' --install 'hivemq/hivemq-operator' \
      --values 'hivemq-values.yaml' \
      --set 'monitoring.enabled=true' \
      --namespace 'hivemq-namespace'
  8. If the HiveMQ log is set at the DEBUG level, Prometheus’s activity can be verified:

    Code Block
    DEBUG - Received HTTP-Get-Request from Prometheus to scrape metrics from HiveMQ: Request(GET http://10.244.5.7:9399/metrics)@557cfc7a

In this article, we've outlined the steps to set up Prometheus in your Kubernetes cluster for monitoring HiveMQ. You've learned how to configure Prometheus, enable scraping for HiveMQ, and access the Prometheus server for effective monitoring of your HiveMQ deployment.

Tested with versions:

grafana/grafana 6.59.4 10.1.1

prometheus-community/prometheus 24.4.0 v2.47.0

hivemq/hivemq-operator 0.11.25 4.19.0

Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@957
sortmodified
showSpacefalse
reversetrue
typepage
labelskb-how-to-article
cqllabel = "kb-how-to-article" and type = "page" and space = "KB"