利用prometheus+grafana进行Linux主机监控

本文详细描述了如何在Linux服务器上部署Prometheus和Grafana,包括软件包的上传、配置文件的修改、node-exporter的部署以及Grafana的数据源设置和监控模板定制,确保资源监控的完整性和可扩展性。

一.架构说明与资源准备

在这里插入图片描述

需要准备的软件包:

node_exporter-1.2.0.tar.gz
grafana-7.3.0-1.x86_64.rpm
prometheus-2.45.1.linux-amd64.tar.gz

以上软件版本可以有一定的差异,只要兼容RHEL7的操作系统,本次部署的3台虚拟机操作系统是 CentOS Linux release 7.9.2009 (Core) 。

软件包下载地址参考:

https://rpmfind.net/linux/rpm2html/search.php
https://sourceforge.net/projects/infozip/files/
https://centos.pkgs.org/7/centos-x86_64/
https://access.redhat.com/downloads

二.部署prometheus

本章操作都在node01进行。

1.上传软件包

首先将软件包上传到/root目录下

在这里插入图片描述

2.解压软件包并移动到指定位置

接着创建/data目录,准备将后续解压后的软件文件放在/data目录

mkdir /data
tar zxf prometheus-2.45.1.linux-amd64.tar.gz
mv prometheus-2.45.1.linux-amd64 /data/prometheus

3.修改配置文件

针对配置文件 /data/prometheus/prometheus.yml 进行修改

global:
  scrape_interval: 15s 
  evaluation_interval: 15s 
  scrape_timeout: 15s

alerting:
  alertmanagers:
    - static_configs:
        - targets:
            - 192.168.0.201:9093
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"
  - rules/*.yml

scrape_configs:
  - job_name: "node_exporter"
    static_configs:
    # #监控的主机IP和node-exporter端口
    - targets: ['192.168.0.201:9100','192.168.0.202:9100','192.168.0.203:9100']
    relabel_configs:
    - source_labels:
      - "__address__"
      regex: "(.*):9100"
      target_label: "instance"
      action: replace
      replacement: "$1"

remote_write:
  - url: "http://192.168.0.201:8086/api/v1/prom/write
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值