云原生监控系统Prometheus——Exporter(Elasticsearch监控)

Exporter(Elasticsearch监控)

一、部署 elasticsearch_exporter

  不多bb,直接上配置清单 yaml文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
kind: Pod
apiVersion: v1
metadata:
  name: elastic-j9qoiy-elasticsearch-exporter-598c9b47b8-vnd2p
  generateName: elastic-j9qoiy-elasticsearch-exporter-598c9b47b8-
  namespace: devops-elasticsearch-test
  labels:
    app: elasticsearch-exporter
    pod-template-hash: 598c9b47b8
    release: elastic-j9qoiy
  annotations:
    cni.projectcalico.org/containerID: 7ff05e8f80d31f38d553f592430dfa0a364541bf454da5f628a1a0810d7dd6fd
    cni.projectcalico.org/podIP: 10.233.68.42/32
    cni.projectcalico.org/podIPs: 10.233.68.42/32
    k8s.v1.cni.cncf.io/network-status: |-
      [{
          "name": "k8s-pod-network",
          "ips": [
              "10.233.68.42"
          ],
          "default": true,
          "dns": {}
      }]
    k8s.v1.cni.cncf.io/networks-status: |-
      [{
          "name": "k8s-pod-network",
          "ips": [
              "10.233.68.42"
          ],
          "default": true,
          "dns": {}
      }]
    kubesphere.io/creator: admin
spec:
  volumes:
    - name: kube-api-access-jk9l6
      projected:
        sources:
          - serviceAccountToken:
              expirationSeconds: 3607
              path: token
          - configMap:
              name: kube-root-ca.crt
              items:
                - key: ca.crt
                  path: ca.crt
          - downwardAPI:
              items:
                - path: namespace
                  fieldRef:
                    apiVersion: v1
                    fieldPath: metadata.namespace
        defaultMode: 420
  containers:
    - name: elasticsearch-exporter
      image: 'justwatch/elasticsearch_exporter:1.1.0'
      command:
        - elasticsearch_exporter
        - '--es.uri=http://localhost:9200'
        - '--es.all'
        - '--es.indices'
        - '--es.indices_settings'
        - '--es.shards'
        - '--es.snapshots'
        - '--es.timeout=30s'
        - '--web.listen-address=:9108'
        - '--web.telemetry-path=/metrics'
      ports:
        - name: http
          containerPort: 9108
          protocol: TCP
      resources: {}
      volumeMounts:
        - name: kube-api-access-jk9l6
          readOnly: true
          mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      livenessProbe:
        httpGet:
          path: /healthz
          port: http
          scheme: HTTP
        initialDelaySeconds: 5
        timeoutSeconds: 5
        periodSeconds: 5
        successThreshold: 1
        failureThreshold: 3
      readinessProbe:
        httpGet:
          path: /healthz
          port: http
          scheme: HTTP
        initialDelaySeconds: 1
        timeoutSeconds: 5
        periodSeconds: 5
        successThreshold: 1
        failureThreshold: 3
      lifecycle:
        preStop:
          exec:
            command:
              - /bin/bash
              - '-c'
              - sleep 20
      terminationMessagePath: /dev/termination-log
      terminationMessagePolicy: File
      imagePullPolicy: IfNotPresent
      securityContext:
        capabilities:
          drop:
            - SETPCAP
            - MKNOD
            - AUDIT_WRITE
            - CHOWN
            - NET_RAW
            - DAC_OVERRIDE
            - FOWNER
            - FSETID
            - KILL
            - SETGID
            - SETUID
            - NET_BIND_SERVICE
            - SYS_CHROOT
            - SETFCAP
        readOnlyRootFilesystem: true
  restartPolicy: Always
  terminationGracePeriodSeconds: 30
  dnsPolicy: ClusterFirst
  serviceAccountName: default
  serviceAccount: default
  nodeName: k8s-workernode-2-128
  securityContext:
    runAsUser: 1000
    runAsNonRoot: true
  schedulerName: default-scheduler
  tolerations:
    - key: node.kubernetes.io/not-ready
      operator: Exists
      effect: NoExecute
      tolerationSeconds: 300
    - key: node.kubernetes.io/unreachable
      operator: Exists
      effect: NoExecute
      tolerationSeconds: 300
  priority: 0
  enableServiceLinks: true
  preemptionPolicy: PreemptLowerPriority  

二、与 Prometheus 集成

  与 Prometheus 的配置文件 prometheus.yaml 中的 static_configs 模块内,继续追加配置内容来采集 elasticsearch_exporter 提供的数据。添加的参考配置内容如下: 

1
2
3
4
5
6
7
8
9
10
11
12
13
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: "prometheus"
 
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
 
    static_configs:
      - targets: ["localhost:9090"]
     
  - job_name: "elasticsearch_exporter"
    static_configs:
      - targets: ["192.168.2.121:9108"]
posted @   左扬  阅读(732)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
levels of contents
点击右上角即可分享
微信分享提示