Explore/Loki: Show results of instant queries only in table and time series only in graph (#25845)

* Show results of instant queries only in table and rest in graph

* Add type to QueryResultMeta

* Update log row hover background only if context is not open

* Revert "Update log row hover background only if context is not open"

This reverts commit 144197c954.
This commit is contained in:
Ivana Huckova
2020-06-30 09:25:05 +02:00
committed by GitHub
parent 6eabe6c29f
commit 69f9b6f945
3 changed files with 20 additions and 3 deletions

View File

@@ -4,7 +4,7 @@ import { Observable, from, merge, of } from 'rxjs';
import { map, filter, catchError, switchMap } from 'rxjs/operators';
// Services & Utils
import { DataFrame, dateMath, FieldCache } from '@grafana/data';
import { DataFrame, dateMath, FieldCache, QueryResultMeta } from '@grafana/data';
import { getBackendSrv } from '@grafana/runtime';
import { addLabelToQuery } from 'app/plugins/datasource/prometheus/add_label_to_query';
import { DatasourceRequestOptions } from 'app/core/services/backend_srv';
@@ -140,6 +140,10 @@ export class LokiDatasource extends DataSourceApi<LokiQuery, LokiOptions> {
time: `${timeNs + (1e9 - (timeNs % 1e9))}`,
limit: Math.min(options.maxDataPoints || Infinity, this.maxLines),
};
/** Show results of Loki instant queries only in table */
const meta: QueryResultMeta = {
preferredVisualisationType: 'table',
};
return this._request(INSTANT_QUERY_ENDPOINT, query).pipe(
catchError((err: any) => this.throwUnless(err, err.cancelled, target)),
@@ -150,7 +154,7 @@ export class LokiDatasource extends DataSourceApi<LokiQuery, LokiOptions> {
}
return {
data: [lokiResultsToTableModel(response.data.data.result, responseListLength, target.refId, true)],
data: [lokiResultsToTableModel(response.data.data.result, responseListLength, target.refId, meta, true)],
key: `${target.refId}_instant`,
};
})