首页 > 其他分享 >Prometheus笔记-Label标签

Prometheus笔记-Label标签

时间:2023-01-17 13:34:46浏览次数:36  
标签:配置文件 标签 scrape Label metrics Prometheus

Label

Lable是为了方便管理及查询监控目标,在后续写promtheus查询语法的时候需要使用标签作为查询条件

配置文件

# 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'

	  # 静态指定每一个监控目标
    static_configs:
      # 监控目标节点地址,可以并列写入多个目标节点地址(格式为 机器ip:端口),以逗号隔开
      - targets: ["localhost:9090"]
        # 标签
        labels:
          env: 'test'

上文配置文件17,18两行实现了新增一个label标签 env

显示效果

image.png
注意:在修改配置文件后,需要重启Prometheus服务

标签:配置文件,标签,scrape,Label,metrics,Prometheus
From: https://www.cnblogs.com/jruing/p/17057597.html

相关文章