Prometheus - Relabel

本文涉及的产品
可观测监控 Prometheus 版,每月50GB免费额度
简介: 通过对标签的重命名进行重整操作,便于统一化管理或者服务升级前后管理。

通过对标签的重命名进行重整操作,便于统一化管理或者服务升级前后管理。


原始数据:

cat targets/node-exporter.yml

- targets:  - "172.20.31.195:9100"  labels:    __os__: "linux"    __release__: "redhat"- targets:  - "172.20.31.196:9100"  labels:    __os__: "linux"    __release__: "centos"- targets:  - "172.20.31.197:9100"  labels:    __os__: "linux"    __release__: "centos"

image.jpeg




replace: 对原有的标签进行更名

scrape_configs:  - job_name: 'node-exporter'    file_sd_configs:    - files:      - targets/node-exporter.yml
      refresh_interval: 1m
    relabel_configs:    - source_labels:      - "__os__"      regex: "(.*)"      target_label: "os"      action: replace
      replacement: "$1"


image.jpeg



replace-separator: 对字段进行合并处理

scrape_configs:  - job_name: 'node-exporter'    file_sd_configs:    - files:      - targets/node-exporter.yml
      refresh_interval: 1m
    relabel_configs:    - source_labels:      - "__os__"      - "__release__"      separator: "-"      regex: "(.*)"      target_label: "os_release"      action: replace
      replacement: "$1"


image.jpeg



keep: 满足特定条件的实例进行采集,其他的不采集。

scrape_configs:  - job_name: 'node-exporter'    file_sd_configs:    - files:      - targets/node-exporter.yml
      refresh_interval: 1m
    relabel_configs:    - source_labels:      - "__release__"      regex: "redhat"      action: keep


image.jpeg



drop: 满足特定条件的实例不采集,其他的采集。

scrape_configs:  - job_name: 'node-exporter'    file_sd_configs:    - files:      - targets/node-exporter.yml
      refresh_interval: 1m
    relabel_configs:    - source_labels:      - "__release__"      regex: "redhat"      action: drop


image.jpeg




labelkeep:  对抓取的实例特定标签进行保留,其他标签删除。

scrape_configs:  - job_name: 'node-exporter'    file_sd_configs:    - files:      - targets/node-exporter.yml
      refresh_interval: 1m
    relabel_configs:     - source_labels:      - "__os__"      regex: "(.*)"      target_label: "os"      action: replace
      replacement: "$1"    - source_labels:      - "__release__"      regex: "(.*)"      target_label: "release"      action: replace
      replacement: "$1"    - regex: "jobs"      action: labelkeep


labeldrop: 对抓取的实例特定标签进行删除。

scrape_configs:  - job_name: 'node-exporter'    file_sd_configs:    - files:      - targets/node-exporter.yml
      refresh_interval: 1m
    relabel_configs:     - source_labels:      - "__os__"      regex: "(.*)"      target_label: "os"      action: replace
      replacement: "$1"    - source_labels:      - "__release__"      regex: "(.*)"      target_label: "release"      action: replace
      replacement: "$1"    - regex: "os"      action: labeldrop


image.jpeg



hashmod:将target_label设置成source_label的modulus配置的hash值;



labelmap:将regex匹配到的所有标签的名称配置成新的标签,值配置成新标签的值;



相关实践学习
容器服务Serverless版ACK Serverless 快速入门:在线魔方应用部署和监控
通过本实验,您将了解到容器服务Serverless版ACK Serverless 的基本产品能力,即可以实现快速部署一个在线魔方应用,并借助阿里云容器服务成熟的产品生态,实现在线应用的企业级监控,提升应用稳定性。
目录
相关文章
|
5月前
|
存储 Prometheus Kubernetes
「译文」Prometheus 中的 relabel 是如何工作的?
「译文」Prometheus 中的 relabel 是如何工作的?
|
Prometheus 监控 Cloud Native
Ceph 监控中应用 Prometheus relabel 功能
1. 问题描述 工作环境中有三个独立的 Ceph 集群,分别负责对象存储、块存储和文件存储。搭建这几个 Ceph 集群时,我对 Ceph 重命名 Cluster name 的难度没有足够的了解,所以使用的都是默认的 cluster name:ceph,不巧的是 Prometheus 的 ceph_exporter 就是用 cluster name 来区分不同集群,结果是 Grafana 中各个集群的数据无法区分,所有的集群数据都绘制在了一个图标中,非常乱不说,而且部分数据还无法正常显示。
1469 0
|
2月前
|
Prometheus 监控 Cloud Native
【监控】prometheus传统环境监控告警常用配置
【监控】prometheus传统环境监控告警常用配置
【监控】prometheus传统环境监控告警常用配置
|
4月前
|
Prometheus 监控 Cloud Native
基于Prometheus和Grafana的监控平台 - 环境搭建
基于Prometheus和Grafana的监控平台 - 环境搭建
|
1月前
|
Prometheus 监控 Cloud Native
介绍如何使用Prometheus进行监控
介绍如何使用Prometheus进行监控
147 3
|
1月前
|
Prometheus 监控 Cloud Native
docker安装prometheus+Granfan并监控容器
【9月更文挑战第14天】本文介绍了在Docker中安装Prometheus与Grafana并监控容器的步骤,包括创建配置文件、运行Prometheus与Grafana容器,以及在Grafana中配置数据源和创建监控仪表盘,展示了如何通过Prometheus抓取数据并利用Grafana展示容器的CPU使用率等关键指标。
|
2月前
|
存储 Prometheus 监控
Grafana 与 Prometheus 集成:打造高效监控系统
【8月更文第29天】在现代软件开发和运维领域,监控系统已成为不可或缺的一部分。Prometheus 和 Grafana 作为两个非常流行且互补的开源工具,可以协同工作来构建强大的实时监控解决方案。Prometheus 负责收集和存储时间序列数据,而 Grafana 则提供直观的数据可视化功能。本文将详细介绍如何集成这两个工具,构建一个高效、灵活的监控系统。
279 1
|
2月前
|
Prometheus 监控 Cloud Native
使用Prometheus搞定微服务监控
使用Prometheus搞定微服务监控
使用Prometheus搞定微服务监控
|
2月前
|
Prometheus Kubernetes 监控
Kubernetes(K8S) 监控 Prometheus + Grafana
Kubernetes(K8S) 监控 Prometheus + Grafana
192 2
|
2月前
|
Prometheus 监控 Cloud Native
在 HBase 集群中,Prometheus 通常监控哪些类型的性能指标?
在 HBase 集群中,Prometheus 通常监控哪些类型的性能指标?
104 2