开启 Nacos 暴露 Prometheus 端点
确认 Nacos 的端点访问正常:http://127.0.0.1:8848/nacos/actuator/prometheus
创建 Service 绑定 Nacos
apiVersion: v1
kind: Service
metadata:
annotations:
prometheus.io/nacos-prometheus-enabled: "true"
prometheus.io/port: "8848"
name: nacos-cluster
namespace: tools
spec:
clusterIP: none
ports:
- name: tcp-8848-8848
port: 8848
protocol: TCP
targetPort: 8848
- name: tcp-9848-9848
port: 9848
protocol: TCP
targetPort: 9848
- name: tcp-9849-9849
port: 9849
protocol: TCP
targetPort: 9849
selector:
app.kubernetes.io/name: nacos
app.kubernetes.io/component: spring-cloud
sessionAffinity: None
type: ClusterIP
加入 Prometheus 监控配置
global:
scrape_interval: 15s
evaluation_interval: 15s
- job_name: "nacos"
metrics_path: '/nacos/actuator/prometheus'
scrape_interval: 5s
kubernetes_sd_configs:
- role: endpoints
relabel_configs:
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_nacos_prometheus_enabled]
action: keep
regex: true
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scheme]
action: replace
target_label: __scheme__
regex: (https?)
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_path]
action: replace
target_label: __metrics_path__
regex: (.+)
- source_labels: [__address__, __meta_kubernetes_service_annotation_prometheus_io_port]
action: replace
target_label: __address__
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
- action: labelmap
regex: __meta_kubernetes_service_label_(.+)
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: namespace
- source_labels: [__meta_kubernetes_service_name]
action: replace
target_label: service_name
确认 Prometheus 的目标 Nacos 节点状态为 UP
本文由 Ivan Dong 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Jun 13, 2023 at 10:07 am