基于文件的服务发现方式不需要依赖其他平台与第三方服务,用户只需将要新的target信息以yaml或json文件格式添加到target文件中 ,prometheus会定期从指定文件中读取target信息并更新。

target文件

vim /usr/local/prometheus-2.1/targets.json
[
{
"targets": [ "192.168.20.136:9100"],
"labels": {
"instance": "nodeone",
"job": "expor_test1"
}
}, {
"targets": [ "localhost:9090"],
"labels": {
"job": "prometheus"
}
}, {
"targets": [ "192.168.20.137:9100"],
"labels": {
"instance": "nodetwo",
"job": "expor_test2"
}
}
]

Prometheus配置文件

global:
scrape_interval: 15s
evaluation_interval: 15s alerting:
alertmanagers:
- static_configs:
- targets: ['localhost:9093'] rule_files:
# - "/usr/local/prometheus-2.1/rule.yml"
# - "/usr/local/prometheus-2.1/rule2.yml" scrape_configs: - job_name: 'file_ds' #此处定义了自动发现的采集任务
file_sd_configs:
- files:
- targets.json #采集文件名

启动prometheus

./prometheus &

查看web界面targets 出现targets.json 所定义的3个job。

prometheus — 基于文件的服务发现的更多相关文章

  1. Prometheus 基于文件的服务发现

    Prometheus 基于文件的服务发现 官方文档:https://github.com/prometheus/prometheus/tree/master/discovery 服务发现支持: end ...

  2. Prometheus基于文件的服务发现

    Prometheus基于文件的服务发现 一.基于文件的服务发现 1.prometheus.yml 配置文件的写法 2.file_sd 目录下的文件 3.配置结果 二.注意事项 三.参考链接 一.基于文 ...

  3. Prometheus基于Eureka的服务发现

    Prometheus基于Eureka的服务发现 一.背景 二.实现步骤 1.eureka 客户端注册到prometheus中 2.prometheus中的写法 3.实现效果 三.完整代码 四.参考链接 ...

  4. prometheus 基于文件的目标发现

    prometheus 基于文件的目标发现 1.创建目录 cd /usr/local/prometheus/conf mkdir -pv targets/{nodes,docker} 2.修改prome ...

  5. prometheus 基于DNS的目标发现

    prometheus 基于DNS的目标发现 DNS服务发现依赖于查询A.AAAA或SRV DNS记录. 1.基于 SRV 记录发现 scrape_configs: - job_name: 'webap ...

  6. Prometheus Consul实现自动服务发现

    Prometheus Consul实现自动服务发现   1.概述 Consul 是一个支持多数据中心分布式高可用的服务发现和配置共享的服务软件. Consul 由 HashiCorp公司用Go语言开发 ...

  7. Ocelot + Consul + Registrator 基于Docker 实现服务发现、服务自动注册

    目录 1. Consul集群搭建 1.1 F&Q Consul官方推荐的host网络模式运行 2. Registrator服务注册工具 2.1 F&Q Registrator悬挂服务 ...

  8. K8s基于DNS的服务发现(转)

    原文地址:https://www.oschina.net/question/2657833_2201246 1.Kubernetes中如何发现服务 ◆   发现Pod提供的服务 首先使用nginx-d ...

  9. prometheus服务发现机制

    一. Prometheus与服务发现 1.1 目前支持的服务发现方式 二. 案例 2.1 基于文件的服务发现 2.2 基于Consul的服务发现 三.本地测试 3.1 基于文件的服务发现 1.测试环境 ...

随机推荐

  1. Reinforcement Learning Solutions Ed2 Chapter 1 - 2 问题解答

    RL到了第三章题目多的不可思议 前两章比较简单,就在博客随便写写了.之后的用pdf更新. 1.1: Self-play will result different move even from the ...

  2. Java基础13-字符串缓冲流;字节流

    作业解析 描述HashMap内部实现原理 HashMap是一种存储机制,存储的是key-value对,key用来保证元素的唯一性.通过hash算法将要存储的对象打散,分布在不同的区间中. 当添加对象时 ...

  3. [mysql] 修复问题表Table '.xxxx' is marked as crashed and should be repaired

    程序执行的过程中,出现   Table '.xxxx' is marked as crashed and should be repaired 错误,上网查了一下,原来是表遭到损坏所致,具体修复办法如 ...

  4. [吐槽]webpack4

    https://webpack.js.org/guides/tree-shaking/ https://www.webpackjs.com/guides/ 插件都过时被替代了,中文文档也没更新过来,坑 ...

  5. 高德JSAPI获取当前所在位置的经度纬度

    这是在浏览器中的效果: 控制台打印出来的就是经度纬度的值 代码如下: <!doctype html> <html> <head> <meta charset= ...

  6. springmvc 控制器 读取properties文件

    配置文件app.properties如下: yt.api.url=http://localhost:9000 springmvc.xml 增加配置: <context:property-plac ...

  7. Mybatis 源码学习系列

    前言 很久以前,我们学习了Java,从一个控制台的 Hello world .开始,我们进入了面向对象的世界. 然后由学习了SQL语言,可以写出SQL语句来将尘封在硬盘之下的数据库数据,展现出来. 后 ...

  8. thinkPHP实现APP微信支付

    控制器 class Pay extends Controller { const WX_PAY_URL = "https://api.mch.weixin.qq.com/pay/unifie ...

  9. labview下载地址

    ftp://ftp.ni.com/evaluation/labview/ekit/other/downloader

  10. 给hive的metastore做JVM优化

    最近在测试环境下,hive的metastore不稳定,于是做一次JVM优化 在hive-env.sh中 export HADOOP_HOME=/opt/cdh/hadoop-2.6.0-cdh5.14 ...