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

86. 如何在 Prometheus 的 kube-state-metrics 中加入额外的资源标签

Environment 环境

A Kubernetes cluster provisioned by the RKE2 CLI or Rancher v2.x
由 RKE2 CLI 或 Rancher v2.x 配置的 Kubernetes 集群

Situation 地理位置

By default, kube-state-metrics in Rancher Monitoring exports only a limited set of Kubernetes labels to help optimize resource usage and avoid excessive data collection in Prometheus. If you need additional labels to be included in the metrics for better monitoring or alerting, you can easily customize the values.yaml file of the rancher-monitoring chart to export those labels.
默认情况下,Rancher Monitoring 中的 kube-state-metrics 只导出有限的 Kubernetes 标签集,以帮助优化资源使用,避免 Prometheus 中过度收集数据。如果你需要在指标中加入额外标签以更好地监控或提醒,可以轻松自定义 Rancher-Monitoring 图表中的 values.yaml 文件来导出这些标签。

Resolution 结局

Why Customize Labels? 为什么要定制标签?

Sometimes, you may need more granular insights into your Kubernetes cluster. For example, you might want to track node group labels, application versions, or specific zone information. By exporting additional labels, you can enrich your metrics and enable more precise monitoring, alerting, and troubleshooting.
有时,您可能需要对 Kubernetes 集群提供更细致的洞察。例如,您可能需要跟踪节点组标签、应用版本或特定区域信息。通过导出额外标签,您可以丰富指标,实现更精准的监控、警报和故障排除。

How to Export Additional Labels
如何导出额外标签

To export additional labels, you can modify the metricLabelsAllowlist setting in the values.yaml file of the rancher-monitoring chart. This configuration lets you specify which labels to include for specific Kubernetes resources like nodes, pods, or namespaces.
要导出更多标签,可以在 rancher-monitoring 图表的 values.yaml 文件中修改 metricLabelsAllowlist 设置。该配置允许你指定为特定 Kubernetes 资源(如节点、播客或命名空间)添加哪些标签。

Go to Rancher UI ☰ > Apps > Installed apps > rancher-monitoring, click on Edit/Upgrade option and then edit the helm values.
进入牧场主 UI ☰>应用>已安装应用>牧场主监控,点击编辑/升级选项,然后编辑舵手的数值。

Example: Include All Labels for Nodes
示例:包含所有节点标签

If you need to include all labels for nodes (which can be useful but should be used cautiously due to performance considerations), you can use the wildcard *:
如果你需要包含所有节点标签(这很有用,但因性能考虑需谨慎使用),可以使用通配符 *:

kube-state-metrics:
metricLabelsAllowlist:
- nodes=[*]

Warning: Using * will includealllabels for nodes, which may increase the resource usage in Prometheus.
警告:使用 * 会包含所有节点标签,这可能会增加 Prometheus 中的资源使用。

If you want to add specific labels for namespaces and pods, you can configure it like this:
如果你想为命名空间和 pod 添加特定标签,可以这样配置:

kube-state-metrics:
metricLabelsAllowlist:
- namespaces=["k8s-label-1", "k8s-label-2"]
- pods=["app", "version"]

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

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

相关文章:

  • WinDiskWriter:让Mac用户轻松制作Windows启动盘的专业工具
  • 自助建站平台哪个好 - 码云数智
  • vLLM-v0.17.1实操手册:vLLM服务自动扩缩容(KEDA+Prometheus)
  • 聊聊2026好用的伸缩门厂家,沧州、北京、天津、太原地区推荐 - 工业设备
  • 多年以后,面对 Vibe Code,我想起了拿起 TDD 的那个下午
  • 别再混淆了!深入对比Vivado中AXI DMA IP核与PS端DMA控制器的角色与分工
  • FanControl终极指南:5步掌握Windows风扇智能控制,告别噪音烦恼!
  • 2026年国内有名的轻烧粉厂家找哪家,轻质医药氧化镁/氢氧化镁/氧化镁/碳酸镁/氧化镁糊/轻烧粉,轻烧粉厂家哪家好 - 品牌推荐师
  • DiffSinger歌声合成:如何用AI创作专业级人声的完整指南
  • 收藏!2026年高低温冷热冲击试验箱品牌(厂家)推荐及选购方法 - 博客万
  • 智能相册管理系统:Face Analysis WebUI+人脸聚类算法
  • 腾讯企业邮箱怎么注册:2026年流程详解 - 品牌2025
  • BiliTools跨平台哔哩哔哩工具箱:揭秘如何打造个人专属的B站内容收藏库
  • 2026年防火铝塑板厂家推荐:商业空间装修高防火等级板材选购与避坑指南 - 十大品牌推荐
  • 3步掌握Balena Etcher:安全高效的镜像烧录解决方案
  • SDMatte模型原理剖析:从卷积神经网络到精细化Matting
  • 2026年值得关注的BWT净水器个性化定制,满足多样需求 - 工业推荐榜
  • 基于anythingLLM让AI全自动操作电脑的探索os agent(computer use)
  • Eino Tool 开发:三种姿势,我踩过的坑
  • 公司网站建设流程 - 码云数智
  • Akagi雀魂AI助手:5分钟快速搭建你的智能麻将教练系统
  • 闲置大润发购物卡别吃灰,浅谈保姆级提现攻略 - 淘淘收小程序
  • Nunchaku-flux-1-dev多模态协同架构:未来支持‘语音描述→文字转译→图像生成’端到端链路
  • 避坑指南:Selenium爬取动态网页时遇到的5个典型问题及解决方案
  • 2026年防火铝塑板厂家推荐:大型工程采购高性价比与稳定供应靠谱供应商分析 - 十大品牌推荐
  • 别再踩坑了!MinGW、LLVM、Clang、GCC… 这些编译工具到底是啥?一篇大白话讲透
  • 2025-2026年低温锂电池厂家推荐:工业特种车辆低温启动高性价比方案分析 - 十大品牌推荐
  • iText7中文渲染完全指南:从乱码到多语言排版的技术突破
  • 2026年新疆钢模板/塑料模板/塑钢模板选购指南:行业趋势、优质品牌推荐及采购全攻略 - 2026年企业推荐榜
  • VSCode界面美化指南:使用vscode-background打造个性化编辑器环境