pmm1监控es

发布时间 2023-06-27 11:35:24作者: slnngk

环境:

OS:Centos 7

pmm server:版本1

 

##########################################被监控ES机器安装###########################

1.查看es版本

[root@localhost ~]# curl -u elastic:XXXX http://192.168.1.136:19200/?pretty
{
  "name" : "pZWD9hr",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "D90sryqyTduCUoN6fEJShQ",
  "version" : {
    "number" : "6.5.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "816e6f6",
    "build_date" : "2018-11-09T18:58:36.352602Z",
    "build_snapshot" : false,
    "lucene_version" : "7.5.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

 

2.下载安装包
https://prometheus.io/docs/instrumenting/exporters/
找到Elasticsearch exporter
进入链接进行下载
我这里下载的是:
elasticsearch_exporter-1.4.0.linux-amd64.tar.gz

 

3.解压安装
[root@localhost soft]# tar -xvf elasticsearch_exporter-1.4.0.linux-amd64.tar.gz
[root@localhost soft]# mv elasticsearch_exporter-1.4.0.linux-amd64 /opt/

 

4.查看使用语法

[root@localhost elasticsearch_exporter-1.4.0.linux-amd64]# ./elasticsearch_exporter --help
usage: elasticsearch_exporter [<flags>]

Flags:
  -h, --help                    Show context-sensitive help (also try --help-long and --help-man).
      --collector.cluster-info  Enable the cluster-info collector (default: enabled).
      --web.listen-address=":9114"  
                                Address to listen on for web interface and telemetry.
      --web.telemetry-path="/metrics"  
                                Path under which to expose metrics.
      --es.uri="http://localhost:9200"  
                                HTTP API address of an Elasticsearch node.
      --es.timeout=5s           Timeout for trying to get stats from Elasticsearch.
      --es.all                  Export stats for all nodes in the cluster. If used, this flag will override the flag
                                es.node.
      --es.node="_local"        Node's name of which metrics should be exposed.
      --es.indices              Export stats for indices in the cluster.
      --es.indices_settings     Export stats for settings of all indices of the cluster.
      --es.indices_mappings     Export stats for mappings of all indices of the cluster.
      --es.aliases              Export informational alias metrics.
      --es.cluster_settings     Export stats for cluster settings.
      --es.shards               Export stats for shards in the cluster (implies --es.indices).
      --es.snapshots            Export stats for the cluster snapshots.
      --es.slm                  Export stats for SLM snapshots.
      --es.clusterinfo.interval=5m  
                                Cluster info update interval for the cluster label
      --es.ca=""                Path to PEM file that contains trusted Certificate Authorities for the Elasticsearch
                                connection.
      --es.client-private-key=""  
                                Path to PEM file that contains the private key for client auth when connecting to
                                Elasticsearch.
      --es.client-cert=""       Path to PEM file that contains the corresponding cert for the private key to connect
                                to Elasticsearch.
      --es.ssl-skip-verify      Skip SSL verification when connecting to Elasticsearch.
      --log.level="info"        Sets the loglevel. Valid levels are debug, info, warn, error
      --log.format="logfmt"     Sets the log format. Valid formats are json and logfmt
      --log.output="stdout"     Sets the log output. Valid outputs are stdout and stderr
      --version                 Show application version.

 

5.启动客户端
[root@localhost elasticsearch_exporter-1.4.0.linux-amd64]#nohup ./elasticsearch_exporter --es.uri http://elastic:XXXX@192.168.1.136:19200> exporter.log 2>&1 &

 

6.浏览器打开,查看监控指标
exporter 监控使用的IP:的端口,默认本机的9114
# 浏览器打开,查看监控指标,监控端口9114
http://192.168.1.136:9114/metrics

 

#####################pmm server操作########################

1.登录容器修改配置
docker exec -it pmm-server /bin/bash

[root@a5914a0f9617 opt]# vi /etc/prometheus.yml

添加如下配置

- job_name: 'es-136'
  static_configs:
  - targets: 
    - 192.168.1.136:9114

 

2.重启容器(容器外执行)
docker restart pmm-server

 

3.Grafana面板配置
#下载 grafana 仪表盘
https://github.com/justwatchcom/elasticsearch_exporter/blob/master/examples/grafana/dashboard.json
或者是直接拷贝文件的内容

 

4.导入模板