指标设置默认值

This commit is contained in:
Liujian
2022-12-22 21:15:23 +08:00
parent 549f7ca13a
commit 4f8e88e88a
2 changed files with 10 additions and 2 deletions

View File

@@ -43,7 +43,11 @@ func ReadProxy(ctx http_context.IHttpContext) []IPoint {
"node": globalLabels["node_id"], "node": globalLabels["node_id"],
} }
for key, label := range labels { for key, label := range labels {
labelMetrics[key] = ctx.GetLabel(label) value := ctx.GetLabel(label)
if value == "" {
value = "-"
}
labelMetrics[key] = value
} }
for _, key := range proxyRequestMetrics { for _, key := range proxyRequestMetrics {

View File

@@ -38,7 +38,11 @@ func ReadRequest(ctx http_context.IHttpContext) []IPoint {
} }
for key, label := range labels { for key, label := range labels {
tags[key] = ctx.GetLabel(label) value := ctx.GetLabel(label)
if value == "" {
value = "-"
}
tags[key] = value
} }
for _, metrics := range requestMetrics { for _, metrics := range requestMetrics {
f, has := request[metrics] f, has := request[metrics]