系统相关
首页 > 系统相关> > CentOS-Docker搭建远程监控服务器指标(已更新)

CentOS-Docker搭建远程监控服务器指标(已更新)

作者:互联网

注:远程监控服务器指标,可查看、CPU、内存、网络信息等,搭建依赖Docker环境,可参考:yum安装Docker环境

服务端:Grafana(可视化展示) + Prometheus(数据源,配置客户端信息)

CentOS客户端导出机器指标:node_exporter

Windows客户端导出机器指标:windows_exporter

使用grafana-dashboards说明

CentOS仪表盘:https://grafana.com/grafana/dashboards/8919
Windows仪表盘:https://grafana.com/grafana/dashboards/10467

下载相关镜像

$ docker pull prom/prometheus
$ docker pull prom/node-exporter
$ docker pull grafana/grafana

创建相关配置

配置数据源文件(样例仅监控本机,如需监控其他机器修改-targets即可,如: ['localhost:9100','192.168.1.100:9100','192.168.1.200:9182'])

$ vim /home/prometheus.yml

global:
  scrape_interval:     15s # By default, scrape targets every 15 seconds.

  # Attach these labels to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
    monitor: 'server-monitor'

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=

    # Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 5s

    static_configs:
      - targets: ['localhost:9090']
        labels:
          instance: prometheus
      - targets: ['localhost:9100']
        labels:
          #nodename: test
          instance: local

 

运行镜像

1.客户端导出机器指标(本实例监控本机)

$ docker run --restart=unless-stopped -d --name=node-exporter -p 9100:9100 -v /etc/localtime:/etc/localtime prom/node-exporter

2.可视化展示grafana服务

$ docker run --restart=unless-stopped -d --name=grafana -p 3000:3000 grafana/grafana

3.数据源prometheus服务

$ docker run --restart=unless-stopped -d --name=prometheus -p 9090:9090 -v /home/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus

配置grafana服务

1.访问:http://ip:3000 默认用户名/密码:admin/admin

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

2.配置数据源-prometheus,填写http地址后保存(Save & Test)

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

3.导入仪表盘

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

4.填写仪表盘id(Centos:8919,Windows:2129)

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

5.仪表盘预览,点击保存即可

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

CentOS监控最终展示效果

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

Windows监控最终展示效果

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

 

标签:CentOS,--,scrape,grafana,prometheus,9100,服务器,Docker,docker
来源: https://blog.51cto.com/u_15187745/2747193