当前位置: 首页 > news >正文

80. 使用 grafana 和 prometheus监控Longhorn

Environment 环境

SUSE Rancher Longhorn SUSE 牧场长角牛

Procedure 程序

Overview 概述

Longhorn integrates seamlessly with Prometheus, providing comprehensive visibility into the health and performance of your storage environment. Prometheus collects a wide range of metrics across Longhorn and related system components, enabling effective monitoring of volumes, disks, and nodes throughout the cluster.
Longhorn 与 Prometheus 无缝集成,全面了解您的存储环境健康状况和性能。Prometheus 收集了 Longhorn 及相关系统组件的广泛指标,能够有效监控集群中的卷、磁盘和节点。

Rancher integrates Prometheus and Grafana to monitor Kubernetes nodes, components, and workloads. To enable Rancher Monitoring refer the official documentation.
Rancher 集成了 Prometheus 和 Grafana,用于监控 Kubernetes 节点、组件和工作负载。 要启用牧场主监控,请参阅官方文档 。

If Rancher Monitoring is already enabled, Longhorn metrics can be scraped by deploying a ServiceMonitor in the Longhorn-system namespace.
如果已经启用了牧场主监控,可以通过在 Longhorn 系统命名空间中部署 ServiceMonitor 来抓取 Longhorn 的指标。

Step 1: Deploy Longhorn ServiceMonitor
步骤 1:部署 Longhorn ServiceMonitor

Apply the following manifest:
应用以下清单:

<span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#efefef"><code>apiVersion: <a>After deployment, Prometheus will automatically discover and collect Longhorn metrics.
部署后,普罗米修斯会自动发现并收集长角牛的指标。

Validation: 验证:
Check metrics by running a query such as below in the Prometheus UI or check if the prometheus target is showing UP:
通过在 Prometheus 界面中运行查询,或检查 Prometheus 目标是否显示为 UP:

<span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#efefef"><code>longhorn_disk_usage_bytes</code></span></span></span>

Step 2: Visualizing Metrics in Grafana
第二步:在 Grafana 中可视化度量

Accessing Grafana 访问格拉法纳

  1. In Rancher UI, navigate to your Cluster
    在 Rancher 界面中,导航到你的集群

  2. Go to Cluster Tools (or Apps depending on Rancher version)
    进入集群工具(或根据 Rancher 版本的应用)

  3. SelectMonitoring

  4. Click the Grafana icon/link to open in a new tab
    点击 Grafana 图标/链接,在新标签页中打开

  5. Log in (default credentials if unchanged):
    登录(如果未更改,则使用默认凭证):

    • Username:admin用户名:admin

    • Password:prom-operator
      密码:prom-operator

Option A — Import a Prebuilt Longhorn Dashboard
选项 A — 导入预建的 Longhorn 仪表盘

Please refer to the community Grafana dashboard library for Longhorn.
请参阅社区 Grafana 仪表盘库中的 Longhorn。

Steps: 步骤:

  1. Go to Dashboards → New → Import
    前往仪表盘→新→导入
  2. Select and import one of the available Longhorn dashboards
    选择并导入其中一个可用的 Longhorn 仪表盘
    Example: Dashboard ID 13032
    示例:仪表盘 ID 13032
  3. Select Prometheus as the data source
    选择普罗米修斯作为数据源

This provides visualization of common Longhorn storage performance metrics.
这为常见的长角牛存储性能指标提供了可视化。

Option B — Create Custom Panels
选项 B — 创建自定义面板

  1. In Grafana: From the sidebar, click → Dashboard → Add new dashboard → Add Visualization
    在 Grafana 中:从侧边栏点击→仪表盘→添加新仪表盘→添加可视化
  2. Select Prometheus as the data source
    选择普罗米修斯作为数据源
  3. You can either use the Query Builder to construct queries visually, or switch to the Code mode to write PromQL directly.
    你可以使用查询构建器来可视化构建查询,或者切换到代码模式直接编写 PromQL。

Example PromQL for node storage utilization percentage:
节点存储利用率示例 PromQL:

<span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#efefef"><code>(longhorn_node_storage_usage_bytes / longhorn_node_storage_capacity_bytes) * 100</code></span></span></span>

Additional recommended metrics:
其他推荐指标:

  • longhorn_node_count_total
  • longhorn_instance_manager_cpu_usage_millicpu
  • longhorn_node_cpu_capacity_millicpu

Adjust panel type, legends, and thresholds as required
根据需要调整面板类型、图例和阈值

Step 3: Save Dashboard 步骤3:保存仪表盘

  • Provide a descriptive name in title section and save the dashboard
    在标题部分提供描述性名称并保存仪表盘

  • Optionally export as JSON for reuse across environments
    可选地导出为 JSON 以便在不同环境中重复使用

访问Rancher-K8S解决方案博主,企业合作伙伴 :
https://blog.csdn.net/lidw2009

http://www.jsqmd.com/news/529999/

相关文章:

  • OpenClaw智能书签:Qwen3-VL:30B自动归档失效链接并推荐替代
  • java毕业设计基于springboot动物之家平台
  • Qwen2.5-32B-Instruct入门教程:从零开始部署与使用
  • Redis实战:手把手教你实现搜索历史与自动补全功能(Python版)
  • Vibe Coding是什么东西?怎么使用它?
  • 网络工程师必看:从“一刀切”到“精细化”,高级ACL如何拿捏网络权限?
  • 【LVGL】跨平台开发环境一站式配置指南:从Windows到Ubuntu的快速部署
  • 链上新纪元:2026区块链资产交易的“去中心化+”革命
  • 微信QQ防撤回终极解决方案:RevokeMsgPatcher 2.1 完全使用指南
  • OpCore-Simplify智能配置引擎:OpenCore EFI制作全流程指南
  • Windows CMD隐藏技巧:10个连老手都可能不知道的实用命令
  • 阿里云代理商:阿里云部署 OpenClaw 常见问题排查手册
  • 7个颠覆效率边界的开源工具:重构macOS工作流的实战指南
  • PyCharm缓存文件占用C盘空间?3步教你迁移到其他盘(附详细路径配置)
  • 红外遥控硬件设计与NEC协议工程实践
  • 从阻塞到亚毫秒:Python 3.15新增task_group_timeout与asyncgen_awaitable优化,如何一夜重构遗留微服务?
  • Portainer:开源Docker容器管理神器,打造可视化的容器运维平台
  • 咱们玩无人机或者看手机屏幕自动旋转时,背后都藏着IMU的姿态解算。今天用Matlab手撕一套四元数姿态解算方案,直接上硬核代码!(文末附完整工程)
  • 20253914 2024-2025-2 《网络攻防实践》第3次作业
  • Qwen3-ASR-1.7B在Win11系统上的部署与性能测试
  • 不只是改参数:深入理解VMware黑苹果中CPUID伪装原理与Mac机型标识设置
  • 从InceptionV3到CLIP:手把手教你为自定义任务实现FID变体(避坑指南)
  • 78. RKE2 集群配置失败,由于无法解析 localhost,导致 kube-apiserver 健康检查失败
  • 在vscode中使用create vue创建项目(小白向)
  • 越招人越亏?ToB必建的复利飞轮
  • MCP协议落地实战手册(REST开发者必读的协议升维指南)
  • 3分钟掌握WebGPU加速图像修复:Inpaint-web浏览器端零配置解决方案
  • Unity Timeline绑定丢失?教你用ScriptableObject自动备份与恢复(附完整代码)
  • 3步掌握PyEMD:从信号分解到模态分析全攻略
  • Arduino异步移位寄存器读取库AsyncShiftIn详解