prometheus 自定义服务发现的几种实现方法

prometheus 具有强大的生态系统,同时也已经内置了好多服务发现的支持(file,consul,k8s,ec2,dns,openstack,....)

自己开发自定义的服务发现机制

官方提供了参考的说明文档,主要的问题是我们需要修改prometheus 的代码,同时自己进行构建,很多时候我们会失去新特性的支持 
很不灵活

与现有内置的服务发现机制做适配

方法就很多了,我们可以通过api 将需要监控的节点信息写入consul,或者基于文件的服务发现模式写好标准的文件,使用prometheus 内置 
的特性,可以灵活的扩展

使用类似vmagent push 模式的工具

vmagent 是一个很不错的prometheus 周边扩展,可以将pull 模式修改为push,这样我就剋一不用修改prometheus 了,需要做的只是调整agent 
pushgateway 也是一个选择的方案,实际我们可以结合实际使用的工具以及场景,选择不同的工具,vmagent是一个不错的选择,但是如果使用了 
vmagent我们就需要使用一个支持prometheus remote 协议的存储系统了

说明

如果需要进行自定义服务发现的开发,还是比较推荐的基于与内置服务发现适配的模式,这样方便系统的升级以及保持与上游的同步

参考资料

https://prometheus.io/blog/2018/07/05/implementing-custom-sd/#custom-sd-implementation 
https://github.com/prometheus/prometheus/blob/master/prompb/remote.proto 
https://prometheus.io/docs/prometheus/latest/configuration/configuration/#remote_write 
https://prometheus.io/docs/prometheus/latest/configuration/configuration/#remote_read 
https://prometheus.io/docs/prometheus/latest/storage/ 
https://github.com/VictoriaMetrics/VictoriaMetrics/wiki/vmagent 
https://github.com/prometheus/pushgateway 
https://github.com/prometheus/prometheus/tree/master/documentation/examples/remote_storage/remote_storage_adapter

posted on   荣锋亮  阅读(1923)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2019-08-17 Centrifugo  语言无关的实时消息服务
2018-08-17 harbor rest api 转graphql api
2018-08-17 ringojs java jar 集成使用
2018-08-17 ringojs 使用rp 包管理web 应用依赖
2018-08-17 ringojs 的包管理
2017-08-17 keycloak && docker安装 &&spring boot 集成使用
2017-08-17 gogs docker 安装

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示