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 /starit-buckyshop-stat.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<type=(\w+), name=(\w+)><>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