Tomcat

本章节为 Cloud Insight 支持的平台服务的文档的示例。

目前能够想到的章节分为以下几个部分:

  • 支持的性能指标
  • 如何配置 Tomcat 监控
  • 常见的问题

性能指标

  • tomcat.bytes_rcvd
  • tomcat.bytes_sent
  • tomcat.error_count
  • tomcat.max_time
  • tomcat.processing_time
  • tomcat.request_count
  • tomcat.servlet.error_count
  • tomcat.servlet.processing_time
  • tomcat.servlet.request_count
  • tomcat.threads.busy
  • tomcat.threads.count
  • tomcat.threads.max
  • jvm.gc.cms.count
  • jvm.gc.parnew.time
  • jvm.heap_memory
  • jvm.heap_memory_committed
  • jvm.heap_memory_init
  • jvm.heap_memory_max
  • jvm.non_heap_memory
  • jvm.non_heap_memory_committed
  • jvm.non_heap_memory_init
  • jvm.non_heap_memory_max
  • jvm.thread_count
  • jmx.catalina.jsp_count
  • jmx.catalina.jsp_queue_length
  • jmx.catalina.jsp_reload_count
  • jmx.catalina.jsp_unload_count

配置 Tomcat 监控

启动 JMX Remote

OneAPM Cloud Insight Agent 通过 JMX 获取 Tomcat 中的性能指标,所以确保 JMX Remote 是 enabled状态。

由于每个实体最多可以监控 350 个性能指标,所以您需要按照下方的配置方法,修改配置文件来确定自己需要哪些指标。

有关 JMX 采集方法,请查阅 JMX 远程监控

更多信息,请查阅 Apache Tomcat 官方手册

编辑配置文件

编辑配置文件 conf.d/tomcat.yaml,使 Cloud Insight Agent 可以与 Tomcat 通信。

instances:
    - host: localhost
      port: 7199
      user: username
      password: password
      name: tomcat_instance

# List of metrics to be collected by the integration

init_config:
  conf:
    - include:
        type: ThreadPool
        attribute:
          maxThreads:
            alias: tomcat.threads.max
            metric_type: gauge
          currentThreadCount:
            alias: tomcat.threads.count
            metric_type: gauge
          currentThreadsBusy:
            alias: tomcat.threads.busy
            metric_type: gauge
    - include:
        type: GlobalRequestProcessor
        attribute:
          bytesSent:
            alias: tomcat.bytes_sent
            metric_type: counter
          bytesReceived:
            alias: tomcat.bytes_rcvd
            metric_type: counter
          errorCount:
            alias: tomcat.error_count
            metric_type: counter
          requestCount:
            alias: tomcat.request_count
            metric_type: counter
          maxTime:
            alias: tomcat.max_time
            metric_type: gauge
          processingTime:
            alias: tomcat.processing_time
            metric_type: counter
    - include:
        j2eeType: Servlet
        attribute:
          processingTime:
            alias: tomcat.servlet.processing_time
            metric_type: counter
          errorCount:
            alias: tomcat.servlet.error_count
            metric_type: counter
          requestCount:
            alias: tomcat.servlet.request_count
            metric_type: counter
    - include:
        type: Cache
        accessCount:
          alias: tomcat.cache.access_count
          metric_type: counter
        hitsCounts:
          alias: tomcat.cache.hits_count
          metric_type: counter
    - include:
        type: JspMonitor
        jspCount:
          alias: tomcat.jsp.count
          metric_type: counter
        jspReloadCount:
          alias: tomcat.jsp.reload_count
          metric_type: counter

重启 Agent

重启 OneAPM Cloud Insight Agent,使配置生效。

您也可以通过查看 Agent Info 信息,来验证配置是否成功。当出现以下信息,则代表安装成功。

Checks
======

[...]

tomcat
------
  - instance #0 [OK]
  - Collected 8 metrics & 0 events

有关 Agent Info 信息的查看,请访问帮助中心,查看 Cloud Insight Agent 常用操作

常见问题