Versions Compared

Key

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

This artical explains how to expose HiveMQ JMX metrics in DataDog using Kubernetes

\uD83D\uDCD8 Pre-requisites

  1. Helm version v3+

  2. Running Kubernetes cluster version 1.18.0 or higher

  3. kubectl lastest version

\uD83D\uDCD8 Instructions

  1. Configure the DataDog agent using the Helm chart

    1. Add Datadog helm repository

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

      1. Code Block
        languageyaml
        logLevel: DEBUG
        targetSystem: "linux"
        datadog:
          apiKey: <your api key from your account>
          
          #Logs configurations
          logs:
            enabled: true
            containerCollectAll: true
            containerCollectUsingFiles: true
          
          #Plesse 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

...

      1. 
        
        clusterAgent:

...

      1. 
          rbac:

...

      1. 
            

...

      1. create: true  
        
        

...

      1. # setting to read JMX metrics from HiveMQ
        agents:
          image:
            tagSuffix: "jmx"
    1. install Datadog agent using Helm

      1. Code Block
        languagebash
        kubectl create ns <namespace>
        helm install -f datadog-values.yaml <release name> datadog/datadog 
    2. Verify installation and check the agent pod’s status

      1. Code Block
        languagebash
        kubectl get pods
      2. Also, check the agent’s

...

      1. logs to confirm.

  1. Install HiveMQ using Operator

    1. Configure hivemq-values.yaml based on your requirement and then add podAnnotations for Datadog to auto-discover HiveMQ metrics and logs. Check here for details.
      Please find below a minimalist config example of hivemq-values.yaml

      1. Code Block
        languageyaml
        
        hivemq:
          image: hivemq/hivemq4:k8s-4.7.5
          imagePullPolicy: Always
          cpu: 8
          memory: 8Gi
          nodeCount: "3"
        
        
          podAnnotations:
            ad.datadoghq.com/hivemq.

...

      1. checks: '

...

      1. {
              \"hivemq\"

...

      1. : {
                

...

      1. \"init_

...

      1. config\": 

...

      1. {
                  \"is_jmx\": true,
                  \"collect_default_metrics\": true

...

      1. ,
                  },
                

...

      1. \"instances\": 

...

      1. [
                  {
                    \"host\": \"%%host%%\",
                    \"port\": \"9010\"
                  }

...

      1. 
                ]
              }
          

...

      1.   }'
          
          ports:
            - name: "mqtt"
              port: 1883
              expose: true
              patch:
               - '[{"op":"add","path":"/spec/type","value":"LoadBalancer"}]'
            - name: "cc"
              port: 8080
              expose: true
              patch:
                - '[{"op":"add","path":"/spec/sessionAffinity","value":"ClientIP"}]'
            
        operator:
          admissionWebhooks:
            # Enable the admission hook
            enabled: false
        
        monitoring:
          enabled: false
          dedicated: false
        

        If you would like to add more metrics to available HiveMQ metrics, please refer the following example.

        Code Block
        hivemq:
          podAnnotations:
            ad.datadoghq.com/hivemq.checks: '{
              \"hivemq\": {
                \"init_config\": {
                  \"is_jmx\": true,
                  \"collect_default_metrics\": true,
        

...

      1.           \"conf\": [
                    {
                      \"include\": {
                        \"bean\": \"metrics:name=com.hivemq.jvm.memory.heap.max\",
                        \"attribute\": {
                          \"Value\": {
                            \"alias\": \"hivemq.jvm.memory.heap.max\",
                            \"metric_type\": \"gauge\"
                          }
                        }
                      }
                    },
                    {
                      \"include\": {
                        \"bean\": \"metrics:name=com.hivemq.jvm.memory.heap.used\",
                        \"attribute\": {
                          \"Value\": {
                            \"alias\": \"hivemq.jvm.memory.heap.used\",
                            \"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\",
                            \"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\",
                            \"metric_type\": \"gauge\"
                          }
                        }
                      }
                    }
                  ]
                },
                \"instances\": [
                  {
                    \"host\": \"%%host%%\",
                    \"port\": \"9010\"
                  }
                ]
              }
            }'
    1. Install HiveMQ using the following command

      1. Code Block
        languagebash
        helm upgrade --install -f hivemq-values.yaml <release name> hivemq/hivemq-operator
    2. verify installation

      1. Code Block
        languagebash
        kubectl get pods
    3. Login to your Datadog account and click “Metrics” =>” Explorer” from the left navigation links. You will be redirected to the “Graph your data” page. By default, you will see “system.cpu.user“ metrics and

...

    1. their data.
      Type "hivemq" in the search box and you should be able to see the list of available metrics.

    2. Image Modified

...

    1. Create HiveMQ dashboard:

      1. Click the “New Dashboard” link from the left navigation links.

      2. enter the name and select the “New Screenboard” button.

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

        1. Image Added
      4. Import the attached HiveMq dashboard JSON and done

      5. Image Added
      6. Check the HiveMQ dashboard to view HiveMQ Metrics.

        Image Added
  1. Uninstall DataDog and HiveMQ

    1. Code Block
      languagebash
      helm list
      helm uninstall <datadog release name>
      helm uninstall <hivemq release name>
      kubectl delete ns <namespce>