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 天前
Prometheus接入“飞书“实现自动化告警
运维·安全·自动化·github·飞书·prometheus
朱包林6 天前
Prometheus监控K8S集群-ExternalName-endpoints-ElasticStack采集K8S集群日志实战
运维·云原生·容器·kubernetes·prometheus
3分云计算6 天前
Prometheus 05-01: 告警规则与Alertmanager配置
prometheus
散一世繁华,颠半世琉璃9 天前
Prometheus+Grafana轻松实现SpringBoot应用监控
spring boot·grafana·prometheus
Achou.Wang10 天前
kube-prometheus监控服务发现
服务发现·prometheus
LoneEon11 天前
Ubuntu 系统安装 Prometheus+Grafana(附shell脚本一键部署↓)
ubuntu·grafana·prometheus
Coco_淳12 天前
K8s平台部署Grafana + Loki + Promtail日志收集系统
kubernetes·grafana·日志·loki
文人sec13 天前
性能测试-jmeter15-性能项目计划流
分布式·jmeter·性能优化·grafana·prometheus·模块测试
Knight_AL13 天前
Spring Cloud Gateway 实战:全局过滤器日志统计与 Prometheus + Grafana 接口耗时监控
spring boot·spring cloud·grafana·prometheus