2022-01-31 14:57:14 +08:00
|
|
|
import React from 'react';
|
2022-04-22 21:33:13 +08:00
|
|
|
|
2022-01-31 14:57:14 +08:00
|
|
|
import { Stack } from '@grafana/experimental';
|
|
|
|
import { OperationExplainedBox } from 'app/plugins/datasource/prometheus/querybuilder/shared/OperationExplainedBox';
|
2022-04-22 21:33:13 +08:00
|
|
|
import { OperationListExplained } from 'app/plugins/datasource/prometheus/querybuilder/shared/OperationListExplained';
|
|
|
|
|
|
|
|
import { lokiQueryModeller } from '../LokiQueryModeller';
|
2022-04-14 16:59:39 +08:00
|
|
|
import { buildVisualQueryFromString } from '../parsing';
|
2022-04-22 21:33:13 +08:00
|
|
|
import { LokiVisualQuery } from '../types';
|
2022-01-31 14:57:14 +08:00
|
|
|
|
|
|
|
export interface Props {
|
2022-04-14 16:59:39 +08:00
|
|
|
query: string;
|
2022-01-31 14:57:14 +08:00
|
|
|
nested?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const LokiQueryBuilderExplained = React.memo<Props>(({ query, nested }) => {
|
2022-04-14 16:59:39 +08:00
|
|
|
const visQuery = buildVisualQueryFromString(query || '').query;
|
|
|
|
|
2022-01-31 14:57:14 +08:00
|
|
|
return (
|
|
|
|
<Stack gap={0} direction="column">
|
2022-04-14 16:59:39 +08:00
|
|
|
<OperationExplainedBox stepNumber={1} title={`${lokiQueryModeller.renderLabels(visQuery.labels)}`}>
|
2022-01-31 14:57:14 +08:00
|
|
|
Fetch all log lines matching label filters.
|
|
|
|
</OperationExplainedBox>
|
2022-04-14 16:59:39 +08:00
|
|
|
<OperationListExplained<LokiVisualQuery> stepNumber={2} queryModeller={lokiQueryModeller} query={visQuery} />
|
2022-01-31 14:57:14 +08:00
|
|
|
</Stack>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
LokiQueryBuilderExplained.displayName = 'LokiQueryBuilderExplained';
|