Skip to content

Commit

Permalink
fixbug, ignore hostname not effective, use OmitHostname (#828)
Browse files Browse the repository at this point in the history
* fixbug, ignore hostname not effective, use `OmitHostname`

* Revert "fixbug, ignore hostname not effective, use `OmitHostname`"

This reverts commit 0655538.

* fixbug, add config for ignore hostname and labels

---------

Co-authored-by: xuxiaobing <[email protected]>
  • Loading branch information
worker24h and xuxiaobing authored Mar 14, 2024
1 parent c56e5f9 commit 0c0e292
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 17 deletions.
4 changes: 2 additions & 2 deletions api/router_falcon.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ func openFalcon(c *gin.Context) {
ts = time.Now().Unix()
)

ignoreHostname := c.GetBool("ignore_hostname")
ignoreGlobalLabels := c.GetBool("ignore_global_labels")
ignoreHostname := config.Config.HTTP.IgnoreHostname
ignoreGlobalLabels := config.Config.HTTP.IgnoreGlobalLabels
count := len(arr)
series := make([]prompb.TimeSeries, 0, count)
for i := 0; i < count; i++ {
Expand Down
4 changes: 2 additions & 2 deletions api/router_opentsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ func openTSDB(c *gin.Context) {
ts = time.Now().Unix()
)

ignoreHostname := c.GetBool("ignore_hostname")
ignoreGlobalLabels := c.GetBool("ignore_global_labels")
ignoreHostname := config.Config.HTTP.IgnoreHostname
ignoreGlobalLabels := config.Config.HTTP.IgnoreGlobalLabels
count := len(list)
series := make([]prompb.TimeSeries, 0, count)
for i := 0; i < len(list); i++ {
Expand Down
4 changes: 2 additions & 2 deletions api/router_pushgateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func pushgateway(c *gin.Context) {
return
}

ignoreHostname := c.GetBool("ignore_hostname")
ignoreGlobalLabels := c.GetBool("ignore_global_labels")
ignoreHostname := config.Config.HTTP.IgnoreHostname
ignoreGlobalLabels := config.Config.HTTP.IgnoreGlobalLabels

now := time.Now()

Expand Down
4 changes: 2 additions & 2 deletions api/router_remotewrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func remoteWrite(c *gin.Context) {
return
}

ignoreHostname := c.GetBool("ignore_hostname")
ignoreGlobalLabels := c.GetBool("ignore_global_labels")
ignoreHostname := config.Config.HTTP.IgnoreHostname
ignoreGlobalLabels := config.Config.HTTP.IgnoreGlobalLabels
for i := 0; i < count; i++ {
// 去除重复的数据
if duplicateLabelKey(req.Timeseries[i]) {
Expand Down
3 changes: 3 additions & 0 deletions conf/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ providers = ["local"]
# However, utilizing the concurrency setting can help mitigate this issue and optimize the response time.
concurrency = -1

# Setting http.ignore_global_labels = true if disabled report custom labels
[global.labels]
# region = "shanghai"
# env = "localhost"
Expand Down Expand Up @@ -80,6 +81,8 @@ enable = false
address = ":9100"
print_access = false
run_mode = "release"
ignore_hostname = false
ignore_global_labels = false

[ibex]
enable = false
Expand Down
20 changes: 11 additions & 9 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,17 @@ type WriterOption struct {
}

type HTTP struct {
Enable bool `toml:"enable"`
Address string `toml:"address"`
PrintAccess bool `toml:"print_access"`
RunMode string `toml:"run_mode"`
CertFile string `toml:"cert_file"`
KeyFile string `toml:"key_file"`
ReadTimeout int `toml:"read_timeout"`
WriteTimeout int `toml:"write_timeout"`
IdleTimeout int `toml:"idle_timeout"`
Enable bool `toml:"enable"`
Address string `toml:"address"`
PrintAccess bool `toml:"print_access"`
RunMode string `toml:"run_mode"`
IgnoreHostname bool `toml:"ignore_hostname"`
IgnoreGlobalLabels bool `toml:"ignore_global_labels"`
CertFile string `toml:"cert_file"`
KeyFile string `toml:"key_file"`
ReadTimeout int `toml:"read_timeout"`
WriteTimeout int `toml:"write_timeout"`
IdleTimeout int `toml:"idle_timeout"`
}

type IbexConfig struct {
Expand Down

0 comments on commit 0c0e292

Please sign in to comment.