Grafana接入Prometheus实战

接上文:prometheus监控实战

1.Grafana简介

Grafana 是一个开源的数据可视化与监控平台,专注于将多源数据(如时序数据库、日志、追踪信息)转化为动态仪表盘,支持实时监控与告警。

1.1 关键架构组件

  • 数据源层:支持 Prometheus、InfluxDB、Elasticsearch 等数十种数据源,通过插件机制实现统一接入。
  • 可视化层:提供折线图、热力图、仪表盘等丰富图表,支持拖拽式面板定制与变量联动。
  • 告警系统:可配置阈值规则,通过邮件、Slack 等渠道推送异常通知。
  • 扩展能力:开放式插件生态(数据源/面板/应用插件)支持功能定制。

1.2 核心优势

  • 灵活性:不存储数据,仅作为统一展示层,兼容异构数据环境。
  • 协作性:支持团队仪表盘共享、权限管理及社区模板导入。
  • 实时性:秒级数据刷新与日志流式处理能力。

2.部署

安装:

powershell 复制代码
# CentOS/RHEL:
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://packages.grafana.com/oss/rpm
sudo yum install -y https://dl.grafana.com/enterprise/release/grafana-enterprise-12.0.2-1.x86_64.rpm

启动服务并设置自启:

powershell 复制代码
sudo systemctl daemon-reload
sudo systemctl start grafana-server
sudo systemctl enable grafana-server  # 开机自启

访问:

http://10.86.97.200:3000/login

账号/密码:admin/admin

关键配置:

powershell 复制代码
vim /etc/grafana/grafana.ini
powershell 复制代码
[server]
http_port = 3000  # 监听端口
[security]
disable_initial_admin_creation = false  # 禁止自动创建admin(生产建议true)

3.接入prometheus

Connections->Data sources->Add data source->prometheus。

4.数据可视化

新建dashboard:

模板填写12633:

选择数据源:

5.最后效果


6.常见问题

6.1 You have enabled checking of packages via GPG keys

描述:You have enabled checking of packages via GPG keys. This is a good thing.

However, you do not have any GPG public keys installed. You need to download

the keys for packages you wish to install and install them.

You can do that by running the command:

rpm --import public.gpg.key。

解决:

下载Grafana官方公钥(推荐)

powershell 复制代码
wget https://packages.grafana.com/gpg.key

导入公钥

powershell 复制代码
sudo rpm --import gpg.key  # 导入当前目录下的gpg.key文件。

验证是否导入成功

powershell 复制代码
rpm -q gpg-pubkey --info  # 显示所有已安装公钥信息。

7.dashbord模板

访问:https://grafana.com/

首页底部:

检索:主机(Redis、MySQL、PostgreSQL等)

找到ID:

8 其它接入效果

8.1 redis

8.2 mysql

相关推荐
zxcxylong5 小时前
almalinux下部署promethues+grafana服务-容器化
docker·grafana·prometheus·docker compose·almalinux
A-刘晨阳5 小时前
【云原生】Prometheus之PromQL用法详解
运维·云原生·grafana·prometheus·监控·promql
牛奔1 天前
grafana 二次开发,制作镜像流程
grafana
u0104058361 天前
Java中的服务监控:Prometheus与Grafana的集成
java·grafana·prometheus
oMcLin3 天前
如何在 Rocky Linux 8.7 上通过 Prometheus 与 Grafana 结合,提升大规模容器环境的监控与性能分析?
linux·grafana·prometheus
飞翔沫沫情3 天前
Prometheus 监控 ESXi 实战
grafana·prometheus·esxi·vcenter 监控·vsphere 监控
莫非王土也非王臣3 天前
Prometheus监控多个网站状态并推送到企业微信群机器人的完整方案
机器人·企业微信·prometheus
goodlook01235 天前
监控平台搭建-日志-alloy篇(八)
grafana·prometheus
goodlook01235 天前
监控平台搭建-日志-springboot直接推送loki篇(九)
java·spring boot·后端·grafana
三不原则5 天前
实战:Prometheus 监控 GPU 使用率,设置智能告警阈值
prometheus