亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 prometheus/client_golang 中禁用 go_collector 指標

如何在 prometheus/client_golang 中禁用 go_collector 指標

Go
喵喔喔 2021-12-07 17:06:08
我正在使用 NewGaugeVec 來報告我的指標:elapsed := prometheus.NewGaugeVec(prometheus.GaugeOpts{    Name: "gogrinder_elapsed_ms",    Help: "Current time elapsed of gogrinder teststep",}, []string{"teststep", "user", "iteration", "timestamp"})prometheus.MustRegister(elapsed)一切正常,但我注意到我的自定義導出器包含來自 prometheus/go_collector.go 的所有指標:# HELP go_gc_duration_seconds A summary of the GC invocation durations.# TYPE go_gc_duration_seconds summarygo_gc_duration_seconds{quantile="0"} 0.00041795300000000004go_gc_duration_seconds{quantile="0.25"} 0.00041795300000000004go_gc_duration_seconds{quantile="0.5"} 0.00041795300000000004...我懷疑這是一種默認行為,但我沒有在文檔中找到有關如何禁用它的任何內容。關于如何配置我的自定義導出器以便這些默認指標消失的任何想法?
查看完整描述

3 回答

?
明月笑刀無情

TA貢獻1828條經驗 獲得超4個贊

好吧,這個話題已經很老了,但以防萬一其他人不得不處理它。以下代碼適用于當前代碼庫v0.9.0-pre1


// [...] imports, metric initialization ...


func main() {

  // go get rid of any additional metrics 

  // we have to expose our metrics with a custom registry

  r := prometheus.NewRegistry()

  r.MustRegister(myMetrics)

  handler := promhttp.HandlerFor(r, promhttp.HandlerOpts{})


  // [...] update metrics within a goroutine


  http.Handle("/metrics", handler)

  log.Fatal(http.ListenAndServe(":12345", nil))

}


查看完整回答
反對 回復 2021-12-07
?
一只萌萌小番薯

TA貢獻1795條經驗 獲得超7個贊

這在 Go 客戶端中目前是不可能的,一旦https://github.com/prometheus/client_golang/issues/46完成,您將有辦法做到這一點。

一般來說,您希望您的自定義導出器導出這些,我知道目前沒有意義的唯一導出器是 snmp 和 blackbox 導出器。

順便說一句,timestamp作為標簽似乎很奇怪,如果你想要的話,你可能應該使用日志記錄而不是指標。請參閱https://blog.raintank.io/logs-and-metrics-and-graphs-oh-my/ 普羅米修斯的方式是將時間戳作為一個值,而不是一個標簽。


查看完整回答
反對 回復 2021-12-07
?
智慧大石

TA貢獻1946條經驗 獲得超3個贊

--web.disable-exporter-metrics現在可以使用了。

https://github.com/prometheus/node_exporter/pull/1148


查看完整回答
反對 回復 2021-12-07
  • 3 回答
  • 0 關注
  • 529 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號