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

相关推荐
何中应4 天前
Grafana如何共享面板
运维·grafana·可观测
何中应4 天前
Grafana如何安装插件
运维·grafana·可观测
疯子的梦想@5 天前
Prometheus 接入 Alertmanager 与钉钉机器人,附中文模板和完整踩坑记录
机器人·钉钉·prometheus
lbb 小魔仙6 天前
Windows搭建PaddleOCR+飞书Webhook自动打卡通知机器人:识别、推送与远程触发完整教程
数据库·人工智能·prometheus·时序数据库
云边有个稻草人6 天前
Prometheus Pushgateway教程:离线任务指标上报、Shell与Python示例、远程访问
开发语言·python·prometheus
广目软件7 天前
HA分布式架构采集节点变更操作手册20261029
运维·服务器·ansible·zabbix·prometheus
tianyuanwo11 天前
Prometheus 服务部署指南:从架构原理到生产级落地
架构·prometheus
看浪的路人14 天前
第8讲:记忆系统的监控与运维——Prometheus 指标、Grafana 面板与告警体系
运维·grafana·prometheus
爬也要爬着前进15 天前
Prometheus通过Nginx-vts-exporter模块监控nginx服务
运维·nginx·prometheus
Crayon Lin16 天前
Prometheus
prometheus