记录一次Linux利用grafana+prometheus搭建可视化展示资源使用率 - 风屿岛
记录一次Linux利用grafana+prometheus搭建可视化展示资源使用率 - 风屿岛

记录一次Linux利用grafana+prometheus搭建可视化展示资源使用率

2020-02-25 超级管理员
分类: #Linux #技术文章 标签: #教程
AI摘要

本文介绍了在云服务器上部署监控系统,包括安装node_exporter、Prometheus和Grafana三个组件。首先通过Linux命令安装node_exporter用于收集系统数据,然后配置Prometheus以监听node_exporter数据,最后安装Grafana并添加Prometheus数据源及Dashboards,实现可视化监控。文章提供了详细的安装步骤和配置方法,适合需要搭建监控系统的人员参考。

如果您使用1Panel,Grafana和Prometheus都是有1Panel的一键版本的,但使用1Panel应用的方法未经测试

image

image

如果你希望使用1Panel,可以在购买服务器时选择预装

image

上图为雨云的预装示例,某些服务商可能不支持预装,请看 在线安装 - 1Panel 文档

本文以家里云+centos做演示

准备工作

首先准备好软件环境

    1. node_exporter
    1. prometheus
    1. grafana

这些是必备的

安装工作

首先我们安装node_exporter
node_exporter的作用是用于机器系统数据收集。

官网下载包
安装包

官网包下载

利用Linux命令下载安装

wget https://github.com/prometheus/node_exporter/releases/download/v1.0.0-rc.0/node_exporter-1.0.0-rc.0.linux-amd64.tar.gz #下载node_exporter包

下载node_exporter

tar xvf node_exporter-1.0.0-rc.0.linux-amd64.tar.gz #解压下载来的包

解压node_exporter

mv node_exporter-1.0.0-rc.0.linux-amd64 node_exporter #把解压的目录改成node_exporter

把解压的目录改成node_exporter

cd node_exporter #进入node_exporter目录

进入node_exporter目录

./node_exporter #运行node_exporter

运行 成功会显示端口9100 看到这图片代码安装运行成功了

访问 http://localhost:9100/metrics

接下来安装prometheus
Prometheus的一类数据采集组件的总称。它负责从目标处搜集数据,并将其转化为Prometheus支持的格式。

官网下载包
安装包

官网包下载
官网下载截屏

利用Linux命令下载安装

wget https://github.com/prometheus/prometheus/releases/download/v2.16.0/prometheus-2.16.0.linux-amd64.tar.gz

下载Prometheus

tar xvf prometheus-2.16.0.linux-amd64.tar.gz #解压下载来的包

解压包

mv prometheus-2.16.0.linux-amd64.tar.gz prometheus#把解压的目录改成prometheus

目录改成prometheus

cd prometheus #进入prometheus目录

进入prometheus目录 这里我们要注意修改prometheus的配置文件

利用vim在prometheus.yml文件scrape_configs下添加

 - job_name: 'node'
    static_configs:
      - targets: ['localhost:9100']

添加配置文件 这里监听node_exporter的数据
最后我们启动prometheus服务

./prometheus #启动prometheus服务

启动prometheus 访问 http://47.103.87.205:9090/graph
搜索up出现以下图片代表运行成功数据监听成功
如果

up{instance="localhost:9090",job="prometheus"}    0
up{instance="localhost:9100",job="node"}    0

代表数据没监听到

效果图 最后我们安装grafana

wget https://dl.grafana.com/oss/release/grafana-6.6.2-1.x86_64.rpm
sudo yum localinstall grafana-6.6.2-1.x86_64.rpm

其他服务器看官网
地址 https:

sudo systemctl start grafana-server #启动grafana

启动grafana 访问 http:
默认账号密码是 admin

添加prometheus数据源

添加prometheus数据源

配置图 添加Dashboards
添加Dashboards

这里我们点Import 导入Dashboards

导入 输入官方下载的Dashboards json文件或者Dashboards的ID获取

导入Dashboards

ID或者JSON 查看一下效果

效果图 完工</http:></https:>

返回首页
最后更新: 2025-12-23

评论

发表评论

设置

主题

字体连字

HDR