|
|
|
@ -923,11 +923,14 @@ describe('LokiDatasource', () => { |
|
|
|
|
describe('logs volume', () => { |
|
|
|
|
it('returns logs volume query for range log query', () => { |
|
|
|
|
expect( |
|
|
|
|
ds.getSupplementaryQuery(SupplementaryQueryType.LogsVolume, { |
|
|
|
|
expr: '{label=value}', |
|
|
|
|
queryType: LokiQueryType.Range, |
|
|
|
|
refId: 'A', |
|
|
|
|
}) |
|
|
|
|
ds.getSupplementaryQuery( |
|
|
|
|
{ type: SupplementaryQueryType.LogsVolume }, |
|
|
|
|
{ |
|
|
|
|
expr: '{label=value}', |
|
|
|
|
queryType: LokiQueryType.Range, |
|
|
|
|
refId: 'A', |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
).toEqual({ |
|
|
|
|
expr: 'sum by (level) (count_over_time({label=value}[$__interval]))', |
|
|
|
|
instant: false, |
|
|
|
@ -939,21 +942,27 @@ describe('LokiDatasource', () => { |
|
|
|
|
|
|
|
|
|
it('does not return logs volume query for instant log query', () => { |
|
|
|
|
expect( |
|
|
|
|
ds.getSupplementaryQuery(SupplementaryQueryType.LogsVolume, { |
|
|
|
|
expr: '{label=value}', |
|
|
|
|
queryType: LokiQueryType.Instant, |
|
|
|
|
refId: 'A', |
|
|
|
|
}) |
|
|
|
|
ds.getSupplementaryQuery( |
|
|
|
|
{ type: SupplementaryQueryType.LogsVolume }, |
|
|
|
|
{ |
|
|
|
|
expr: '{label=value}', |
|
|
|
|
queryType: LokiQueryType.Instant, |
|
|
|
|
refId: 'A', |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
).toEqual(undefined); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('does not return logs volume query for metric query', () => { |
|
|
|
|
expect( |
|
|
|
|
ds.getSupplementaryQuery(SupplementaryQueryType.LogsVolume, { |
|
|
|
|
expr: 'rate({label=value}[5m]', |
|
|
|
|
queryType: LokiQueryType.Range, |
|
|
|
|
refId: 'A', |
|
|
|
|
}) |
|
|
|
|
ds.getSupplementaryQuery( |
|
|
|
|
{ type: SupplementaryQueryType.LogsVolume }, |
|
|
|
|
{ |
|
|
|
|
expr: 'rate({label=value}[5m]', |
|
|
|
|
queryType: LokiQueryType.Range, |
|
|
|
|
refId: 'A', |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
).toEqual(undefined); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
@ -961,41 +970,68 @@ describe('LokiDatasource', () => { |
|
|
|
|
describe('logs sample', () => { |
|
|
|
|
it('returns logs sample query for range metric query', () => { |
|
|
|
|
expect( |
|
|
|
|
ds.getSupplementaryQuery(SupplementaryQueryType.LogsSample, { |
|
|
|
|
expr: 'rate({label=value}[5m]', |
|
|
|
|
queryType: LokiQueryType.Range, |
|
|
|
|
refId: 'A', |
|
|
|
|
}) |
|
|
|
|
ds.getSupplementaryQuery( |
|
|
|
|
{ type: SupplementaryQueryType.LogsSample }, |
|
|
|
|
{ |
|
|
|
|
expr: 'rate({label=value}[5m]', |
|
|
|
|
queryType: LokiQueryType.Range, |
|
|
|
|
refId: 'A', |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
).toEqual({ |
|
|
|
|
expr: '{label=value}', |
|
|
|
|
queryType: 'range', |
|
|
|
|
refId: 'log-sample-A', |
|
|
|
|
maxLines: 100, |
|
|
|
|
maxLines: 20, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('returns logs sample query for instant metric query', () => { |
|
|
|
|
expect( |
|
|
|
|
ds.getSupplementaryQuery(SupplementaryQueryType.LogsSample, { |
|
|
|
|
expr: 'rate({label=value}[5m]', |
|
|
|
|
queryType: LokiQueryType.Instant, |
|
|
|
|
refId: 'A', |
|
|
|
|
}) |
|
|
|
|
ds.getSupplementaryQuery( |
|
|
|
|
{ type: SupplementaryQueryType.LogsSample }, |
|
|
|
|
{ |
|
|
|
|
expr: 'rate({label=value}[5m]', |
|
|
|
|
queryType: LokiQueryType.Instant, |
|
|
|
|
refId: 'A', |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
).toEqual({ |
|
|
|
|
expr: '{label=value}', |
|
|
|
|
queryType: 'instant', |
|
|
|
|
refId: 'log-sample-A', |
|
|
|
|
maxLines: 100, |
|
|
|
|
maxLines: 20, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('correctly overrides maxLines if limit is set', () => { |
|
|
|
|
expect( |
|
|
|
|
ds.getSupplementaryQuery( |
|
|
|
|
{ type: SupplementaryQueryType.LogsSample, limit: 5 }, |
|
|
|
|
{ |
|
|
|
|
expr: 'rate({label=value}[5m]', |
|
|
|
|
queryType: LokiQueryType.Instant, |
|
|
|
|
refId: 'A', |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
).toEqual({ |
|
|
|
|
expr: '{label=value}', |
|
|
|
|
queryType: 'instant', |
|
|
|
|
refId: 'log-sample-A', |
|
|
|
|
maxLines: 5, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('does not return logs sample query for log query query', () => { |
|
|
|
|
expect( |
|
|
|
|
ds.getSupplementaryQuery(SupplementaryQueryType.LogsSample, { |
|
|
|
|
expr: '{label=value}', |
|
|
|
|
queryType: LokiQueryType.Range, |
|
|
|
|
refId: 'A', |
|
|
|
|
}) |
|
|
|
|
ds.getSupplementaryQuery( |
|
|
|
|
{ type: SupplementaryQueryType.LogsSample }, |
|
|
|
|
{ |
|
|
|
|
expr: '{label=value}', |
|
|
|
|
queryType: LokiQueryType.Range, |
|
|
|
|
refId: 'A', |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
).toEqual(undefined); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|