未验证 提交 90db12b5 编写于 作者: X xtan 提交者: GitHub

Fix:fix target_up nodata judge for prometheus scrape (#986)

上级 7d326ef3
......@@ -22,6 +22,14 @@ import (
"github.com/didi/nightingale/v5/src/server/writer"
)
var promMetricFilter map[string]bool = map[string]bool{
"up": true,
"scrape_series_added": true,
"scrape_samples_post_metric_relabeling": true,
"scrape_samples_scraped": true,
"scrape_duration_seconds": true,
}
type promqlForm struct {
PromQL string `json:"promql"`
}
......@@ -90,6 +98,14 @@ func remoteWrite(c *gin.Context) {
}
}
// 当数据是通过prometheus抓取(也许直接remote write到夜莺)的时候,prometheus会自动产生部分系统指标
// 例如最典型的有up指标,是prometheus为exporter生成的指标,即使exporter挂掉的时候也会送up=0的指标
// 此类指标当剔除,否则会导致redis数据中时间戳被意外更新,导致由此类指标中携带的ident的相关target_up指标无法变为实际的0值
// 更多详细信息:https://prometheus.io/docs/concepts/jobs_instances/#automatically-generated-labels-and-time-series
if _, has := promMetricFilter[metric]; has {
ident = ""
}
if len(ident) > 0 {
// register host
ids[ident] = now
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册