Add additional tests for #365

testing more edge cases.

Signed-off-by: Matthias Rampke <matthias@prometheus.io>
This commit is contained in:
Matthias Rampke 2021-03-26 16:54:29 +00:00
parent 0c4a66e6a1
commit 5793e05795
No known key found for this signature in database
GPG key ID: F9AFF7F67ACE10BA

View file

@ -338,7 +338,7 @@ mappings:
}, },
}, },
{ {
testName: "Match metric segment starting with a number", testName: "Match metric segment with a number",
config: ` config: `
mappings: mappings:
- match: test.99.myapp.* - match: test.99.myapp.*
@ -357,7 +357,26 @@ mappings:
}, },
}, },
{ {
testName: "Match metric segment starting with a number #328 example", testName: "Match metric segment starting with a number",
config: `
mappings:
- match: test.99test.myapp.*
name: "name"
labels:
label: "${1}_foo"
`,
mappings: mappings{
{
statsdMetric: "test.99test.myapp.create",
name: "name",
labels: map[string]string{
"label": "create_foo",
},
},
},
},
{
testName: "Match metric segment with a number #328 example",
config: ` config: `
mappings: mappings:
- match: kafka.server.FetcherStats.brokerHost.hostname.brokerPort.9092.clientId.ReplicaFetcherThread-0-1.BytesPerSec.1MinuteRate.gauge - match: kafka.server.FetcherStats.brokerHost.hostname.brokerPort.9092.clientId.ReplicaFetcherThread-0-1.BytesPerSec.1MinuteRate.gauge
@ -370,6 +389,25 @@ mappings:
}, },
}, },
}, },
{
testName: "Single segment match",
config: `
mappings:
- match: '*'
name: single_segment
labels:
label: "${1}"
`,
mappings: mappings{
{
statsdMetric: "test",
name: "single_segment",
labels: map[string]string{
"label": "test",
},
},
},
},
{ {
testName: "Config with bad metric line", testName: "Config with bad metric line",
config: `--- config: `---