Prometheus / 监控平台 / 系统运维

Prometheus监控ES集群

浅时光博客 · 12月27日 · 2021年 · 621 字 · 约 3 分钟 7w次已读
Elasticsearch告警规则
价格:免费
  • 终身VIP购买价格 : 免费
信息ES告警规则
文件YAML
最近更新2021年12月27日
  • 登录购买
  • 解压密码
  • AI 文章摘要 时光AI(本站开发) 原文链接:https://dqzboy.com
    文章来源(Source):浅时光博客

    一、安装exporter


    • elasticsearch_exporter与ES集群是分开独立的,不需要对原有的ES集群(可能有很多个)做任何修改,不需要重启,只要能访问es集群即可。可以单独部署在一台服务器上
    [root@prod-es-master01 ~]# mkdir /opt/soft/
    [root@prod-es-master01 ~]# cd /opt/soft/
    [root@prod-es-master01 soft]# wget https://github.com/prometheus-community/elasticsearch_exporter/releases/download/v1.3.0/elasticsearch_exporter-1.3.0.linux-amd64.tar.gz
    
    [root@prod-es-master01 soft]# tar -zxvf elasticsearch_exporter-1.3.0.linux-amd64.tar.gz -C /usr/local/
    [root@prod-es-master01 soft]# cd /usr/local/
    [root@prod-es-master01 local]# mv elasticsearch_exporter-1.3.0.linux-amd64 elasticsearch_exporter

    二、启动exporter


    1、常用参数解释

    参数选项参数说明
    –es.uri 默认http://localhost:9200,连接到的Elasticsearch节点的地址(主机和端口)
    –es.all  默认flase,如果为true,则查询群集中所有节点的统计信息,而不仅仅是查询我们连接到的节点
    –es.cluster_settings 默认flase,如果为true,请在统计信息中查询集群设置
    –es.indices默认flase,如果为true,则查询统计信息以获取集群中的所有索引
    –es.indices_settings默认flase,如果为true,则查询集群中所有索引的设置统计信息
    –es.shards默认flase,如果为true,则查询集群中所有索引的统计信息,包括分片级统计信息
    –es.snapshots默认flase,如果为true,则查询集群快照的统计信息

    2、Systemd管理

    vim /lib/systemd/system/es_exporter.service
    
    [Unit]
    Description=The es_exporter
    After=network.target
    
    [Service]
    Type=simple
    ExecStart=/usr/local/elasticsearch_exporter/elasticsearch_exporter --es.all --es.indices --es.cluster_settings --es.indices_settings --es.shards --es.snapshots  --es.uri http://elastic:T6dc7aY1mLTP9NtK3sX4@192.168.66.86:9200
    Restart=on-failure
    
    [Install]
    WantedBy=multi-user.target

    注意:es集群开启了x-pack验证则需要使用用户名和密码,反之不需要

    3、启动服务

    systemctl daemon-reload
    systemctl start es_exporter
    systemctl enable es_exporter

    4、检查数据

    • 现在通过curl去访问9114端口去检查数据
    [root@prod-es-master01 ~]# curl 127.0.0.1:9114/metrics
    prom+es01

    三、配置监控Job


    1、配置prometheus监控

    ~]# vim /usr/local/prometheus/prometheus.yml
      ## elasticsearch Cluster
      - job_name: "elasticsearch Cluster"
        scrape_interval: 60s
        scrape_timeout: 60s
        static_configs:
        - targets: ['192.168.66.86:9114']
        relabel_configs:
          - source_labels: [__address__]
            regex: '(.*)\:9114'
            target_label: 'nodeip'
            replacement: '$1'
          - source_labels: [__address__]
            regex: '(.*)\:9114'
            target_label: 'hostname'
            replacement: '$1'
    
    #重载prometheus配置
    ~]# promtool check config /usr/local/prometheus/prometheus.yml
    ~]# curl -X POST http://127.0.0.1:9090/-/reload
    • 检查Targets
    prom+es02

    2、添加Grafana监控面板

    prom+es03
    • 节点跳转链接URL修改
    prom+es04
    • 格式:URL:https://你的Grafana访问域名/d/5b64379ae97d471bb733c16fa5494f98/elasticsearch-node-stats?var-cluster=$cluster&var-name=${__cell}
    prom+es05

    四、告警规则创建


    ~]# vim /usr/local/prometheus/rules/alerts_es.yml
    prometheus
    3 条回应

    必须 注册 为本站用户, 登录 后才可以发表评论!

    1. Msr.wang广东·深圳2024-2-25 · 11:36

      公众号是什么

    2. lc_zz广东·深圳2022-4-28 · 10:16

      博主。你好!关注了公众号,获取到了告警文件,没有找到解压密码,请问下解压密码是啥?

      • 浅时光博客2022-4-28 · 10:17

        解压密码:www.dqzboy.com