kubernetes pod 级别的 jvm 监控

1.下包

wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.13.0/jmx_prometheus_javaagent-0.13.0.jar

2.配置java启动命令

-javaagent:/data/logs/jmx-exporter/jmx_prometheus_javaagent-0.13.0.jar=33334:/data/logs/jmx-exporter/config.yaml
/data/logs/jmx-exporter/jmx_prometheus_javaagent-0.13.0.jar:jar包路径
33334:监控端口
/data/logs/jmx-exporter/config.yaml:配置文件

java -javaagent:/data/logs/jmx-exporter/jmx_prometheus_javaagent-0.13.0.jar=33334:/data/logs/jmx-exporter/config.yaml -jar -server -XX:MetaspaceSize=256M -XX:MaxMetaspaceSize=256M -Xms2048M -Xmx2048M -Xmn256M -Xss512K -XX:SurvivorRatio=4 -XX:+UseConcMarkSweepGC /********.jar --spring.profiles.active=newsuper

3.配置jmx配置文件(发现所有监控项)

cat /mnt/jmx-exporter/config.yaml 
---
startDelaySeconds: 0
lowercaseOutputName: false
lowercaseOutputLabelNames: false
whitelistObjectNames: ["org.apache.cassandra.metrics:*"]
blacklistObjectNames: ["org.apache.cassandra.metrics:type=ColumnFamily,*"]
rules:
  - pattern: 'org.apache.cassandra.metrics<>Value: (\d+)'
    name: cassandra_$1_$2
    value: $3
    valueFactor: 0.001
    labels: {}
    help: "Cassandra metric $1 $2"
    type: GAUGE
    attrNameSnakeCase: false

4.配置prometheus

cat ~/kube-prometheus-0.5.0/manifests/prometheus-additional.yaml 
- job_name: 'jmx-exporter'
  kubernetes_sd_configs:
    - role: pod
#  metrics_path: /metrics
  relabel_configs:
    - source_labels: [__address__]
      action: keep
      regex: '(.*):(.*)'
    - source_labels: [__meta_kubernetes_pod_container_port_number]
      action: keep
      regex: '33334'
    - source_labels: [__meta_kubernetes_namespace]
      action: replace
      target_label: kubernetes_namespace
    - source_labels: [__meta_kubernetes_pod_name]
      action: replace
      target_label: kubernetes_pod_name
  scheme: http

5.配置deployment

deployment增加jmx的container

6.导入grafana

1996
kubernetes pod 级别的 jvm 监控_第1张图片

你可能感兴趣的:(kubernetes,jvm,监控,prometheus)