匿名
未登录
登录
Linux78|wiki
搜索
查看“Prometheus 标签整合”的源代码
来自Linux78|wiki
名字空间
页面
讨论
更多
更多
页面选项
查看
查看源代码
历史
←
Prometheus 标签整合
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
wiki:用户|用户
您可以查看与复制此页面的源代码。
一、Prometheus 根据标签聚合总CPU使用率 1、主机添加标签(可在多个主机内添加相同标签实现聚合):vim prometheus.conf static_configs: - targets: ['localhost:9090'] # 添加标签选项 labels: # 标签key:标签value idc: bj 2、检查配置文件 ./promtool check config prometheus.yml 3、配置文件重新生效 4、监控平台:使用promSQL查询指定标签内主机的所有CPU总和 sum(process_cpu_seconds_total{idc="bj"}) 二、Prometheus 重命名标签 根据标签聚合总CPU使用率 1、修改配置文件:vim prometheus.conf scrape_configs: # 作业改为bj - job_name: 'bj' static_configs: - targets: ['localhost:9090'] # 添加重命名标签 relabel_configs: # 基于正则表达式匹配操作 - action: replace # 指定源标签 source_labels: ['job'] # 写入正则,捕获值 regex: (.*) # 替换正则表达式匹配到的分组,分组引用 $1 replacement: $1 # 重新标记标签 为 idc target_label: idc 2、检查配置文件 ./promtool check config prometheus.yml 3、配置文件重新生效 4、使用promSQL查询指定标签内主机的所有CPU总和 sum(process_cpu_seconds_total{job="bj"}) 三、Prometheus 根据标签过滤目标 1、指定标签下的主机停止数据采集 scrape_configs: - job_name: 'bj' static_configs: - targets: ['localhost:9090'] relabel_configs: # 启动drop标签过滤,被指定到的标签停止数据采集 - action: drop # 指定 job 标签 source_labels: ['job'] 2、指定标签下的主机保留数据采集 scrape_configs: - job_name: 'bj' static_configs: - targets: ['localhost:9090'] relabel_configs: # 启动keep标签过滤,被指定到的标签保留数据采集 - action: keep # 指定 job 标签 source_labels: ['job'] 四、Prometheus 删除标签 1、删除标签动作 scrape_configs: - job_name: 'bj' static_configs: - targets: ['localhost:9090'] relabel_configs: # 删除指定标签 - action: labeldrop # 指定 job 标签 regex: job
返回至
Prometheus 标签整合
。
导航
导航
首页
最近更改
随机页面
栏目
Nginx
Kubernetes
Spring Cloud
Wiki工具
Wiki工具
特殊页面
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志