Skip to content

Commit

Permalink
http_listener_v2: make http header tags case insensitive (influxdata#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ssoroka authored Aug 14, 2020
1 parent b8b6f2e commit b2eb774
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions plugins/inputs/http_listener_v2/http_listener_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ func (h *HTTPListenerV2) serveWrite(res http.ResponseWriter, req *http.Request)

for _, m := range metrics {
for headerName, measurementName := range h.HTTPHeaderTags {
headerValues, foundHeader := req.Header[headerName]
if foundHeader && len(headerValues) > 0 {
m.AddTag(measurementName, headerValues[0])
headerValues := req.Header.Get(headerName)
if len(headerValues) > 0 {
m.AddTag(measurementName, headerValues)
}
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/http_listener_v2/http_listener_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func TestWriteHTTPEmpty(t *testing.T) {

func TestWriteHTTPTransformHeaderValuesToTagsSingleWrite(t *testing.T) {
listener := newTestHTTPListenerV2()
listener.HTTPHeaderTags = map[string]string{"Present_http_header_1": "presentMeasurementKey1", "Present_http_header_2": "presentMeasurementKey2", "NOT_PRESENT_HEADER": "notPresentMeasurementKey"}
listener.HTTPHeaderTags = map[string]string{"Present_http_header_1": "presentMeasurementKey1", "present_http_header_2": "presentMeasurementKey2", "NOT_PRESENT_HEADER": "notPresentMeasurementKey"}

acc := &testutil.Accumulator{}
require.NoError(t, listener.Start(acc))
Expand Down
4 changes: 4 additions & 0 deletions testutil/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ package testutil

import (
"log"

"github.com/influxdata/telegraf"
)

var _ telegraf.Logger = &Logger{}

// Logger defines a logging structure for plugins.
type Logger struct {
Name string // Name is the plugin name, will be printed in the `[]`.
Expand Down

0 comments on commit b2eb774

Please sign in to comment.