Loki: Fix log samples using instant queries (#67271)

change log samples queryType to always be `range`
This commit is contained in:
Sven Grossmann 2023-04-26 13:26:07 +02:00 committed by GitHub
parent c962d3175b
commit d51e63520c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -932,8 +932,7 @@ describe('LokiDatasource', () => {
)
).toEqual({
expr: 'sum by (level) (count_over_time({label=value}[$__interval]))',
instant: false,
queryType: 'range',
queryType: LokiQueryType.Range,
refId: 'log-volume-A',
supportingQueryType: SupportingQueryType.LogsVolume,
});
@ -997,7 +996,7 @@ describe('LokiDatasource', () => {
)
).toEqual({
expr: '{label=value}',
queryType: 'instant',
queryType: LokiQueryType.Range,
refId: 'log-sample-A',
maxLines: 20,
});
@ -1015,7 +1014,7 @@ describe('LokiDatasource', () => {
)
).toEqual({
expr: '{label=value}',
queryType: 'instant',
queryType: LokiQueryType.Range,
refId: 'log-sample-A',
maxLines: 5,
});

View File

@ -193,7 +193,7 @@ export class LokiDatasource
return {
...normalizedQuery,
refId: `${REF_ID_STARTER_LOG_VOLUME}${normalizedQuery.refId}`,
instant: false,
queryType: LokiQueryType.Range,
supportingQueryType: SupportingQueryType.LogsVolume,
expr: `sum by (level) (count_over_time(${expr}[$__interval]))`,
};
@ -206,6 +206,7 @@ export class LokiDatasource
}
return {
...normalizedQuery,
queryType: LokiQueryType.Range,
refId: `${REF_ID_STARTER_LOG_SAMPLE}${normalizedQuery.refId}`,
expr: getLogQueryFromMetricsQuery(expr),
maxLines: Number.isNaN(Number(options.limit)) ? this.maxLines : Number(options.limit),