Explore: Add feature to open log sample in split view (#62097)

* Add tests

* Implement split open to see logs functionality

* Fix imports in test

* Update packages/grafana-data/src/types/logs.ts

Co-authored-by: Matias Chomicki <matyax@gmail.com>

* Update packages/grafana-data/src/types/logs.ts

Co-authored-by: Matias Chomicki <matyax@gmail.com>

* Update default scneario to throw error

* Exit early in getSupplementaryQuery

* Update public/app/features/explore/LogsSamplePanel.tsx

Co-authored-by: Matias Chomicki <matyax@gmail.com>
This commit is contained in:
Ivana Huckova
2023-01-26 16:06:10 +01:00
committed by GitHub
parent 5e1dc22f88
commit ea1fcbb866
10 changed files with 392 additions and 109 deletions

View File

@@ -15,6 +15,7 @@ import {
FieldType,
MutableDataFrame,
RawTimeRange,
SupplementaryQueryType,
TimeRange,
toUtc,
} from '@grafana/data';
@@ -924,6 +925,56 @@ describe('ElasticDatasource', () => {
expect((interpolatedQuery.bucketAggs![0] as Filters).settings!.filters![0].query).toBe('*');
});
describe('getSupplementaryQuery', () => {
let ds: ElasticDatasource;
beforeEach(() => {
ds = getTestContext().ds;
});
it('does not return logs volume query for metric query', () => {
expect(
ds.getSupplementaryQuery(SupplementaryQueryType.LogsVolume, {
refId: 'A',
metrics: [{ type: 'count', id: '1' }],
bucketAggs: [{ type: 'filters', settings: { filters: [{ query: 'foo', label: '' }] }, id: '1' }],
query: 'foo="bar"',
})
).toEqual(undefined);
});
it('returns logs volume query for log query', () => {
expect(
ds.getSupplementaryQuery(SupplementaryQueryType.LogsVolume, {
refId: 'A',
metrics: [{ type: 'logs', id: '1' }],
query: 'foo="bar"',
})
).toEqual({
bucketAggs: [
{
field: '',
id: '3',
settings: {
interval: 'auto',
min_doc_count: '0',
trimEdges: '0',
},
type: 'date_histogram',
},
],
metrics: [
{
id: '1',
type: 'count',
},
],
query: 'foo="bar"',
refId: 'log-volume-A',
timeField: '',
});
});
});
});
describe('getMultiSearchUrl', () => {