mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Consolidate logs volume logic (full range and limited) * Fix showing limited histogram message * Test passing meta data to logs volume provider * Improve readability * Clean up types * Add basic support for multiple log volumes * Move the comment back to the right place * Improve readability * Clean up the logic to support Logs Samples * Update docs * Sort log volumes * Provide title to logs volume panel * Move logs volume cache to the provider factory * Add helper functions * Reuse only if queries are the same * Fix alphabetical sorting * Move caching out of the provider * Support errors and loading state * Remove unused code * Consolidate supplementary query utils * Add tests for supplementaryQueries * Update tests * Simplify logs volume extra info * Update tests * Remove comment * Update tests * Fix hiding the histogram for hidden queries * Simplify loading message * Update tests * Wait for full fallback histogram to load before showing it * Fix a typo * Add feedback comments * Move feedback comments to github * Do not filter out hidden queries as they may be used as references in other queries * Group log volume by refId * Support showing fallback histograms per query to avoid duplicates * Improve type-checking * Fix supplementaryQueries.test.ts * Fix logsModel.test.ts * Fix loading fallback results * Fix unit tests * WIP * Update deprecated styles * Simplify test * Simplify rendering zoom info * Update deprecated styles * Simplify getLogsVolumeDataSourceInfo * Simplify isLogsVolumeLimited() * Simplify rendering zoom info
128 lines
3.5 KiB
TypeScript
128 lines
3.5 KiB
TypeScript
import { css } from '@emotion/css';
|
|
import React from 'react';
|
|
|
|
import {
|
|
AbsoluteTimeRange,
|
|
DataQueryResponse,
|
|
LoadingState,
|
|
SplitOpen,
|
|
TimeZone,
|
|
EventBus,
|
|
isLogsVolumeLimited,
|
|
getLogsVolumeAbsoluteRange,
|
|
GrafanaTheme2,
|
|
getLogsVolumeDataSourceInfo,
|
|
} from '@grafana/data';
|
|
import { Icon, Tooltip, TooltipDisplayMode, useStyles2, useTheme2 } from '@grafana/ui';
|
|
|
|
import { ExploreGraph } from './Graph/ExploreGraph';
|
|
|
|
type Props = {
|
|
logsVolumeData: DataQueryResponse | undefined;
|
|
absoluteRange: AbsoluteTimeRange;
|
|
timeZone: TimeZone;
|
|
splitOpen: SplitOpen;
|
|
width: number;
|
|
onUpdateTimeRange: (timeRange: AbsoluteTimeRange) => void;
|
|
onLoadLogsVolume: () => void;
|
|
onHiddenSeriesChanged: (hiddenSeries: string[]) => void;
|
|
eventBus: EventBus;
|
|
};
|
|
|
|
export function LogsVolumePanel(props: Props) {
|
|
const { width, timeZone, splitOpen, onUpdateTimeRange, onHiddenSeriesChanged } = props;
|
|
const theme = useTheme2();
|
|
const styles = useStyles2(getStyles);
|
|
const spacing = parseInt(theme.spacing(2).slice(0, -2), 10);
|
|
const height = 150;
|
|
|
|
if (props.logsVolumeData === undefined) {
|
|
return null;
|
|
}
|
|
|
|
const logsVolumeData = props.logsVolumeData;
|
|
|
|
const logsVolumeInfo = getLogsVolumeDataSourceInfo(logsVolumeData?.data);
|
|
let extraInfo = logsVolumeInfo ? `${logsVolumeInfo.refId} (${logsVolumeInfo.name})` : '';
|
|
|
|
if (isLogsVolumeLimited(logsVolumeData.data)) {
|
|
extraInfo = [
|
|
extraInfo,
|
|
'This datasource does not support full-range histograms. The graph below is based on the logs seen in the response.',
|
|
].join('. ');
|
|
}
|
|
|
|
const range = isLogsVolumeLimited(logsVolumeData.data)
|
|
? getLogsVolumeAbsoluteRange(logsVolumeData.data, props.absoluteRange)
|
|
: props.absoluteRange;
|
|
|
|
let LogsVolumePanelContent;
|
|
|
|
if (logsVolumeData?.data) {
|
|
if (logsVolumeData.data.length > 0) {
|
|
LogsVolumePanelContent = (
|
|
<ExploreGraph
|
|
graphStyle="lines"
|
|
loadingState={logsVolumeData.state ?? LoadingState.Done}
|
|
data={logsVolumeData.data}
|
|
height={height}
|
|
width={width - spacing * 2}
|
|
absoluteRange={range}
|
|
onChangeTime={onUpdateTimeRange}
|
|
timeZone={timeZone}
|
|
splitOpenFn={splitOpen}
|
|
tooltipDisplayMode={TooltipDisplayMode.Multi}
|
|
onHiddenSeriesChanged={onHiddenSeriesChanged}
|
|
anchorToZero
|
|
eventBus={props.eventBus}
|
|
/>
|
|
);
|
|
} else {
|
|
LogsVolumePanelContent = <span>No volume data.</span>;
|
|
}
|
|
}
|
|
|
|
let extraInfoComponent = <span>{extraInfo}</span>;
|
|
|
|
if (logsVolumeData.state === LoadingState.Streaming) {
|
|
extraInfoComponent = (
|
|
<>
|
|
{extraInfoComponent}
|
|
<Tooltip content="Streaming">
|
|
<Icon name="circle-mono" size="md" className={styles.streaming} data-testid="logs-volume-streaming" />
|
|
</Tooltip>
|
|
</>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div style={{ height }} className={styles.contentContainer}>
|
|
{LogsVolumePanelContent}
|
|
{extraInfoComponent && <div className={styles.extraInfoContainer}>{extraInfoComponent}</div>}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const getStyles = (theme: GrafanaTheme2) => {
|
|
return {
|
|
extraInfoContainer: css`
|
|
display: flex;
|
|
justify-content: end;
|
|
position: absolute;
|
|
right: 5px;
|
|
top: -10px;
|
|
font-size: ${theme.typography.bodySmall.fontSize};
|
|
color: ${theme.colors.text.secondary};
|
|
`,
|
|
contentContainer: css`
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
position: relative;
|
|
`,
|
|
streaming: css`
|
|
color: ${theme.colors.success.text};
|
|
`,
|
|
};
|
|
};
|