作者:张富春(ahfuzhang),转载时请注明作者和引用链接,谢谢!


envoy这个组件的expoter路径为 /stats/prometheus,那么这样的特殊路径如何配置,才能让vm-agent抓取到?

  • 方法1:在 prometheus_cfg.yaml中使用static_config,对所有envoy配置 metric_path

    • 非常麻烦,而且需要让vm-agent不停加载配置
  • 方法2:使用filesd的方法来配置,然后在JSON中通过__metrics_path__字段指定特殊路径。
    • 不行,这个方法走不通
  • 方法3:使用httpsd来配置,然后在JSON中通过__metrics_path__字段指定特殊路径。
    • 这个方法OK

vm的源码中也能看出端倪:VictoriaMetrics-1.72.0-cluster/lib/promscrape/scrapework.go

// ScrapeWork represents a unit of work for scraping Prometheus metrics.
//
// It must be immutable during its lifetime, since it is read from concurrently running goroutines.
type ScrapeWork struct {
// Full URL (including query args) for the scrape.
ScrapeURL string // Interval for scraping the ScrapeURL.
ScrapeInterval time.Duration // Timeout for scraping the ScrapeURL.
ScrapeTimeout time.Duration // How to deal with conflicting labels.
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config
HonorLabels bool // How to deal with scraped timestamps.
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config
HonorTimestamps bool // Whether to deny redirects during requests to scrape config.
DenyRedirects bool // OriginalLabels contains original labels before relabeling.
//
// These labels are needed for relabeling troubleshooting at /targets page.
OriginalLabels []prompbmarshal.Label // Labels to add to the scraped metrics.
//
// The list contains at least the following labels according to https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config
//
// * job
// * __address__
// * __scheme__
// * __metrics_path__
// * __scrape_interval__
// * __scrape_timeout__
// * __param_<name>
// * __meta_*
// * user-defined labels set via `relabel_configs` section in `scrape_config`
//
// See also https://prometheus.io/docs/concepts/jobs_instances/
Labels []prompbmarshal.Label // ProxyURL HTTP proxy url
ProxyURL *proxy.URL // Auth config for ProxyUR:
ProxyAuthConfig *promauth.Config // Auth config
AuthConfig *promauth.Config // Optional `metric_relabel_configs`.
MetricRelabelConfigs *promrelabel.ParsedConfigs // The maximum number of metrics to scrape after relabeling.
SampleLimit int // Whether to disable response compression when querying ScrapeURL.
DisableCompression bool // Whether to disable HTTP keep-alive when querying ScrapeURL.
DisableKeepAlive bool // Whether to parse target responses in a streaming manner.
StreamParse bool // The interval for aligning the first scrape.
ScrapeAlignInterval time.Duration // The offset for the first scrape.
ScrapeOffset time.Duration // Optional limit on the number of unique series the scrape target can expose.
SeriesLimit int // The original 'job_name'
jobNameOriginal string
}

