This article explains how to expose HiveMQ JMX metrics to DataDog using Kubernetes.
\uD83D\uDCD8 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
\uD83D\uDCD8 Instructions
Install and configure a DataDog agent
Add Datadog helm repository:
helm repo add datadog https://helm.datadoghq.com helm repo update datadog
Create
datadog-values.yaml
. For full values check here.
Please refer to following the example ofdatadog-values.yaml
: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"
Optionally, create a dedicated namespace for the Datadog Agent. Further in this article, we consider the datadog namespace.
kubectl create namespace datadog
Install Datadog agent using Helm:
helm upgrade datadog --install datadog/datadog --values datadog-values.yaml --namespace datadog
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
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
Optionally, create a dedicated namespace for the HiveMQ. Further in this article, we assume the
hivemq
namespace.kubectl create namespace hivemq
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
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 – https://docs.datadoghq.com/containers/kubernetes/integrations/?tab=annotations.
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" } ] } }'
Install the HiveMQ Platform using the following command:
helm upgrade broker --install hivemq/hivemq-platform --values hivemq-platform-values.yaml
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.
Create a HiveMQ dashboard in the Datadog UI
In the Datadog UI, click the “New Dashboard” link from the left navigation links tab
Enter the name and select the “New Screenboard” button.
Click the “Gear” icon from the top right corner and click the “Import Dashboard JSON” link
Import the attached HiveMq dashboard JSON and done:
Check the HiveMQ dashboard to view HiveMQ Metrics.
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