From bb43e34484a744013b9e049c45b257e9ce0f687a Mon Sep 17 00:00:00 2001 From: tianyanli Date: Thu, 27 Jun 2024 22:06:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/router_pushgateway.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/router_pushgateway.go b/api/router_pushgateway.go index e50ab387..15ed1061 100644 --- a/api/router_pushgateway.go +++ b/api/router_pushgateway.go @@ -71,9 +71,9 @@ func pushgateway(c *gin.Context) { ignoreHostname := config.Config.HTTP.IgnoreHostname || c.GetBool("ignore_hostname") ignoreGlobalLabels := config.Config.HTTP.IgnoreGlobalLabels || c.GetBool("ignore_global_labels") // 获取 AgentHostTag 的值 - AgentHostTag := config.Config.HTTP.AgentHostTag - if AgentHostTag == "" { - AgentHostTag = c.GetString("agent_host_tag") + agentHostTag := config.Config.HTTP.AgentHostTag + if agentHostTag == "" { + agentHostTag = c.GetString("agent_host_tag") } now := time.Now() @@ -102,13 +102,13 @@ func pushgateway(c *gin.Context) { // add label: agent_hostname if !ignoreHostname { - if AgentHostTag == "" { + if agentHostTag == "" { if _, has := samples[i].Labels[agentHostnameLabelKey]; !has { samples[i].Labels[agentHostnameLabelKey] = config.Config.GetHostname() } } else { // 从当前现有的 Labels 中找到 key 等于 config.Config.HTTP.AgentHostTag 的值 - if value, exists := samples[i].Labels[AgentHostTag]; exists { + if value, exists := samples[i].Labels[agentHostTag]; exists { samples[i].Labels[agentHostnameLabelKey] = value } }