《云原生监控体系构建实录:从Prometheus到Grafana的观测革命》

Prometheus+Grafana部署配置

Prometheus安装

下载Prometheus服务端

Download | PrometheusAn open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.https://prometheus.io/download/

上传至服务器,解压

复制代码
tar -zxvf prometheus-3.0.1.linux-amd64.tar.gz
复制代码
cd prometheus-3.0.1.linux-amd64

运行

复制代码
./prometheus --config.file="prometheus.yml"

后台运行

复制代码
nohup ./prometheus --config.file=prometheus.yml &

当首次访问9090端口时,时间序列数据的洪流如同宇宙背景辐射般扑面而来。

Grafana安装

Grafana是一个可视化面板(Dashboard),有着非常漂亮的图表和布局展示,功能齐全的度量仪表盘和图形编辑器,支持Graphite、zabbix、InfluxDB、Prometheus

下载地址:Download Grafana | Grafana LabsOverview of how to download and install different versions of Grafana on different operating systems.https://grafana.com/grafana/download

复制代码
yum localinstall -y grafana-6.5.0-1.x86_64.rpm
复制代码
systemctl start grafana-server

访问页面http://服务器IP:3000 ,默认账号、密码admin/admin

Prometheus被监控端安装插件

下载插件(此处下载一个node 和 mysql插件)

Download | PrometheusAn open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.https://prometheus.io/download/

在被监控端主机解压这两个文件

复制代码
tar -zxvf node_exporter-1.8.2.linux-amd64.tar.gz 

node_exporter插件可直接运行

cd node_exporter-1.8.2.linux-amd64

node_exporter插件可直接运行

cd node_exporter-1.8.2.linux-amd64

nohup ./node_exporter &

mysqld_exporter需要连接到MySQL,需要授权

mysqld_exporter插件需要创建一个用户+密码的文件

复制代码
tar -zxvf mysqld_exporter-0.16.0.linux-amd64.tar.gz
复制代码
cd mysqld_exporter-0.16.0.linux-amd64
复制代码
mysql> use mysql;

mysql> create user dbuser;
复制代码
mysql> GRANT REPLICATION CLIENT, PROCESS ON *.* TO 'dbuser'@'localhost' identified by '123456';
复制代码
mysql> GRANT SELECT ON performance_schema.* TO 'dbuser'@'localhost';

创建 .my.cnf 加入以下内容

复制代码
[client]

user=dbuser

password=123456

启动mysqld_exporter

复制代码
nohup ./mysqld_exporter --config.my-cnf=.my.cnf &

Prometheus服务端添加被监控端

复制代码
cd prometheus-3.0.1.linux-amd64

vi prometheus.yml  加入

  - job_name: system-status

    static_configs:

    - targets: ['192.168.126.50:9100']

      labels:

        instance: 7-7



  - job_name: mysql-status

    static_configs:

    - targets: ['192.168.126.40:9104']

      labels:

        instance: 7-7-mysql
复制代码
​访问Prometheus   http://192.168.126.30:9090/targets

Grafana对接Prometheus

添加源数据

添加成功

Grafana添加图表

自带dashboard

下载地址

Grafana dashboards | Grafana LabsBrowse a library of official and community-built dashboards.https://grafana.com/grafana/dashboards

导入

相关推荐
一ge科研小菜鸡13 分钟前
构建云原生安全治理体系:挑战、策略与实践路径
安全·云原生
上海运维Q先生2 小时前
Cilium动手实验室: 精通之旅---4.Cilium Gateway API - Lab
云原生·k8s·cilium
探索云原生3 小时前
开源 vGPU 方案:HAMi,实现细粒度 GPU 切分
ai·云原生·kubernetes·gpu
NineData3 小时前
NineData云原生智能数据管理平台新功能发布|2025年5月版
数据库·云原生·oracle·devops·ninedata
一ge科研小菜鸡4 小时前
云原生 DevOps 实践路线:构建敏捷、高效、可观测的交付体系
运维·云原生·devops
阿里云云原生1 天前
阿里云事件总线 EventBridge 正式商业化,构建智能化时代的企业级云上事件枢纽
云原生
阿里云云原生1 天前
StoreView SQL,让数据分析不受地域限制
云原生
在未来等你1 天前
互联网大厂Java求职面试:云原生架构下的微服务网关与可观测性设计
java·spring cloud·微服务·云原生·面试·分布式系统
阿里云云原生1 天前
【发布实录】云原生+AI,助力企业全球化业务创新
人工智能·云原生·可观测·通义灵码
掘金-我是哪吒1 天前
分布式微服务系统架构第143集:pom文件
分布式·微服务·云原生·架构