Prometheus Agent 安装手册

    Prometheus官方

    • 下载对应操作系统的最新release版本
    • 运行node_exporter
    • 查看默认提供的9100端口,能看到所暴露的指标数据
    • 下载对应操作系统的最新release版本
    • 需要在被监控数据库中新建监控用户并授权
      1. GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';
    • 新建my.cnf配置文件
    • 运行exporter
      1. nohub ./mysqld_exporter --config.my-cnf="my.cnf" > app.log 2>&1 &
    • 查看提供的9104端口,能看到所暴露的指标数据

    官方并没有提供Redis的exporter,可使用较流行的redis_exporter

    • 运行redis_exporter
    • 查看提供的9121端口,能看到所暴露的指标数据

    tomcat war 部署方式监控,这种方式直接在tomcat里面加上exporter的jar包修改catalina.sh,启动并暴露指标
    1、新建config.yaml文件

    1. lowercaseOutputLabelNames: true
    2. lowercaseOutputName: true
    3. rules:
    4. - pattern: 'Catalina<type=GlobalRequestProcessor, name=\"(\w+-\w+)-(\d+)\"><>(\w+):'
    5. name: tomcat_$3_total
    6. labels:
    7. port: "$2"
    8. protocol: "$1"
    9. type: COUNTER
    10. - pattern: 'Catalina<j2eeType=Servlet, WebModule=//([-a-zA-Z0-9+&@#/%?=~_|!:.,;]*[-a-zA-Z0-9+&@#/%=~_|]), name=([-a-zA-Z0-9+/$%~_-|!.]*), J2EEApplication=none, J2EEServer=none><>(requestCount|maxTime|processingTime|errorCount):'
    11. name: tomcat_servlet_$3_total
    12. labels:
    13. servlet: "$2"
    14. help: Tomcat servlet $3 total
    15. type: COUNTER
    16. - pattern: 'Catalina<type=ThreadPool, name="(\w+-\w+)-(\d+)"><>(currentThreadCount|currentThreadsBusy|keepAliveCount|pollerThreadCount|connectionCount):'
    17. name: tomcat_threadpool_$3
    18. port: "$2"
    19. protocol: "$1"
    20. help: Tomcat threadpool $3
    21. type: GAUGE
    22. - pattern: 'Catalina<type=Manager, host=([-a-zA-Z0-9+&@#/%?=~_|!:.,;]*[-a-zA-Z0-9+&@#/%=~_|]), context=([-a-zA-Z0-9+/$%~_-|!.]*)><>(processingTime|sessionCounter|rejectedSessions|expiredSessions):'
    23. name: tomcat_session_$3_total
    24. labels:
    25. context: "$2"
    26. host: "$1"

    4、最后startup.sh启动tomcat,可在提供的9151端口上查到tomcat和jmx的相关指标