-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(kuma-dp) pass query parameters through the metrics hijacker (#2124)
The Envoy Prometheus endpoint supports passing a filtering regex in the query parameters to limit the set of metrics that are returned. This feature lets a metrics scraper scrape different sets of metrics at different intervals. This updates #1755. Signed-off-by: James Peach <james.peach@konghq.com>
- Loading branch information
Showing
4 changed files
with
66 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package metrics_test | ||
package metrics | ||
|
||
import ( | ||
"testing" | ||
|
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,35 @@ | ||
package metrics | ||
|
||
import ( | ||
"net/url" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/ginkgo/extensions/table" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Rewriting the metrics URL", func() { | ||
type testCase struct { | ||
input string | ||
adminPort uint32 | ||
expected string | ||
} | ||
DescribeTable("should", | ||
func(given testCase) { | ||
u, err := url.Parse(given.input) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
Expect(rewriteMetricsURL(given.adminPort, u)).Should(Equal(given.expected)) | ||
}, | ||
Entry("use the admin port", testCase{ | ||
input: "http://foo/bar", | ||
adminPort: 99, | ||
expected: "http://127.0.0.1:99/stats/prometheus", | ||
}), | ||
Entry("preserve query parameters", testCase{ | ||
input: "http://foo/bar?one=two&three=four", | ||
adminPort: 80, | ||
expected: "http://127.0.0.1:80/stats/prometheus?one=two&three=four", | ||
}), | ||
) | ||
}) |