# Module: activemq
# Docs: https://www.elastic.co/guide/en/beats/metricbeat/7.6/metricbeat-module-activemq.html

- module: activemq
  metricsets: ['broker', 'queue', 'topic']
  period: 10s
  hosts: ['localhost:8161']
  path: '/api/jolokia/?ignoreErrors=true&canonicalNaming=false'
  username: admin # default username
  password: admin # default password
  processors:
    - script:
        lang: javascript
        source: >
          function process(event) {
            var broker_memory_broker_pct = event.Get("activemq.broker.memory.broker.pct")
            if (broker_memory_broker_pct != null) {
              event.Put("activemq.broker.memory.broker.pct", broker_memory_broker_pct / 100.0)
            }

            var broker_memory_temp_pct = event.Get("activemq.broker.memory.temp.pct")
            if (broker_memory_temp_pct != null) {
              event.Put("activemq.broker.memory.temp.pct", broker_memory_temp_pct / 100.0)
            }

            var broker_memory_store_pct = event.Get("activemq.broker.memory.store.pct")
            if (broker_memory_store_pct != null) {
              event.Put("activemq.broker.memory.store.pct", broker_memory_store_pct / 100.0)
            }

            var queue_memory_broker_pct = event.Get("activemq.queue.memory.broker.pct")
            if (queue_memory_broker_pct != null) {
              event.Put("activemq.queue.memory.broker.pct", queue_memory_broker_pct / 100.0)
            }

            var topic_memory_broker_pct = event.Get("activemq.topic.memory.broker.pct")
            if (topic_memory_broker_pct != null) {
              event.Put("activemq.topic.memory.broker.pct", topic_memory_broker_pct / 100.0)
            }
          }
