Metricbeat와 Jolokia를 이용한 자바 애플리케이션 모니터링 | Elastic Blog
엔지니어링

Metricbeat와 Jolokia를 이용한 자바 애플리케이션 모니터링

(JVM) . , JMX(Java Management eXtensions) , JMX , JMX Jolokia, Elastic Stack . JMX Jolokia , Metricbeat .

JMX JConsole

JMX . (managed beans) , MBeans , JVM . , , . JMX MBean Server , MBeans, JVM , . MBeans . , JMX API , API . , Jolokia HTTP . JMX JConsole, . JConsole , . , JConsole .

JConsole 환영 화면

, . MBeans .

JConsole 메인 창

, MBeans . java.lang , JVM , . MBean, , , . , . MBeans , . , Tomcat Kafka . JMX, , .

JConsole의 MBean 브라우저

, JConsole . , . , Metricbeat Jolokia .

Metricbeat Jolokia JMX

Metricbeat Elasticsearch , Kibana . , JMX . Jolokia . Jolokia JVM , REST HTTP MBeans , . JVM , Java EE WAR, OSGI Mule . Jolokia , -javaagent . , , . , 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

Jolokia WAR , Java EE . , Tomcat WAR webapps . , . Jolokia . JVM Jolokia , Jolokia JVM JMX . Jolokia JVM , Metricbeat 5.4 Jolokia JMX metricset]7 Metricbeat JMX . Jolokia , JMX Metricbeat . .

: Metricbeat Jolokia ------------------------------------------------------------------ Kafka , , 8778 Jolokia . JConsole MBeans . MBean , , .

JConsole에서 MBean 스레딩

, java.lang:type=Threading MBean , java.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"

Metricbeat 4 . JConsole , 4 . Metricbeat , jolokia.jvm

수집된 jolokia 이벤트 메트릭이 있는 이벤트

10 .

. Metricbeat 6.3, JMX . . , . , .

  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"

6.3 . MBeans , . , Tomcat , .

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

, mbean , mbean

와일드카드를 사용할 때 수집된 Jolokia 메트릭을 가진 이벤트

. Metricbeat 6.4 Jolokia Jolokia Discovery . . Jolokia Discovery UDP , Jolokia . Kubernete Docker autodiscover , 릿 . 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"

릿 , Jolokia , Tomcat . 릿 , . JMX metricset , , filebeat . , Jolokia autodiscover Discuss .19. [