Explore: Match queries that are longer than defined Graphite/Loki mapping (#34003)

This commit is contained in:
Piotr Jamróz 2021-05-12 16:10:38 +02:00 committed by GitHub
parent a7efe19167
commit 6ac43130f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -49,7 +49,7 @@ function fromGraphite(graphiteQuery: GraphiteQueryModel, config: GraphiteToLokiQ
});
} else {
const targetNodes = graphiteQuery.segments.map((segment) => segment.value);
let mappings = config.mappings.filter((mapping) => mapping.matchers.length === targetNodes.length);
let mappings = config.mappings.filter((mapping) => mapping.matchers.length <= targetNodes.length);
for (let mapping of mappings) {
const matchers = mapping.matchers.concat();

View File

@ -40,6 +40,7 @@ describe('importing from Graphite queries', () => {
[
// metrics: captured
mockGraphiteQuery('interpolate(alias(servers.west.001.cpu,1,2))'),
mockGraphiteQuery('interpolate(alias(servers.east.001.request.POST.200,1,2))'),
mockGraphiteQuery('interpolate(alias(servers.*.002.*,1,2))'),
// tags: captured
mockGraphiteQuery("interpolate(seriesByTag('cluster=west', 'server=002'), inf))"),
@ -53,6 +54,7 @@ describe('importing from Graphite queries', () => {
expect(lokiQueries).toMatchObject([
{ refId: 'A', expr: '{cluster="west", server="001"}' },
{ refId: 'A', expr: '{cluster="east", server="001"}' },
{ refId: 'A', expr: '{server="002"}' },
{ refId: 'A', expr: '{cluster="west", server="002"}' },
{ refId: 'A', expr: '{foo="bar", server="002"}' },