Prometheus 基於文件的服務發現


Prometheus 基於文件的服務發現

官方文檔:https://github.com/prometheus/prometheus/tree/master/discovery

服務發現支持: endpoints,ingress,kubernetes,node,pod,service。
Prometheus也提供了服務發現功能,可以從consul,dns,kubernetes,file等等多種來源發現新的目標。
其中最簡單的是從文件發現服務。

• azure_sd_configs
• consul_sd_configs
• dns_sd_configs
• ec2_sd_configs
• openstack_sd_configs
• file_sd_configs
• gce_sd_configs
• kubernetes_sd_configs
• marathon_sd_configs
• nerve_sd_configs
• serverset_sd_configs
• triton_sd_configs
Prometheus 支持服務發現的來源:

1、編寫配置文件:vim prometheus.yml

scrape_configs:
  - job_name: 'prometheus'
    # 使用基於文件服務發現
    file_sd_configs:
        # 指定服務發現的目錄及配置文件
        - files: ['/usr/local/prometheus/sd_config/*.yml']
          # 每過5秒動態發現服務配置
          refresh_interval: 5s

2、創建目錄

mkdir /usr/local/prometheus/sd_config

3、寫入配置文件

vim /usr/local/prometheus/sd_config/test.yml

# 添加本地主機並填入標簽
- targets: ['localhost:9090']
  labels:
    idc: bj

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM