Skip to content

Commit

Permalink
[BugFix][Change] Metric override fix for druid emitted metrics (#122)
Browse files Browse the repository at this point in the history
* Fixed metric overriding issue

Signed-off-by: iamabhishek-dubey <abhishekbhardwaj510@gmail.com>

* Fixed metric overriding issue

Signed-off-by: iamabhishek-dubey <abhishekbhardwaj510@gmail.com>

* Changed taskID to id

Signed-off-by: iamabhishek-dubey <abhishekbhardwaj510@gmail.com>

* Changed taskID to id

Signed-off-by: iamabhishek-dubey <abhishekbhardwaj510@gmail.com>

* Fixed code for listener endpoint

Signed-off-by: iamabhishek-dubey <abhishekbhardwaj510@gmail.com>

* Fixed code for listener endpoint

Signed-off-by: iamabhishek-dubey <abhishekbhardwaj510@gmail.com>

* Fixed code for listener endpoint

Signed-off-by: iamabhishek-dubey <abhishekbhardwaj510@gmail.com>
  • Loading branch information
iamabhishek-dubey authored Sep 19, 2021
1 parent 965c959 commit fe49869
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
### v0.11
##### September 19, 2021

#### :tada: Features

- Added metrics cleanup TTLS for cleaning up metrics from memory
- Support existing secret in helm chart
- Added support for extra environment variables

#### :beetle: Bug Fixes

- Fixed metrics overriding issue
- Helm testing is optional now

### v0.10
##### April 12, 2021

Expand Down
9 changes: 7 additions & 2 deletions listener/druid_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func DruidHTTPEndpoint(metricsCleanupTTL int, disableHistogram bool, histogram *
gaugeCleaner := newCleaner(gauge, metricsCleanupTTL)
return func(w http.ResponseWriter, req *http.Request) {
var druidData []map[string]interface{}
var id string
reqHeader, _ := header.ParseValueAndParams(req.Header, "Content-Type")
if req.Method == "POST" && reqHeader == "application/json" {
output, err := ioutil.ReadAll(req.Body)
Expand All @@ -45,9 +46,13 @@ func DruidHTTPEndpoint(metricsCleanupTTL int, disableHistogram bool, histogram *
service := fmt.Sprintf("%v", data["service"])
hostname := fmt.Sprintf("%v", data["host"])
datasource := data["dataSource"]
id := fmt.Sprintf("%v", data["id"])
value, _ := strconv.ParseFloat(fmt.Sprintf("%v", data["value"]), 64)

if data["id"] != nil {
id = fmt.Sprintf("%v", data["id"])
} else {
id = ""
}
// Reverse DNS Lookup
// Mutates dnsCache
hostValue := strings.Split(hostname, ":")[0]
Expand All @@ -62,7 +67,7 @@ func DruidHTTPEndpoint(metricsCleanupTTL int, disableHistogram bool, histogram *
logrus.Tracef(" hostname => (%s -> %s)", hostname, host)
logrus.Tracef(" datasource => %v", datasource)
logrus.Tracef(" value => %v", value)
logrus.Tracef(" id => %v", id)
logrus.Tracef(" id => %v", id)
}

if data["dataSource"] != nil {
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ var (
prometheus.HistogramOpts{
Name: "druid_emitted_metrics_histogram",
Help: "Druid emitted metrics from druid emitter",
}, []string{"host", "metric_name", "service", "datasource"},
}, []string{"host", "metric_name", "service", "datasource", "id"},
)
druidEmittedDataGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "druid_emitted_metrics",
Help: "Druid emitted metrics from druid emitter",
}, []string{"host", "metric_name", "service", "datasource"},
}, []string{"host", "metric_name", "service", "datasource", "id"},
)
)

Expand Down

0 comments on commit fe49869

Please sign in to comment.