• prometheus 监控jvm


    1.下载jar包

    [root@k8s-matser01 jmx]# wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.13.0/jmx_prometheus_javaagent-0.13.0.jar
    
    [root@k8s-matser01 jmx]# cat prometheus-jmx-config.yaml 
    ---
    ssl: false
    lowercaseOutputName: false
    lowercaseOutputLabelNames: false
    

    2.编辑基础镜像

    [root@k8s-matser01 jmx]# cat Dockerfile 
    FROM tomcat:jdk8-openjdk-slim
    ADD prometheus-jmx-config.yaml /prometheus-jmx-config.yaml
    ADD jmx_prometheus_javaagent-0.13.0.jar /jmx_prometheus_javaagent-0.13.0.jar
    

    3.生成镜像

    [root@k8s-matser01 jmx]# docker build -t tomcat:jdk8 .
    

    4.编译yaml文件

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: tomcat
    spec:
      replicas: 3
      selector:
        matchLabels:
          app: tomcat
      template:
        metadata:
          labels:
            app: tomcat
        spec:
          containers:
          - name: tomcat
            image: tomcat:jdk8
            env:
            - name: JAVA_OPTS
              value: "-javaagent:/jmx_prometheus_javaagent-0.13.0.jar=9090:/prometheus-jmx-config.yaml"
    
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: tomcat
      labels:
        app: tomcat
    spec:
      type: ClusterIP
      ports:
      - port: 8080
        protocol: TCP
        name: http
      - port: 9090
        protocol: TCP
        name: jmx-metrics
      selector:
        app: tomcat
    

    4.监控增加jvm监控规则

        - job_name: jvm
          scrape_interval: 5s
          kubernetes_sd_configs:
          - role: endpoints
          relabel_configs:
          - action: keep
            source_labels:
            - __meta_kubernetes_service_label_app
            regex: tomcat
          - action: keep
            source_labels:
            - __meta_kubernetes_endpoint_port_name
            regex: jmx-metrics
    

  • 相关阅读:
    下拉列表实现模糊匹配选择
    Java读取修改Properties文件
    idea2018.2.4的安装激活与热部署插件JRebel的激活方法
    request.getScheme() 使用方法
    Navicat连接mysql8.0.1版本出现1251--Client does not support authentication protocol requested by server的解决
    javascript
    CSS第二节
    HTML+CSS
    mysql
    ubuntu常见错误
  • 原文地址:https://www.cnblogs.com/Applogize/p/15568697.html
Copyright © 2020-2023  润新知