【解决了一个小问题】vm-agent中,如何对envoy这样的特殊expoter路径做处理?的更多相关文章

  1. 【解决了一个小问题】golang中引用一个路径较长的库,导致goland中出现"module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2"

    在项目中的go.mod文件中有这样一句: require ( github.com/xxx-devops/xx1/sdk/go v2.2.3 ) 项目的编译没有问题,但是goland中出现如下提示: ...

  2. mysql url 连接配置的一个小坑。 工作中不会遇到。 学习的时候会

    <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> & ...

  3. 【解决了一个小问题】golang protocol buffers 3中去掉json标签中的omitempty

    参考了这篇帖子:golang protobuf从生成的json标记中删除omitempty标记 由于是在windows上开发,因此写了一个python脚本来解决: remove_tag.py impo ...

  4. 【解决了一个小问题】golang gin框架中的模板,让模板中的参数不要做HTML转义

    代码中使用了类似的方式来向模板填充参数: c.HTML(200, "list.html", gin.H{"data":builder.String()}) 模板 ...

  5. 【解决了一个小问题】golang build中因为缓存文件损坏导致的编译错误

    编译的过程中出现了一个吓人的错误: GOROOT=C:\Go #gosetup GOPATH=C:\Users\ahfuzhang\go #gosetup C:\Go\bin\go.exe mod t ...

  6. 【解决了一个小问题】go.mod文件中引用另一个库,总会自动拉取新版本

    我的项目依赖某个旧的公共库: require ( git.xxx.com/myprj/mylib v0.0.43 ) 可以编译的时候,系统总会自动加上这样的路径: require ( git.xxx. ...

  7. 【解决了一个小问题】golang的go.mod中出现版本错误

    代码中的这一句使用prometheus2.28.0版本的代码: import "github.com/prometheus/prometheus/prompb" 我把require ...

  8. 【解决了一个小问题】golang samara的kafka客户端中使用错误版本号导致初始化失败

    发现在如下代码中存储kafka生产者初始化失败: config.Version = sarama.V0_10_2_1 //V2_2_0_0 producer, err := sarama.NewSyn ...

  9. 【解决了一个小问题】golang xorm中使用where id in (xxx),没办法使用参数替换

    代码中使用XORM来从数据库查询数据,有类似如下的代码: session.Where("id in (?)", strings,Join(arr, ",")) ...

  10. 【解决了一个小问题】gin框架中出现如下错误:"[GIN-debug] [WARNING] Headers were already written. Wanted to override status code 400 with 500"

    POST到数据到一条gin框架的接口后,客户端收到400错误,并且返回了业务中返回的"decode json fail". 关键代码是: func report(c *gin.Co ...

随机推荐

  1. kubernetes实战(三十一):Prometheus监控Windows主机

    1. 基本说明 使用Prometheus监控Windows主机和Linux主机并无太大区别,都是使用社区的Exporter进行采集数据,之后暴露一个接口,可以让Prometheus采集到主机的数据. ...

  2. 它来了!真正的 python 多线程

    哈喽大家好,我是咸鱼 几天前,IBM 工程师 Martin Heinz 发文表示 python 3.12 版本回引入"Per-Interpreter GIL",有了这个 Per-I ...

  3. vue.js 本地调用远程接口进行开发,如何进行跨域及cookie传递

    在前后端分离vue作为前端框架,在使用服务器接口时面临的第一个问题就是跨域.本文涉及内容仅保证在vue-cli3.0脚手架创建的项目中.及本地调试中有效(使用之前版本脚手架创建的项目请自行转换),本文 ...

  4. IntelliJ JSP 格式化问题

    Q: 当我尝试在 IntelliJ 中格式化一些 JSP 文件时,所有行都从头开始. A: 因为JSP是有关HTML和HTML以下标签的孩子html,body,thead,tbody,tfoot默认情 ...

  5. 使用 Python 参与算法竞赛

    引言 众所周知,打算法竞赛最频繁使用的语言是 C++.然而,对于那些不卡复杂度的题目,可以考虑使用 Python 编写(因为 Python 真的好写). 本文将简单地介绍一些 Python 使用技巧和 ...

  6. 【每日一题】31.「土」秘法地震 (二维前缀和 / DP)

    补题链接:Here 题意就是要找每一个 \(k * k\) 的小正方形里至少有一个1的数量 显然我们可以通过二维前缀和处理出(1, 1) 到 (n, m) 的数量 然后通过枚举处理出答案,具体思想是容 ...

  7. P1616-DP【橙】

    这道题好几天前就写出了记搜代码,但是理论上空间恰好够,实际上不论是用new-delete还是malloc-free,都有1~2个点MLE了(最抽象的是一开始MLE两个点,我把数组两个下标调换顺序后理应 ...

  8. P5719 水题

    https://www.luogu.com.cn/problem/P5719 唠唠:别看这题很水,且只要求保留小数点后一位,倘若用float而不是double的话就无法AC,洛谷评测则只有40分.所以 ...

  9. C#设计模式06——适配器的写法

    什么是适配器模式? 适配器模式是一种结构型设计模式,用于将现有接口转换为符合客户端期望的接口.适配器模式允许不兼容的类可以相互协作. 为什么需要适配器模式? 在实际开发中,经常会遇到需要复用一些已有的 ...

  10. PMP-干系人管理

    转载请注明出处: 1.分析干系人管理的两大工具 1.1.权力-利益方阵                          第一象限:严防死守(重点管理) 第二象限:投其所好(令其满意) 第三象限:保存 ...