エンジニアリング

JavaアプリケーションをMetricbeatとJolokiaで監視する

JavaJVMJMXJava Management ExtensionsJMXJolokiaElastic StackJMXJMXJolokiaMetricbeat

JMXJConsole

JMXJavaJMXMBeans使MBeansDIJVM使MBeansJMXMBeanMBeanJVMMBeansJMX APIJavaAPIJolokiaJMX APIHTTP

JMX便JConsoleJavaJConsoleJavaJConsole

JConsole welcome screen

MBeans

JConsole main window

MBeansjava.langJVMMBeanMBeansMBeansTomcatKafka使JMX

MBean browser in JConsole

JConsole便使MetricbeatJolokia

JMXMetricbeatJolokia

MetricbeatElasticsearchElasticsearchKibanaJMXJavaJolokia使JolokiaJVMRESTMBeansHTTPJava使JolokiaJVMJava EEWAROSGIMule

JolokiaJava-javaagent使Java使Kafka**KAFKA_OPTS使

export KAFKA_OPTS=-javaagent:/opt/jolokia-jvm-1.5.0-agent.jar=port=8778,host=localhost
./bin/kafka-server-start.sh ./config/server.properties

JolokiaWARJava EETomcatWARwebappsJava使JolokiaJVMJolokiaJolokiaJVM使JolokiaJVMMetricbeat 5.4JolokiaJMX metricset使JMXJolokia使JolokiaJMXMetricbeat

JavaMetricbeatJolokia

KafkaJolokia8778MBeansJConsoleMBean

Threading MBean in JConsole

java.lang:type=Threading MBeanjava.lang:type=Memory使

- module: jolokia
  metricsets: ["jmx"]
  hosts: ["localhost:8778"]
  period: 10s
  namespace: "jvm"
  jmx.mappings:
  - mbean: "java.lang:type=Memory"
    attributes:
    - attr: "HeapMemoryUsage"
        field: "memory.heap"
    - attr: "NonHeapMemoryUsage"
        field: "memory.nonheap"
  - mbean: "java.lang:type=Threading"
    attributes:
    - attr: "ThreadCount"
        field: "thread.count"
    - attr: "DaemonThreadCount"
        field: "thread.daemon"

Metricbeat4JConsole使4Metricbeatjolokia.jvm10

Event with the collected jolokia metrics

Metricbeat 6.3JMX使22

  jmx.mappings:
  - mbean: "java.lang:type=Memory"
    attributes:
    - attr: "HeapMemoryUsage"
        field: "memory.heap"
        event: "memory"
    - attr: "NonHeapMemoryUsage"
        field: "memory.nonheap"
        event: "memory"
  - mbean: "java.lang:type=Threading"
    attributes:
    - attr: "ThreadCount"
      field: "thread.count"
      event: "threads"
    - attr: "DaemonThreadCount"
      field: "thread.daemon"
      event: "threads"

Metricbeat 6.31MBeans1使便Tomcat

  - mbean: "Catalina:name=*,type=ThreadPool"
    attributes:
    - attr: "currentThreadCount"
      field: "thread.count"
    - attr: "maxThreads"
      field: "thread.max"
    - attr: "connectionCount"
      field: "connection.count"

MBeanMBean

Event with the collected Jolokia metrics when using wildcards

JolokiaMetricbeat 6.4JavaJolokia Discovery

Jolokia DiscoveryUDP使JolokiaKubernetesDockerautodiscover使Jolokia Discovery

metricbeat.autodiscover:
  providers:
  - type: jolokia
    templates:
    - condition:
        contains:
          jolokia.agent.version: "1.5.0"
      config:
      - module: "jolokia"
        metricsets: ["jmx"]
        hosts: ["${data.jolokia.url}"]
        namespace: "jvm"
        jmx.mappings: 
        - mbean: "java.lang:type=Threading"
          attributes:
          - attr: "ThreadCount"
            field: "thread.count"
    - condition:
        contains:
          jolokia.server.product: "tomcat"
      config:
      - module: "jolokia"
        metricsets: ["jmx"]
        hosts: ["${data.jolokia.url}"]
        namespace: "jvm"
        jmx.mappings:
        - mbean: "Catalina:name=*,type=ThreadPool"
          attributes:
          - attr: "currentThreadCount"
            field: "thread.count"

21Jolokia1Tomcat使JMX metricset使使filebeat使Jolokia moduleautodiscover.