kubesphere -prometheus 自动监控jvm
在你的service中添加这个注解,他就能自动识别
annotations:
prometheus.io/jvm: 'true'
prometheus.io/port: '19999'
大概的prometheus规则就是匹配所有的集群 service中 annotations包含着两条规则,然后他截取 port作为端口
你jmx端口是什么,那个port就配置成什么
prometheus.yaml
- job_name: jmx
scrape_interval: 5s
kubernetes_sd_configs:
- role: endpoints
relabel_configs:
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_jvm]
action: keep
regex: true
- source_labels: [__address__, __meta_kubernetes_service_annotation_prometheus_io_port]
action: replace
target_label: __address__
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
- source_labels: [__meta_kubernetes_service_name]
action: replace
regex: (.+)
target_label: application
replacement: $1
- source_labels: [__meta_kubernetes_namespace]
action: replace
regex: (.+)
target_label: namespace
- source_labels: [__meta_kubernetes_pod_name]
action: replace
regex: (.+)
target_label: pod
replacement: $1
- action: labelmap
regex: __meta_kubernetes_service_label_(.+)