Prometheus监控ElasticSearch

这里只是对prometheus监控ES的配置过程做个记录,方便以后查阅。

1.安装elasticsearch-prometheus-exporter

1
[admin@haifly-bj-es2 ~]$ ./elasticsearch-6.5.3/bin/elasticsearch-plugin install -b https://github.com/vvanholl/elasticsearch-prometheus-exporter/releases/download/6.5.3.0/prometheus-exporter-6.5.3.0.zip

输出如下:

1
2
3
4
5
6
7
8
9
10
11
-> Downloading https://github.com/vvanholl/elasticsearch-prometheus-exporter/releases/download/6.5.3.0/prometheus-exporter-6.5.3.0.zip
[=================================================] 100%  
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: plugin requires additional permissions @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.lang.RuntimePermission accessClassInPackage.sun.misc
* java.lang.RuntimePermission accessDeclaredMembers
* java.lang.reflect.ReflectPermission suppressAccessChecks
See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.
-> Installed prometheus-exporter

安装完别忘了重启es

2.安装并启动export(可选)

下载地址: https://github.com/justwatchcom/elasticsearch_exporter/releases

1
2
3
[admin@haifly-bj-es2 ~]$ tar xf elasticsearch_exporter-1.1.0rc1.linux-amd64.tar.gz
[admin@haifly-bj-es2 ~]$ mv -f elasticsearch_exporter-1.1.0rc1 elasticsearch_exporter
[admin@haifly-bj-es2 ~]$ /work/admin/elasticsearch_exporter/elasticsearch_exporter --web.listen-address=":9114" --es.uri="http://192.168.6.217:9200" --es.all

3.prometheus配置

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
- job_name: 'es'
static_configs:
- targets: ['192.168.7.206:9100']
labels: {cluster: 'product',type: 'basic',env: 'es',job: 'es1',export: 'es'}
- targets: ['192.168.7.206:9114']
labels: {cluster: 'product',type: 'basic',env: 'es',job: 'es1',export: 'elasticsearch_exporter'}
- targets: ['192.168.6.217:9100']
labels: {cluster: 'product',type: 'basic',env: 'es',job: 'es2',export: 'es'}
- targets: ['192.168.6.217:9114']
labels: {cluster: 'product',type: 'basic',env: 'es',job: 'es2',export: 'elasticsearch_exporter'}
- targets: ['192.168.3.96:9100']
labels: {cluster: 'product',type: 'basic',env: 'es',job: 'es3',export: 'es'}
- targets: ['192.168.3.96:9114']
labels: {cluster: 'product',type: 'basic',env: 'es',job: 'es3',export: 'elasticsearch_exporter'}

- job_name: 'elasticsearch'
metrics_path: "/_prometheus/metrics"
static_configs:
- targets: ['192.168.7.206:9200']
labels: {cluster: 'product',type: 'middle',env: 'es',job: 'es1',export: 'elasticsearch'}
- targets: ['192.168.6.217:9200']
labels: {cluster: 'product',type: 'middle',env: 'es',job: 'es2',export: 'elasticsearch'}
- targets: ['192.168.3.96:9200']
labels: {cluster: 'product',type: 'middle',env: 'es',job: 'es3',export: 'elasticsearch'}
- targets: ['192.168.7.210:9200']
labels: {cluster: 'product',type: 'middle',env: 'es-work',job: 'es-work',export: 'elasticsearch'}

重启prometheus

如果开启了api管理功能,可以如下方式热加载配置

1
curl -X POST http://127.0.0.1:9090/-/reload

4.grafana出图

推荐使用4358、266、2322

效果如下

图片1

上图面板经过一定的修改可能略有不同,仅供参考

-------------本文结束感谢您的阅读-------------