zoukankan      html  css  js  c++  java
  • 6.监控elasticsearch集群

    prometheus监控es,同样采用exporter的方案。

    • 项目地址:
      • elasticsearch_exporter:https://github.com/justwatchcom/elasticsearch_exporter

    1、安装部署

    现有es三节点的集群,环境大概如下:

    主机 组件
    192.168.75.11 prometheus
    192.168.75.21 es,kibana,nginx

    接着分别在如上三台主机上进行如下配置:

    wget https://github.com/justwatchcom/elasticsearch_exporter/releases/download/v1.1.0/elasticsearch_exporter-1.1.0.linux-amd64.tar.gz
    tar -zxv -f elasticsearch_exporter-1.1.0.linux-amd64.tar.gz
    mv elasticsearch_exporter-1.1.0.linux-amd64 /usr/local/elasticsearch_exporter
    

    创建用户等

    groupadd prometheus
    useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus
    chown -R prometheus.prometheus /usr/local/elasticsearch_exporter
    

    启动监控客户端:

    nohup ./elasticsearch_exporter --web.listen-address ":9308"  --es.uri http://192.168.75.21:9200 &
    

    使用systemd管理:

    cat /lib/systemd/system/es_exporter.service
    
    [Unit]
    Description=The es_exporter
    After=network.target
    
    [Service]
    Type=simple
    User=prometheus
    ExecStart=/usr/local/elasticsearch_exporter/elasticsearch_exporter --web.listen-address ":9308" --es.uri http://192.168.75.21:9200
    Restart=on-failure
    
    [Install]
    WantedBy=multi-user.target
    

    启动:

    systemctl daemon-reload
    systemctl start es_exporter
    systemctl enable es_exporter
    

    查看metrics:

    curl 127.0.0.1:9308/metrics
    

    2,配置 prometheus.yml 添加监控目标

    vim /usr/local/prometheus/prometheus.yml
    
      - job_name: 'elasticsearch'
        scrape_interval: 60s
        scrape_timeout:  30s
        metrics_path: "/metrics"
        static_configs:
        - targets: ['192.168.75.21:9308']
          labels:
           service: elasticsearch
    

    重启服务。

    systemctl restart prometheus
    

    或者通过命令热加载:

    curl  -XPOST localhost:9090/-/reload
    

    5,配置 Grafana 的模板

    模板通过json文件进行导入,文件就在解压的包内。

    参考地址:https://shenshengkun.github.io/posts/550bdf86.html

    或者通过如下ID进行导入:2322以及其他。

    6,开启认证的启动方式

    如果es开启了认证,那么启动的时候需要将用户名密码加载进去:

    elasticsearch_exporter --web.listen-address ":9308"  --es.uri http://username:password@192.168.75.21:9200 & 
    

    其中使用的是monitoring的用户密码。

    当然,除去这种命令行的启动方式之外,还可以像上边一样,基于systemd进行管理,只需将认证的参数信息写入到如下内容当中:

    参考网址:https://github.com/justwatchcom/elasticsearch_exporter

    cat /etc/default/elasticsearch_exporter
    
    [Unit]
    Description=The es_exporter
    After=network.target
    
    [Service]
    Type=simple
    User=prometheus
    ExecStart=/usr/local/elasticsearch_exporter/elasticsearch_exporter --web.listen-address ":9308" --es.uri=http://username:password@192.168.75.21:9200
    Restart=on-failure
    
    [Install]
    WantedBy=multi-user.target
    

  • 相关阅读:
    windows Visual Studio 2017 编译 HEVC cmake-3.8.1-win64-x64.msi 下载
    DirectShow
    IDA反汇编学习
    .NET dnSpy 程序集编辑器,反编译器和调试器
    Win7如何自定义鼠标右键菜单 添加新建PowerPoint文档
    Win7如何自定义鼠标右键菜单 添加新建EXCEL文档
    推荐电视剧 大秦帝国之裂变 2008
    推荐电视剧 大明王朝1566 2007
    C#如何生成release版本的程序,生成debug版本的程序
    Solidworks安装完成提示failed to load slderresu.dll怎么办
  • 原文地址:https://www.cnblogs.com/sanduzxcvbnm/p/13098348.html
Copyright © 2011-2022 走看看