/
Forward HiveMQ JMX metrics to DataDog | HiveMQ Platform Operator (new)

Forward HiveMQ JMX metrics to DataDog | HiveMQ Platform Operator (new)

This article explains how to expose HiveMQ JMX metrics to DataDog using Kubernetes.

 Requirements

  • Running Kubernetes cluster version 1.23.x or higher

  • Helm version 3.10.x or higher

  • The Kubernetes command line tool kubectl

  • HiveMQ Professional or Enterprise Edition, versions 4.19 or higher

  • kubectl context set to the target Kubernetes cluster where HiveMQ is installed

 Instructions

Install and configure a DataDog agent

  1. Add Datadog helm repository:

    1. helm repo add datadog https://helm.datadoghq.com helm repo update datadog
  2. Create datadog-values.yaml. For full values check here.
    Please refer to following the example of datadog-values.yaml:

    1. logLevel: DEBUG targetSystem: "linux" datadog: apiKey: <DATADOG_API_KEY_FROM_THE_DATADOG_ACCOUNT> #Logs configurations logs: enabled: true containerCollectAll: true containerCollectUsingFiles: true # Please configure this setting based on your region site: datadoghq.eu tags: [] # datadog.kubelet.tlsVerify should be `false` on kind and minikube # to establish communication with the kubelet kubelet: tlsVerify: false #Following settings are required to collect the Kubernetes events with the Cluster Agent collectEvents: true clusterAgent: rbac: create: true # setting to read JMX metrics from HiveMQ agents: image: tagSuffix: "jmx"
  3. Optionally, create a dedicated namespace for the Datadog Agent. Further in this article, we consider the datadog namespace.

    kubectl create namespace datadog
  4. Install Datadog agent using Helm:

    helm upgrade datadog --install datadog/datadog --values datadog-values.yaml --namespace datadog
  5. Verify installation and check the agent pod’s status

    kubectl get pods --namespace datadog

    The successful output should resemble this:

    NAME READY STATUS RESTARTS AGE pod/datadog-b7rtk 3/3 Running 0 40s pod/datadog-cluster-agent-7b8c8495f9-7zbff 1/1 Running 0 40s pod/datadog-jdbvj 3/3 Running 0 40s
  6. Also, check the agent’s logs to confirm.

    kubectl logs daemonsets/datadog --namespace datadog --follow
    kubectl logs deployment/datadog-cluster-agent --namespace datadog --follow

Install HiveMQ Platform

  1. Optionally, create a dedicated namespace for the HiveMQ. Further in this article, we assume the hivemq namespace.

    kubectl create namespace hivemq
  2. Install the HiveMQ Platform Operator

    helm upgrade oper --install hivemq/hivemq-platform-operator --namespace hivemq

    Once the pod for the hivemq-platform-operator “oper” is running and ready, proceed to install the HiveMQ Platform(s).

    kubectl get pods --selector "app.kubernetes.io/name":"hivemq-platform-operator" -A
  3. For the Datadog Agent to auto-discover HiveMQ metrics and logs, update the hivemq-platform’s values.yaml and add the required annotation to HiveMQ pods:

    nodes: # Annotations to add to the HiveMQ Pods annotations: ad.datadoghq.com/hivemq.checks: '{ "hivemq": { "init_config": { "is_jmx": true, "collect_default_metrics": true }, "instances": [ { "host": "%%host%%", "port": "9010" } ] } }'

    Reference: Datadog Integration Annotations method – Kubernetes and Integrations.

  4. Should you want to add more metrics to available HiveMQ metrics, please refer to the following example:

    nodes: # Annotations to add to the HiveMQ Pods annotations: ad.datadoghq.com/hivemq.checks: '{ "hivemq": { "init_config": { "is_jmx": true, "collect_default_metrics": true, "conf": [ { "include": { "bean": "metrics:name=com.hivemq.jvm.memory.heap.max", "attribute": { "Value": { "alias": "hivemq.jvm.memory.heap.max.xxx1234", "metric_type": "gauge" } } } }, { "include": { "bean": "metrics:name=com.hivemq.jvm.memory.heap.used", "attribute": { "Value": { "alias": "hivemq.jvm.memory.heap.used.xxx1234", "metric_type": "gauge" } } } }, { "include": { "bean": "metrics:name=com.hivemq.jvm.garbage-collector.G1-Young-Generation.time", "attribute": { "Value": { "alias": "hivemq.jvm.garbage.collector.G1.Young.Generation.time.xxx1234", "metric_type": "gauge" } } } }, { "include": { "bean": "metrics:name=com.hivemq.jvm.garbage-collector.G1-Old-Generation.time", "attribute": { "Value": { "alias": "hivemq.jvm.garbage.collector.G1.Old.Generation.time.xxx1234", "metric_type": "gauge" } } } } ] }, "instances": [ { "host": "%%host%%", "port": "9010" } ] } }'
  5. Install the HiveMQ Platform using the following command:

    helm upgrade broker --install hivemq/hivemq-platform --values hivemq-platform-values.yaml
  6. Log in to your Datadog account and click “Metrics” → ” Explorer” from the left navigation links tab. You will be redirected to the “Graph your data” page. By default, you will see the “system.cpu.user“ metric and its data.
    Start typing "hivemq" in the search box and you should be able to see the list of available HiveMQ metrics.

    image-20240805-145821.png

Create a HiveMQ dashboard in the Datadog UI

  1. In the Datadog UI, click the “New Dashboard” link from the left navigation links tab

    image-20240805-150008.png
  2. Enter the name and select the “New Screenboard” button.

    image-20240805-150112.png

     

  3. Click the “Gear” icon from the top right corner and click the “Import Dashboard JSON” link

    image-20240805-150229.png
  4. Import the attached HiveMQ dashboard JSON , and done:

  5. Check the HiveMQ dashboard to view HiveMQ Metrics.

  6. Uninstall DataDog and HiveMQ.

    helm list --all-namespaces helm uninstall datadog --namespace datadog helm uninstall broker --namespace hivemq helm uninstall oper --namespace hivemq kubectl delete namespace datadog kubectl delete namespace hivemq

 

 

Related content