Prometheus笔记-file_sd_config

一般一个job作为一个业务服务,它下面的监控的机器/节点都是这个服务的节点,为了方便管理,我们可以按照job划分,为每个job创建一个子配置文件,这样方便管理

配置文件

# my global config
global:
scrape_interval: 15s # #每15s采集一次数据
evaluation_interval: 15s #每15s做一次告警检测.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration(告警配置)
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# rule_files 加载告警规则文件
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# 定义一个job名称
- job_name: "prometheus"
# 默认指标地址 '/metrics'
metrics_path: '/metrics'
# scheme defaults to 'http'.
scheme: 'http'
# 基于文件的服务发现提供了一种更通用的方法来配置静态目标,子配置文件支持json和yaml
file_sd_configs:
- files: ["./child_config/prometheus.yml"]

创建子配置文件目录

[root@VM-24-9-centos prometheus-2.41.0.linux-amd64]# mkdir -p child_config

创建子配置文件

[root@VM-24-9-centos prometheus-2.41.0.linux-amd64]# cd child_config
[root@VM-24-9-centos prometheus-2.41.0.linux-amd64]# touch prometheus.yml
- targets: ["localhost:9090"]
labels:
env: 'test'
host: 'localhost'

显示效果

image.png

作者:jruing

出处:https://www.cnblogs.com/jruing/p/17057602.html

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。

posted @   Jruing  阅读(591)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
more_horiz
keyboard_arrow_up light_mode palette
选择主题
点击右上角即可分享
微信分享提示