mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Unification of logs/metrics/traces user interface (#25890)
Removes "Metrics"/"Logs" mode switcher from Explore, allowing for both metrics and logs queries at the same time. Co-authored-by: kay delaney <kay@grafana.com>
This commit is contained in:
@@ -233,8 +233,8 @@ describe('ElasticDatasource', function(this: any) {
|
||||
},
|
||||
],
|
||||
});
|
||||
// 1 for logs and 1 for counts.
|
||||
expect(response.data.length).toBe(2);
|
||||
|
||||
expect(response.data.length).toBe(1);
|
||||
const links = response.data[0].fields.find((field: Field) => field.name === 'host').config.links;
|
||||
expect(links.length).toBe(1);
|
||||
expect(links[0].url).toBe('http://localhost:3000/${__value.raw}');
|
||||
@@ -885,13 +885,13 @@ describe('enhanceDataFrame', () => {
|
||||
},
|
||||
]);
|
||||
|
||||
expect(df.fields[0].config.links.length).toBe(1);
|
||||
expect(df.fields[0].config.links[0]).toEqual({
|
||||
expect(df.fields[0].config.links?.length).toBe(1);
|
||||
expect(df.fields[0].config.links?.[0]).toEqual({
|
||||
title: '',
|
||||
url: 'someUrl',
|
||||
});
|
||||
expect(df.fields[1].config.links.length).toBe(1);
|
||||
expect(df.fields[1].config.links[0]).toEqual({
|
||||
expect(df.fields[1].config.links?.length).toBe(1);
|
||||
expect(df.fields[1].config.links?.[0]).toEqual({
|
||||
title: '',
|
||||
url: '',
|
||||
internal: {
|
||||
|
||||
@@ -365,7 +365,7 @@ export class ElasticDatasource extends DataSourceApi<ElasticsearchQuery, Elastic
|
||||
let queryObj;
|
||||
if (target.isLogsQuery || queryDef.hasMetricOfType(target, 'logs')) {
|
||||
target.bucketAggs = [queryDef.defaultBucketAgg()];
|
||||
target.metrics = [queryDef.defaultMetricAgg()];
|
||||
target.metrics = [];
|
||||
// Setting this for metrics queries that are typed as logs
|
||||
target.isLogsQuery = true;
|
||||
queryObj = this.queryBuilder.getLogsQuery(target, adhocFilters, queryString);
|
||||
|
||||
@@ -2,7 +2,14 @@ import _ from 'lodash';
|
||||
import flatten from 'app/core/utils/flatten';
|
||||
import * as queryDef from './query_def';
|
||||
import TableModel from 'app/core/table_model';
|
||||
import { DataQueryResponse, DataFrame, toDataFrame, FieldType, MutableDataFrame } from '@grafana/data';
|
||||
import {
|
||||
DataQueryResponse,
|
||||
DataFrame,
|
||||
toDataFrame,
|
||||
FieldType,
|
||||
MutableDataFrame,
|
||||
PreferredVisualisationType,
|
||||
} from '@grafana/data';
|
||||
import { ElasticsearchAggregation } from './types';
|
||||
|
||||
export class ElasticResponse {
|
||||
@@ -430,7 +437,7 @@ export class ElasticResponse {
|
||||
|
||||
const { propNames, docs } = flattenHits(response.hits.hits);
|
||||
if (docs.length > 0) {
|
||||
const series = createEmptyDataFrame(propNames, this.targets[0].timeField, logMessageField, logLevelField);
|
||||
let series = createEmptyDataFrame(propNames, this.targets[0].timeField, logMessageField, logLevelField);
|
||||
|
||||
// Add a row for each document
|
||||
for (const doc of docs) {
|
||||
@@ -443,6 +450,7 @@ export class ElasticResponse {
|
||||
series.add(doc);
|
||||
}
|
||||
|
||||
series = addPreferredVisualisationType(series, 'logs');
|
||||
dataFrame.push(series);
|
||||
}
|
||||
|
||||
@@ -578,7 +586,7 @@ const createEmptyDataFrame = (
|
||||
return series;
|
||||
};
|
||||
|
||||
const addPreferredVisualisationType = (series: any, type: string) => {
|
||||
const addPreferredVisualisationType = (series: any, type: PreferredVisualisationType) => {
|
||||
let s = series;
|
||||
s.meta
|
||||
? (s.meta.preferredVisualisationType = type)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { DataSourcePlugin } from '@grafana/data';
|
||||
import { ElasticDatasource } from './datasource';
|
||||
import { ElasticQueryCtrl } from './query_ctrl';
|
||||
import ElasticsearchQueryField from './components/ElasticsearchQueryField';
|
||||
import { ConfigEditor } from './configuration/ConfigEditor';
|
||||
|
||||
class ElasticAnnotationsQueryCtrl {
|
||||
@@ -11,5 +10,4 @@ class ElasticAnnotationsQueryCtrl {
|
||||
export const plugin = new DataSourcePlugin(ElasticDatasource)
|
||||
.setQueryCtrl(ElasticQueryCtrl)
|
||||
.setConfigEditor(ConfigEditor)
|
||||
.setExploreLogsQueryField(ElasticsearchQueryField)
|
||||
.setAnnotationQueryCtrl(ElasticAnnotationsQueryCtrl);
|
||||
|
||||
@@ -221,7 +221,7 @@ export class ElasticQueryBuilder {
|
||||
* Check if metric type is raw_document. If metric doesn't have size (or size is 0), update size to 500.
|
||||
* Otherwise it will not be a valid query and error will be thrown.
|
||||
*/
|
||||
if (target.metrics[0].type === 'raw_document') {
|
||||
if (target.metrics?.[0]?.type === 'raw_document') {
|
||||
metric = target.metrics[0];
|
||||
const size = (metric.settings && metric.settings.size !== 0 && metric.settings.size) || 500;
|
||||
return this.documentQuery(query, size);
|
||||
|
||||
Reference in New Issue
Block a user