-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add query-frontend option to select request headers in query logs (#1…
…1499) **What this PR does / why we need it**: Adding feature present in mimir, specifically grafana/mimir#5030. Adds a config option to the query-frontend to specify a list of request headers to include in query logs. For example, setting -frontend.log-query-request-headers="X-Grafana-Org-Id" and sending a query with X-Grafana-Org-Id:1 results in query log lines that include header_x_grafana_org_id=1. **Which issue(s) this PR fixes**: Fixes #11422
- Loading branch information
1 parent
b581db0
commit 0ed536c
Showing
4 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package transport | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestFormatRequestHeaders(t *testing.T) { | ||
h := http.Header{} | ||
h.Add("X-Header-To-Log", "i should be logged!") | ||
h.Add("X-Header-To-Not-Log", "i shouldn't be logged!") | ||
|
||
fields := formatRequestHeaders(&h, []string{"X-Header-To-Log", "X-Header-Not-Present"}) | ||
|
||
expected := []interface{}{ | ||
"header_x_header_to_log", | ||
"i should be logged!", | ||
} | ||
|
||
require.Equal(t, expected, fields) | ||
} |