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';
|
2022-04-22 21:33:13 +08:00
|
|
|
|
2022-01-31 14:57:14 +08:00
|
|
|
import { promQueryModeller } from '../PromQueryModeller';
|
2022-02-10 23:55:44 +08:00
|
|
|
import { buildVisualQueryFromString } from '../parsing';
|
2022-04-22 21:33:13 +08:00
|
|
|
import { OperationExplainedBox } from '../shared/OperationExplainedBox';
|
|
|
|
import { OperationListExplained } from '../shared/OperationListExplained';
|
|
|
|
import { PromVisualQuery } from '../types';
|
2022-01-31 14:57:14 +08:00
|
|
|
|
|
|
|
export interface Props {
|
2022-02-10 23:55:44 +08:00
|
|
|
query: string;
|
2022-01-31 14:57:14 +08:00
|
|
|
nested?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const PromQueryBuilderExplained = React.memo<Props>(({ query, nested }) => {
|
2022-02-10 23:55:44 +08:00
|
|
|
const visQuery = buildVisualQueryFromString(query || '').query;
|
|
|
|
|
2022-01-31 14:57:14 +08:00
|
|
|
return (
|
|
|
|
<Stack gap={0} direction="column">
|
2022-02-10 23:55:44 +08:00
|
|
|
<OperationExplainedBox
|
|
|
|
stepNumber={1}
|
|
|
|
title={`${visQuery.metric} ${promQueryModeller.renderLabels(visQuery.labels)}`}
|
|
|
|
>
|
2022-01-31 14:57:14 +08:00
|
|
|
Fetch all series matching metric name and label filters.
|
|
|
|
</OperationExplainedBox>
|
2022-02-10 23:55:44 +08:00
|
|
|
<OperationListExplained<PromVisualQuery> stepNumber={2} queryModeller={promQueryModeller} query={visQuery} />
|
2022-01-31 14:57:14 +08:00
|
|
|
</Stack>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
PromQueryBuilderExplained.displayName = 'PromQueryBuilderExplained';
|