Prometheus 监控Linux系统(二)

node_exporter 收集器监控linux系统;

下载地址:wget https//github.com/prometheus/node_exporter/releases/download/v1.2.0/node_exporter-1.2.0.linux-amd64.tar.gz

[root@Prometheus tools]# tar -zxvf node_exporter-0.18.1.linux-amd64.tar.gz -C /opt/       #解压tar包
[root@Prometheus opt]# mv node_exporter-0.18.1.linux-amd64/ /usr/local/node_exporter              #修改文件夹名称
[root@Prometheus ]# cd /usr/local/node_exporter/
[root@Prometheus /]# /usr/local/node_exporter/node_exporter &     #启动node_exporter,默认端口9100;

[root@Prometheus /]# ps -ef|grep node
root     17404  2918  0 13:58 pts/2    00:00:00 /usr/local/node_exporter/node_exporter
root     17423  2918  0 13:58 pts/2    00:00:00 grep --color=auto node

node_exporter常用启动参数:

# 收集文件系统,忽略哪些不搜集
--collector.filesystem.ignored-mount-points="^/(dev|proc|sys|var/lib/docker/.+)($|/)"  
# 管理的系统服务
--collector.systemd.unit-whitelist=".+"
# 指定监听端口 默认9100
--web.listen-address=":9100"

注册node_exporter服务

[Unit]
Description=https://prometheus.io

[Service]
Restart=on-failure
ExecStart=/usr/local/node_exporter/node_exporter --conllector.systemd --conllector.systemd.unit-whitelist=(docker|kubelet|kube-proxy|flanneld).service

[Install]
WantedBy=multi-user.target


启动node_exporter服务

systemctl daemon-reload
systemctl restart node_exporter

修改Prometheus.yml配置文件,添加Job

# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# 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=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    static_configs:
    - targets: ['localhost:9090']


############## 添加Job #############    
  - job_name: 'node'
    file_sd_configs:
        - files: ['/opt/prometheus/sd_config/node.yml']
          refresh_interval: 5s 
############## 添加job #############

 重载配置文件

[root@prometheus]# ./promtool check config prometheus.yml 
Checking prometheus.yml
  SUCCESS: 0 rule files found
  重启 prometheus
  
[root@prometheus ]# service prometheus restart

 

 

Grafana可视化Prometheus 数据

安装Grafana

官网地址:https://grafana.com/grafana/download

[root@Prometheus tools]# wget https://dl.grafana.com/oss/release/grafana-8.0.6-1.x86_64.rpm
[root@Prometheus tools]# sudo yum install grafana-8.0.6-1.x86_64.rpm
[root@Prometheus tools]# systemctl daemon-reload
[root@Prometheus tools]# systemctl start grafana-server


Granfana默认的端口3000 ; 默认的账户密码  admin  admin

 访问 http://192.168.11.3:3000

 添加数据源 > add data source 

 添加Prometheus 数据源

 添加视图

官网视图地址:https://grafana.com/grafana/dashboards

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值