Prometheus 基于文件的服务发现

Prometheus 基于文件的服务发现node

官方文档:https://github.com/prometheus/prometheus/tree/master/discoverygit

服务发现支持: endpoints,ingress,kubernetes,node,pod,service。
Prometheus也提供了服务发现功能,能够从consul,dns,kubernetes,file等等多种来源发现新的目标。
其中最简单的是从文件发现服务。github

• 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 支持服务发现的来源:

一、编写配置文件:vim prometheus.ymlvim

scrape_configs:
  - job_name: 'prometheus'
    # 使用基于文件服务发现
    file_sd_configs:
        # 指定服务发现的目录及配置文件
        - files: ['/usr/local/prometheus/sd_config/*.yml']
          # 每过5秒动态发现服务配置
          refresh_interval: 5s

二、建立目录ide

mkdir /usr/local/prometheus/sd_config

三、写入配置文件spa

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

# 添加本地主机并填入标签
- targets: ['localhost:9090']
  labels:
    idc: bj

 

相关文章
相关标签/搜索