mirror of
https://github.com/SigNoz/signoz.git
synced 2026-11-24 09:10:42 +00:00
Compare commits
4 Commits
ci/jest-te
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02de020642 | ||
|
|
570e622a46 | ||
|
|
381cda6821 | ||
|
|
9dbe4db00e |
@@ -15,3 +15,4 @@ paths:
|
||||
- When defining types, keep the structure of file to have any constants and variables first, then exported types and exported methods and then finally the unexported types and methods.
|
||||
- Never import types or other modules in migration files, duplicate the required type or method to keep migration free from changes.
|
||||
- Always run the gofmt tool for formating beforing commiting any changes.
|
||||
- **Never copy through a pointer dereference** (`copied := *original`). It copies only the top level: pointer, slice and map fields stay shared, so changing the copy can change the original. Use the type's `Copy()` when it has one (`QueryBuilderFormula.Copy`); otherwise create a new struct literal from the fields you need. A `Copy()` itself may dereference, as long as it then replaces every pointer, slice and map field.
|
||||
|
||||
@@ -21,6 +21,7 @@ import { DataSource, ReduceOperators } from 'types/common/queryBuilder';
|
||||
|
||||
import {
|
||||
convertBuilderQueriesToV5,
|
||||
createAggregation,
|
||||
mapPanelTypeToRequestType,
|
||||
prepareQueryRangePayloadV5,
|
||||
} from './prepareQueryRangePayloadV5';
|
||||
@@ -1015,3 +1016,47 @@ describe('convertBuilderQueriesToV5 builder query type', () => {
|
||||
expect(buildEnvelope(builderQueryType, 'trace').type).toBe('builder_query');
|
||||
});
|
||||
});
|
||||
|
||||
describe('createAggregation fallback', () => {
|
||||
const logsQuery = (expression: string): Partial<IBuilderQuery> => ({
|
||||
dataSource: DataSource.LOGS,
|
||||
aggregations: [{ expression }],
|
||||
});
|
||||
|
||||
it('sends no aggregation for a heatmap with no field', () => {
|
||||
expect(createAggregation(logsQuery(''), PANEL_TYPES.HEATMAP)).toStrictEqual(
|
||||
[],
|
||||
);
|
||||
});
|
||||
|
||||
it('reads a field on a heatmap and turns it into count() elsewhere', () => {
|
||||
expect(
|
||||
createAggregation(logsQuery('duration_nano'), PANEL_TYPES.HEATMAP),
|
||||
).toStrictEqual([{ expression: 'duration_nano' }]);
|
||||
expect(
|
||||
createAggregation(logsQuery('duration_nano'), PANEL_TYPES.TIME_SERIES),
|
||||
).toStrictEqual([{ expression: 'count()' }]);
|
||||
});
|
||||
|
||||
it('still defaults other panels to count()', () => {
|
||||
expect(
|
||||
createAggregation(logsQuery(''), PANEL_TYPES.TIME_SERIES),
|
||||
).toStrictEqual([{ expression: 'count()' }]);
|
||||
});
|
||||
|
||||
it('sends the field of a logs heatmap query', () => {
|
||||
const [envelope] = convertBuilderQueriesToV5(
|
||||
{
|
||||
A: {
|
||||
...logsQuery('duration_nano'),
|
||||
queryName: 'A',
|
||||
} as IBuilderQuery,
|
||||
},
|
||||
mapPanelTypeToRequestType(PANEL_TYPES.HEATMAP),
|
||||
PANEL_TYPES.HEATMAP,
|
||||
);
|
||||
expect((envelope.spec as LogBuilderQuery).aggregations).toStrictEqual([
|
||||
{ expression: 'duration_nano' },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,6 +5,8 @@ import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { GetQueryResultsProps } from 'lib/dashboard/getQueryResults';
|
||||
import { foldAISlot } from 'lib/query/builderSlot';
|
||||
import getStartEndRangeTime from 'lib/getStartEndRangeTime';
|
||||
import { parseAggregations } from 'lib/query/aggregationExpression';
|
||||
import { aggregatesDistributionField } from 'lib/query/distributionField';
|
||||
import { mapQueryDataToApi } from 'lib/newQueryBuilder/queryBuilderMappers/mapQueryDataToApi';
|
||||
import { isEmpty } from 'lodash-es';
|
||||
import { DynamicVariableSuggestion } from 'providers/Dashboard/store/dynamicVariableSuggestions';
|
||||
@@ -240,32 +242,6 @@ function createBaseSpec(
|
||||
};
|
||||
}
|
||||
|
||||
// Utility to parse aggregation expressions with optional alias
|
||||
export function parseAggregations(
|
||||
expression: string,
|
||||
availableAlias?: string,
|
||||
): { expression: string; alias?: string }[] {
|
||||
const result: { expression: string; alias?: string }[] = [];
|
||||
// Matches function calls like "count()" or "sum(field)" with optional alias like "as 'alias'"
|
||||
// Handles quoted ('alias'), dash-separated (field-name), and unquoted values after "as" keyword
|
||||
const regex =
|
||||
/([a-zA-Z0-9_]+\([^)]*\))(?:\s*as\s+((?:'[^']*'|"[^"]*"|[a-zA-Z0-9_-]+)))?/g;
|
||||
let match = regex.exec(expression);
|
||||
while (match !== null) {
|
||||
const expr = match[1];
|
||||
let alias = match[2] || availableAlias; // Use provided alias or availableAlias if not matched
|
||||
if (alias) {
|
||||
// Remove quotes if present
|
||||
alias = alias.replace(/^['"]|['"]$/g, '');
|
||||
result.push({ expression: expr, alias });
|
||||
} else {
|
||||
result.push({ expression: expr });
|
||||
}
|
||||
match = regex.exec(expression);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function createAggregation(
|
||||
queryData: any,
|
||||
panelType?: PANEL_TYPES,
|
||||
@@ -310,18 +286,28 @@ export function createAggregation(
|
||||
];
|
||||
}
|
||||
|
||||
// A heatmap buckets the field the user names; count() would be rejected as one.
|
||||
// Elsewhere a field is not an aggregation, so it falls back to count().
|
||||
const isDistributionField = aggregatesDistributionField(
|
||||
panelType,
|
||||
queryData.dataSource,
|
||||
);
|
||||
const fallback = isDistributionField ? [] : [{ expression: 'count()' }];
|
||||
|
||||
if (queryData.aggregations?.length > 0) {
|
||||
return queryData.aggregations.flatMap(
|
||||
(agg: { expression: string; alias?: string }) => {
|
||||
const parsedAggregations = parseAggregations(agg.expression, agg?.alias);
|
||||
return isEmpty(parsedAggregations)
|
||||
? [{ expression: 'count()' }]
|
||||
: parsedAggregations;
|
||||
const parsedAggregations = parseAggregations(
|
||||
agg.expression,
|
||||
agg?.alias,
|
||||
isDistributionField,
|
||||
);
|
||||
return isEmpty(parsedAggregations) ? fallback : parsedAggregations;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return [{ expression: 'count()' }];
|
||||
return fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
.headerZone {
|
||||
// Sticks to the top of a scrolling list so the heading and filters stay put
|
||||
// while results scroll beneath. The DSL suggestion popup (z-index 1000) still
|
||||
// layers above it.
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
gap: 14px;
|
||||
padding: 20px 24px;
|
||||
background: var(--l2-background);
|
||||
border-bottom: 1px solid var(--l2-border);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { ReactNode } from 'react';
|
||||
|
||||
import styles from './ListHeaderZone.module.scss';
|
||||
|
||||
interface Props {
|
||||
/** Rendered regardless of whether the list has anything in it. */
|
||||
children: ReactNode;
|
||||
testId?: string;
|
||||
}
|
||||
|
||||
function ListHeaderZone({ children, testId }: Props): JSX.Element {
|
||||
return (
|
||||
<div className={styles.headerZone} data-testid={testId}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ListHeaderZone;
|
||||
@@ -106,8 +106,10 @@ function QueryAddOns({
|
||||
|
||||
if (
|
||||
panelType === PANEL_TYPES.HEATMAP &&
|
||||
query.dataSource === DataSource.METRICS &&
|
||||
!HISTOGRAM_ATTRIBUTE_TYPES.has(query.aggregateAttribute?.type ?? '')
|
||||
!(
|
||||
query.dataSource === DataSource.METRICS &&
|
||||
HISTOGRAM_ATTRIBUTE_TYPES.has(query.aggregateAttribute?.type ?? '')
|
||||
)
|
||||
) {
|
||||
addOns = [...addOns, BUCKET_OPTIONS];
|
||||
}
|
||||
@@ -436,6 +438,7 @@ function QueryAddOns({
|
||||
onChange={handleChangeOrderByKeys}
|
||||
isRawQuery={isRawQuery}
|
||||
isNewQueryV2
|
||||
panelType={panelType ?? undefined}
|
||||
placeholder={placeholderOf(QueryBuilderField.OrderBy)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -107,8 +107,8 @@ export const BASE_ADD_ONS = (
|
||||
|
||||
export const REDUCE_TO = toAddOn(QueryBuilderField.ReduceTo);
|
||||
|
||||
// Offered only by a heatmap over metrics: the bucket axis is what a heatmap plots
|
||||
// against, and no other panel type sends one. A histogram brings its own buckets.
|
||||
// Offered only by a heatmap: the bucket axis is what a heatmap plots against, and no
|
||||
// other panel type sends one. A histogram metric brings its own buckets.
|
||||
export const HISTOGRAM_ATTRIBUTE_TYPES = new Set<string>([
|
||||
ATTRIBUTE_TYPES.HISTOGRAM,
|
||||
ATTRIBUTE_TYPES.EXPONENTIAL_HISTOGRAM,
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// Fills the row like the filter and Group By boxes.
|
||||
.select {
|
||||
flex: 1;
|
||||
min-width: 400px;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
import { Combobox } from '@signozhq/ui/combobox';
|
||||
import { TelemetrytypesFieldDataTypeDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import { DEBOUNCE_DELAY } from 'constants/queryBuilderFilterConfig';
|
||||
import { useFieldKeysSuggestion } from 'hooks/querySuggestions/useFieldKeysSuggestion';
|
||||
import useDebounce from 'hooks/useDebounce';
|
||||
import { getDistributionFieldPlaceholder } from 'lib/query/distributionField';
|
||||
import type { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { DATA_SOURCE_TO_SIGNAL } from 'types/common/queryBuilder';
|
||||
|
||||
import { toDistributionFieldOptions } from './distributionFieldOptions';
|
||||
|
||||
import Styles from './DistributionFieldSelect.module.scss';
|
||||
|
||||
/** A logs or traces heatmap's aggregation: the one numeric field it buckets. */
|
||||
export default function DistributionFieldSelect({
|
||||
queryData,
|
||||
onChange,
|
||||
}: {
|
||||
queryData: IBuilderQuery;
|
||||
onChange?: (field: string) => void;
|
||||
}): JSX.Element {
|
||||
const [search, setSearch] = useState('');
|
||||
const searchText = useDebounce(search, DEBOUNCE_DELAY);
|
||||
|
||||
// The keys API caps its answer, so a field past the cap is reached by searching.
|
||||
const {
|
||||
data: fieldKeys,
|
||||
isLoading,
|
||||
isFetching,
|
||||
} = useFieldKeysSuggestion(
|
||||
{
|
||||
signal: DATA_SOURCE_TO_SIGNAL[queryData.dataSource],
|
||||
searchText,
|
||||
fieldDataType: TelemetrytypesFieldDataTypeDTO.number,
|
||||
},
|
||||
queryData.builderQueryType,
|
||||
{ keepPreviousData: true },
|
||||
);
|
||||
|
||||
const [aggregation] = queryData.aggregations ?? [];
|
||||
const selectedField =
|
||||
aggregation && 'expression' in aggregation ? aggregation.expression : '';
|
||||
|
||||
const items = useMemo(
|
||||
() => toDistributionFieldOptions(fieldKeys ?? [], selectedField),
|
||||
[fieldKeys, selectedField],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={Styles.select}>
|
||||
<Combobox
|
||||
items={items}
|
||||
value={selectedField || undefined}
|
||||
onChange={(field): void => onChange?.(field ?? '')}
|
||||
allowClear
|
||||
placeholder={getDistributionFieldPlaceholder(queryData.dataSource)}
|
||||
searchInputProps={{
|
||||
placeholder: 'Search numeric fields',
|
||||
loading: isFetching,
|
||||
onChange: setSearch,
|
||||
}}
|
||||
loading={isLoading}
|
||||
noContent="No numeric fields"
|
||||
testId="distribution-field-select"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
IBuilderQuery,
|
||||
IBuilderTraceOperator,
|
||||
} from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { aggregatesDistributionField } from 'lib/query/distributionField';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
|
||||
import {
|
||||
@@ -19,6 +20,7 @@ import {
|
||||
} from '../../queryBuilderFields.utils';
|
||||
|
||||
import { isScalarPanelType } from '../panelTypes';
|
||||
import DistributionFieldSelect from './DistributionFieldSelect';
|
||||
import QueryAggregationSelect from './QueryAggregationSelect';
|
||||
|
||||
import './QueryAggregation.styles.scss';
|
||||
@@ -63,17 +65,21 @@ function QueryAggregationOptions({
|
||||
data-testid="query-aggregation-container"
|
||||
>
|
||||
<div className="aggregation-container">
|
||||
<QueryAggregationSelect
|
||||
onChange={onChange}
|
||||
queryData={queryData}
|
||||
maxAggregations={
|
||||
panelType === PANEL_TYPES.VALUE ||
|
||||
panelType === PANEL_TYPES.PIE ||
|
||||
panelType === PANEL_TYPES.TOP_LIST
|
||||
? 1
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
{aggregatesDistributionField(panelType, dataSource) ? (
|
||||
<DistributionFieldSelect queryData={queryData} onChange={onChange} />
|
||||
) : (
|
||||
<QueryAggregationSelect
|
||||
onChange={onChange}
|
||||
queryData={queryData}
|
||||
maxAggregations={
|
||||
panelType === PANEL_TYPES.VALUE ||
|
||||
panelType === PANEL_TYPES.PIE ||
|
||||
panelType === PANEL_TYPES.TOP_LIST
|
||||
? 1
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
{!stepInterval.hidden && (
|
||||
<div className="query-aggregation-interval">
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
import {
|
||||
TelemetrytypesFieldContextDTO,
|
||||
TelemetrytypesFieldDataTypeDTO,
|
||||
TelemetrytypesSignalDTO,
|
||||
type GetFieldsKeys200,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
import { ENVIRONMENT } from 'constants/env';
|
||||
import { DEBOUNCE_DELAY } from 'constants/queryBuilderFilterConfig';
|
||||
import { initialQueriesMap } from 'constants/queryBuilder';
|
||||
import { rest, server } from 'mocks-server/server';
|
||||
import { act, render, screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
import type { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
|
||||
|
||||
import DistributionFieldSelect from '../DistributionFieldSelect';
|
||||
|
||||
const keysResponse: GetFieldsKeys200 = {
|
||||
status: 'success',
|
||||
data: {
|
||||
complete: true,
|
||||
keys: {
|
||||
duration_nano: [
|
||||
{
|
||||
name: 'duration_nano',
|
||||
fieldContext: TelemetrytypesFieldContextDTO.span,
|
||||
fieldDataType: TelemetrytypesFieldDataTypeDTO.float64,
|
||||
signal: TelemetrytypesSignalDTO.traces,
|
||||
},
|
||||
],
|
||||
quantity: [
|
||||
{
|
||||
name: 'quantity',
|
||||
fieldContext: TelemetrytypesFieldContextDTO.attribute,
|
||||
fieldDataType: TelemetrytypesFieldDataTypeDTO.float64,
|
||||
signal: TelemetrytypesSignalDTO.traces,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const tracesQuery = (expression: string): IBuilderQuery => ({
|
||||
...(initialQueriesMap.traces.builder.queryData[0] as IBuilderQuery),
|
||||
aggregations: [{ expression }],
|
||||
});
|
||||
|
||||
describe('DistributionFieldSelect', () => {
|
||||
const requests: URLSearchParams[] = [];
|
||||
|
||||
afterEach(() => {
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
requests.length = 0;
|
||||
server.use(
|
||||
rest.get(`${ENVIRONMENT.baseURL}/api/v1/fields/keys`, (req, res, ctx) => {
|
||||
requests.push(req.url.searchParams);
|
||||
return res(ctx.status(200), ctx.json(keysResponse));
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('shows the saved field', () => {
|
||||
render(
|
||||
<DistributionFieldSelect
|
||||
queryData={tracesQuery('duration_nano')}
|
||||
onChange={jest.fn()}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(screen.getByTestId('distribution-field-select')).toHaveTextContent(
|
||||
'duration_nano',
|
||||
);
|
||||
});
|
||||
|
||||
it('picks a numeric field, keeping its context', async () => {
|
||||
const user = userEvent.setup({ delay: null, pointerEventsCheck: 0 });
|
||||
const onChange = jest.fn() as jest.MockedFunction<(field: string) => void>;
|
||||
render(
|
||||
<DistributionFieldSelect queryData={tracesQuery('')} onChange={onChange} />,
|
||||
);
|
||||
|
||||
await user.click(screen.getByTestId('distribution-field-select'));
|
||||
await screen.findByTestId(
|
||||
'distribution-field-select-item-attribute.quantity',
|
||||
);
|
||||
await user.type(
|
||||
screen.getByTestId('distribution-field-select-search'),
|
||||
'attribute.quantity{Enter}',
|
||||
);
|
||||
|
||||
expect(onChange).toHaveBeenCalledWith('attribute.quantity');
|
||||
expect(requests[0].get('fieldDataType')).toBe(
|
||||
TelemetrytypesFieldDataTypeDTO.number,
|
||||
);
|
||||
expect(requests[0].get('signal')).toBe('traces');
|
||||
});
|
||||
|
||||
it('replaces the saved field with the newly picked one', async () => {
|
||||
const user = userEvent.setup({ delay: null, pointerEventsCheck: 0 });
|
||||
const onChange = jest.fn() as jest.MockedFunction<(field: string) => void>;
|
||||
render(
|
||||
<DistributionFieldSelect
|
||||
queryData={tracesQuery('duration_nano')}
|
||||
onChange={onChange}
|
||||
/>,
|
||||
);
|
||||
|
||||
await user.click(screen.getByTestId('distribution-field-select'));
|
||||
await screen.findByTestId(
|
||||
'distribution-field-select-item-attribute.quantity',
|
||||
);
|
||||
await user.type(
|
||||
screen.getByTestId('distribution-field-select-search'),
|
||||
'attribute.quantity{Enter}',
|
||||
);
|
||||
|
||||
expect(onChange).toHaveBeenCalledWith('attribute.quantity');
|
||||
});
|
||||
|
||||
it('only offers listed fields: typed text is a filter, not a value', async () => {
|
||||
const user = userEvent.setup({ delay: null, pointerEventsCheck: 0 });
|
||||
render(
|
||||
<DistributionFieldSelect queryData={tracesQuery('')} onChange={jest.fn()} />,
|
||||
);
|
||||
|
||||
await user.click(screen.getByTestId('distribution-field-select'));
|
||||
await screen.findByTestId(
|
||||
'distribution-field-select-item-attribute.quantity',
|
||||
);
|
||||
await user.type(
|
||||
screen.getByTestId('distribution-field-select-search'),
|
||||
'no_such_field',
|
||||
);
|
||||
|
||||
await screen.findByText('No numeric fields');
|
||||
expect(
|
||||
screen.queryByTestId('distribution-field-select-item-no_such_field'),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('searches the server for typed text, past the listed fields', async () => {
|
||||
jest.useFakeTimers();
|
||||
const user = userEvent.setup({
|
||||
advanceTimers: (ms) => jest.advanceTimersByTime(ms),
|
||||
pointerEventsCheck: 0,
|
||||
});
|
||||
render(
|
||||
<DistributionFieldSelect queryData={tracesQuery('')} onChange={jest.fn()} />,
|
||||
);
|
||||
|
||||
await user.click(screen.getByTestId('distribution-field-select'));
|
||||
await user.type(
|
||||
await screen.findByTestId('distribution-field-select-search'),
|
||||
'queue',
|
||||
);
|
||||
act(() => {
|
||||
jest.advanceTimersByTime(DEBOUNCE_DELAY);
|
||||
});
|
||||
|
||||
await waitFor(() => expect(requests.at(-1)?.get('searchText')).toBe('queue'));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,84 @@
|
||||
import { TelemetrytypesFieldContextDTO as FieldContext } from 'api/generated/services/sigNoz.schemas';
|
||||
|
||||
import {
|
||||
toDistributionFieldOptions,
|
||||
toDistributionFieldText,
|
||||
} from '../distributionFieldOptions';
|
||||
|
||||
const key = (
|
||||
name: string,
|
||||
fieldContext: FieldContext,
|
||||
): { name: string; fieldContext: FieldContext } => ({ name, fieldContext });
|
||||
|
||||
const KEYS = [
|
||||
key('quantity', FieldContext.resource),
|
||||
key('duration_nano', FieldContext.span),
|
||||
key('quantity', FieldContext.attribute),
|
||||
key('total_tokens', FieldContext.trace),
|
||||
key('latency', FieldContext.body),
|
||||
key('duration_nano', FieldContext.span),
|
||||
];
|
||||
|
||||
describe('toDistributionFieldText', () => {
|
||||
it.each([
|
||||
[key('duration_nano', FieldContext.span), 'duration_nano'],
|
||||
[key('severity_number', FieldContext.log), 'severity_number'],
|
||||
[
|
||||
key('http.status_code', FieldContext.attribute),
|
||||
'attribute.http.status_code',
|
||||
],
|
||||
[key('latency', FieldContext.body), 'body.latency'],
|
||||
])('%j → %s', (fieldKey, text) => {
|
||||
expect(toDistributionFieldText(fieldKey)).toBe(text);
|
||||
});
|
||||
});
|
||||
|
||||
const item = (
|
||||
text: string,
|
||||
): { type: 'item'; label: string; value: string } => ({
|
||||
type: 'item',
|
||||
label: text,
|
||||
value: text,
|
||||
});
|
||||
|
||||
describe('toDistributionFieldOptions', () => {
|
||||
it('groups columns first, keeps contexts apart, drops trace keys and repeats', () => {
|
||||
expect(toDistributionFieldOptions(KEYS, 'duration_nano')).toStrictEqual([
|
||||
{
|
||||
type: 'group',
|
||||
label: 'Columns',
|
||||
value: 'column',
|
||||
items: [item('duration_nano')],
|
||||
},
|
||||
{
|
||||
type: 'group',
|
||||
label: 'Attribute',
|
||||
value: 'attribute',
|
||||
items: [item('attribute.quantity')],
|
||||
},
|
||||
{
|
||||
type: 'group',
|
||||
label: 'Resource',
|
||||
value: 'resource',
|
||||
items: [item('resource.quantity')],
|
||||
},
|
||||
{
|
||||
type: 'group',
|
||||
label: 'Body',
|
||||
value: 'body',
|
||||
items: [item('body.latency')],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('leads with a saved field the keys do not carry', () => {
|
||||
const options = toDistributionFieldOptions(KEYS, 'queue-depth');
|
||||
expect(options[0]).toStrictEqual(item('queue-depth'));
|
||||
expect(options).toHaveLength(5);
|
||||
});
|
||||
|
||||
it('adds nothing for an empty or listed field', () => {
|
||||
expect(toDistributionFieldOptions(KEYS, '')).toHaveLength(4);
|
||||
expect(toDistributionFieldOptions(KEYS, 'body.latency')).toHaveLength(4);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,81 @@
|
||||
import type {
|
||||
ComboboxItemType,
|
||||
ComboboxOptionItemType,
|
||||
} from '@signozhq/ui/combobox';
|
||||
import { TelemetrytypesFieldContextDTO as FieldContext } from 'api/generated/services/sigNoz.schemas';
|
||||
import { upperFirst } from 'lodash-es';
|
||||
import type { TelemetryFieldKey } from 'types/api/v5/queryRange';
|
||||
|
||||
// Span and log columns are read by their name alone; anything else keeps its
|
||||
// context so `attribute.quantity` and `resource.quantity` stay apart.
|
||||
const COLUMN_CONTEXTS = new Set<string | undefined>([
|
||||
FieldContext.span,
|
||||
FieldContext.log,
|
||||
FieldContext[''],
|
||||
]);
|
||||
|
||||
const GROUP_ORDER: string[] = [
|
||||
'column',
|
||||
FieldContext.attribute,
|
||||
FieldContext.resource,
|
||||
];
|
||||
|
||||
const headingOf = (group: string): string =>
|
||||
group === 'column' ? 'Columns' : upperFirst(group);
|
||||
|
||||
const toItem = (text: string): ComboboxOptionItemType => ({
|
||||
type: 'item',
|
||||
label: text,
|
||||
value: text,
|
||||
});
|
||||
|
||||
/** The key text the querier parses back into this key (`GetFieldKeyFromKeyText`). */
|
||||
export function toDistributionFieldText(key: TelemetryFieldKey): string {
|
||||
return COLUMN_CONTEXTS.has(key.fieldContext)
|
||||
? key.name
|
||||
: `${key.fieldContext}.${key.name}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Numeric keys grouped by context, each one once. `trace.*` keys are per-trace
|
||||
* aggregates, which a heatmap cannot bucket. A saved field the keys do not carry
|
||||
* leads as its own item, so the combobox can still show it.
|
||||
*/
|
||||
export function toDistributionFieldOptions(
|
||||
keys: TelemetryFieldKey[],
|
||||
selectedField: string,
|
||||
): ComboboxItemType[] {
|
||||
const byGroup = new Map<string, Set<string>>();
|
||||
keys
|
||||
.filter((key) => key.fieldContext !== FieldContext.trace)
|
||||
.forEach((key) => {
|
||||
const group = COLUMN_CONTEXTS.has(key.fieldContext)
|
||||
? 'column'
|
||||
: String(key.fieldContext);
|
||||
byGroup.set(
|
||||
group,
|
||||
(byGroup.get(group) ?? new Set()).add(toDistributionFieldText(key)),
|
||||
);
|
||||
});
|
||||
|
||||
const isSelectedListed = [...byGroup.values()].some((texts) =>
|
||||
texts.has(selectedField),
|
||||
);
|
||||
const rank = (group: string): number => {
|
||||
const index = GROUP_ORDER.indexOf(group);
|
||||
return index === -1 ? GROUP_ORDER.length : index;
|
||||
};
|
||||
|
||||
const groups = [...byGroup.entries()]
|
||||
.sort(([a], [b]) => rank(a) - rank(b) || a.localeCompare(b))
|
||||
.map(([group, texts]): ComboboxItemType => ({
|
||||
type: 'group',
|
||||
label: headingOf(group),
|
||||
value: group,
|
||||
items: [...texts].map(toItem),
|
||||
}));
|
||||
|
||||
return selectedField && !isSelectedListed
|
||||
? [toItem(selectedField), ...groups]
|
||||
: groups;
|
||||
}
|
||||
@@ -506,7 +506,7 @@ describe('QueryAddOns', () => {
|
||||
);
|
||||
}
|
||||
|
||||
it('is offered on a metrics heatmap only', () => {
|
||||
it('is offered on a metrics heatmap', () => {
|
||||
renderHeatmap();
|
||||
|
||||
expect(
|
||||
@@ -532,23 +532,16 @@ describe('QueryAddOns', () => {
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('is not offered on a heatmap over another signal', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
query={baseQuery({ dataSource: DataSource.LOGS })}
|
||||
version="v5"
|
||||
isRawQuery={false}
|
||||
showReduceTo={false}
|
||||
panelType={PANEL_TYPES.HEATMAP}
|
||||
index={0}
|
||||
isForTraceOperator={false}
|
||||
/>,
|
||||
);
|
||||
it.each([DataSource.LOGS, DataSource.TRACES])(
|
||||
'is offered on a %s heatmap',
|
||||
(dataSource) => {
|
||||
renderHeatmap({ dataSource });
|
||||
|
||||
expect(
|
||||
screen.queryByTestId('query-add-on-bucket_options'),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
expect(
|
||||
screen.getByTestId('query-add-on-bucket_options'),
|
||||
).toBeInTheDocument();
|
||||
},
|
||||
);
|
||||
|
||||
it.each([ATTRIBUTE_TYPES.HISTOGRAM, ATTRIBUTE_TYPES.EXPONENTIAL_HISTOGRAM])(
|
||||
'is not offered for a %s metric, which carries its own buckets',
|
||||
|
||||
@@ -8,7 +8,7 @@ import QueryAggregationOptions from '../QueryV2/QueryAggregation/QueryAggregatio
|
||||
|
||||
jest.mock('../QueryV2/QueryAggregation/QueryAggregationSelect', () => ({
|
||||
__esModule: true,
|
||||
default: (): null => null,
|
||||
default: (): JSX.Element => <div data-testid="aggregation-select" />,
|
||||
}));
|
||||
|
||||
const queryData = initialQueriesMap.traces.builder
|
||||
@@ -69,3 +69,18 @@ describe('QueryAggregationOptions step interval', () => {
|
||||
expect(screen.getByText('every')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('QueryAggregationOptions on a heatmap', () => {
|
||||
it.each([
|
||||
[PANEL_TYPES.HEATMAP, DataSource.TRACES, true],
|
||||
[PANEL_TYPES.HEATMAP, DataSource.METRICS, false],
|
||||
[PANEL_TYPES.TIME_SERIES, DataSource.TRACES, false],
|
||||
])(
|
||||
'%s over %s renders the field picker: %s',
|
||||
(panelType, dataSource, picker) => {
|
||||
renderFor(panelType, dataSource);
|
||||
expect(!!screen.queryByTestId('distribution-field-select')).toBe(picker);
|
||||
expect(!!screen.queryByTestId('aggregation-select')).toBe(!picker);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -59,29 +59,6 @@ export function AlertsEmptyState({
|
||||
return (
|
||||
<div className={styles.alertListContainer}>
|
||||
<div className={styles.alertListViewContent}>
|
||||
<div>
|
||||
<Typography
|
||||
variant="label"
|
||||
size="large"
|
||||
weight="regular"
|
||||
color="main"
|
||||
as="h1"
|
||||
marginY={4}
|
||||
textOverflow="wrap"
|
||||
>
|
||||
Alert Rules
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="paragraph"
|
||||
size="base"
|
||||
weight="regular"
|
||||
color="secondary"
|
||||
as="span"
|
||||
textOverflow="wrap"
|
||||
>
|
||||
Create and manage alert rules for your resources.
|
||||
</Typography>
|
||||
</div>
|
||||
<section className={styles.emptyAlertInfoContainer}>
|
||||
<div className={styles.alertContent}>
|
||||
<section className={styles.heading}>
|
||||
|
||||
@@ -15,18 +15,6 @@
|
||||
background: var(--l1-background);
|
||||
}
|
||||
|
||||
.headerZone {
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
gap: 14px;
|
||||
padding: 20px 24px;
|
||||
background: var(--l2-background);
|
||||
border-bottom: 1px solid var(--l2-border);
|
||||
}
|
||||
|
||||
.tableContainer {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
|
||||
@@ -35,6 +35,10 @@ describe('ListAlertRules — empty states', () => {
|
||||
expect(
|
||||
screen.getByText('Create an Alert Rule to get started'),
|
||||
).toBeInTheDocument();
|
||||
expect(screen.getByTestId('alert-rules-list-search')).toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByTestId('list-alerts-new-alert-button'),
|
||||
).not.toBeInTheDocument();
|
||||
|
||||
// New Alert Rule button is visible and triggers safeNavigate to ALERTS_NEW.
|
||||
await user.click(screen.getByTestId('add-alert'));
|
||||
|
||||
@@ -3,6 +3,7 @@ import ErrorEmptyState from 'components/Alerts/ErrorEmptyState';
|
||||
import NoResultsEmptyState from 'components/Alerts/NoResultsEmptyState';
|
||||
import InvalidQueryState from 'components/ListFilter/InvalidQueryState/InvalidQueryState';
|
||||
import ListCommandHeader from 'components/ListViews/ListCommandHeader/ListCommandHeader';
|
||||
import ListHeaderZone from 'components/ListViews/ListHeaderZone/ListHeaderZone';
|
||||
import ListStatusBar from 'components/ListViews/ListStatusBar/ListStatusBar';
|
||||
import ViewsRail from 'components/ListViews/ViewsRail/ViewsRail';
|
||||
import TanStackTable from 'components/TanStackTableView';
|
||||
@@ -182,32 +183,30 @@ function ListAlertRules(): JSX.Element {
|
||||
deleteDescription="Views are shared across your organization, so this removes it for everyone. Alert rules are not affected."
|
||||
/>
|
||||
<div className={styles.main}>
|
||||
{!isEmptyNoRules && (
|
||||
<div className={styles.headerZone}>
|
||||
<ListCommandHeader
|
||||
label={activeLabel}
|
||||
count={total}
|
||||
isCountLoading={isFetching}
|
||||
isModified={ruleViews.isModified}
|
||||
testIdPrefix="alert-rules"
|
||||
action={
|
||||
<AlertRulesHeaderActions
|
||||
columns={columns}
|
||||
canAddAlert={addNewAlert}
|
||||
onNewAlert={handleNewAlert}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<AlertRulesFilterZone
|
||||
query={filter.query}
|
||||
states={filter.states}
|
||||
creatorOptions={creatorOptions}
|
||||
source={source}
|
||||
onQueryChange={submitQuery}
|
||||
onStatesChange={changeStates}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<ListHeaderZone testId="alert-rules-header-zone">
|
||||
<ListCommandHeader
|
||||
label={activeLabel}
|
||||
count={total}
|
||||
isCountLoading={isFetching}
|
||||
isModified={ruleViews.isModified}
|
||||
testIdPrefix="alert-rules"
|
||||
action={
|
||||
<AlertRulesHeaderActions
|
||||
columns={columns}
|
||||
canAddAlert={addNewAlert && !isEmptyNoRules}
|
||||
onNewAlert={handleNewAlert}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<AlertRulesFilterZone
|
||||
query={filter.query}
|
||||
states={filter.states}
|
||||
creatorOptions={creatorOptions}
|
||||
source={source}
|
||||
onQueryChange={submitQuery}
|
||||
onStatesChange={changeStates}
|
||||
/>
|
||||
</ListHeaderZone>
|
||||
|
||||
<div ref={containerRef} className={styles.tableContainer}>
|
||||
{isError ? (
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import {
|
||||
IBuilderQuery,
|
||||
OrderByPayload,
|
||||
@@ -10,6 +11,8 @@ export type OrderByFilterProps = {
|
||||
entityVersion?: string;
|
||||
isNewQueryV2?: boolean;
|
||||
placeholder?: string;
|
||||
/** A logs or traces heatmap aggregates a field, which Order by then offers. */
|
||||
panelType?: PANEL_TYPES;
|
||||
};
|
||||
|
||||
export type OrderByFilterValue = {
|
||||
|
||||
@@ -23,6 +23,7 @@ export function OrderByFilter({
|
||||
entityVersion,
|
||||
isNewQueryV2 = false,
|
||||
placeholder,
|
||||
panelType,
|
||||
}: OrderByFilterProps): JSX.Element {
|
||||
const getPopupContainer = useSelectPopupContainer();
|
||||
const {
|
||||
@@ -52,8 +53,9 @@ export function OrderByFilter({
|
||||
|
||||
// Get parsed aggregation options using createAggregation only for QueryV2
|
||||
const parsedAggregationOptions = useMemo(
|
||||
() => (isNewQueryV2 ? getParsedAggregationOptionsForOrderBy(query) : []),
|
||||
[query, isNewQueryV2],
|
||||
() =>
|
||||
isNewQueryV2 ? getParsedAggregationOptionsForOrderBy(query, panelType) : [],
|
||||
[query, isNewQueryV2, panelType],
|
||||
);
|
||||
|
||||
const optionsData = useMemo(() => {
|
||||
|
||||
@@ -433,4 +433,57 @@ describe('useQueryBuilderOperations - Empty Aggregate Attribute Type', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('handleChangeQueryData on a heatmap', () => {
|
||||
it('moves the sort on the old field to the new one', () => {
|
||||
setupMockQueryBuilder('heatmap');
|
||||
const result = renderHookWithProps({
|
||||
entityVersion: ENTITY_VERSION_V5,
|
||||
query: {
|
||||
...defaultMockQuery,
|
||||
dataSource: DataSource.TRACES,
|
||||
aggregations: [{ expression: 'duration_nano' }],
|
||||
orderBy: [{ columnName: 'duration_nano', order: 'desc' }],
|
||||
},
|
||||
});
|
||||
act(() => {
|
||||
result.current.handleChangeQueryData('aggregations', [
|
||||
{ expression: 'attribute.quantity' },
|
||||
]);
|
||||
});
|
||||
|
||||
expect(mockHandleSetQueryData).toHaveBeenLastCalledWith(
|
||||
0,
|
||||
expect.objectContaining({
|
||||
aggregations: [{ expression: 'attribute.quantity' }],
|
||||
orderBy: [{ columnName: 'attribute.quantity', order: 'desc' }],
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('handleChangeDataSource', () => {
|
||||
it.each([
|
||||
['heatmap', ''],
|
||||
['time_series', 'count() '],
|
||||
])(
|
||||
'seeds the traces aggregation on a %s panel with %j',
|
||||
(panelType, expression) => {
|
||||
setupMockQueryBuilder(panelType);
|
||||
|
||||
const result = renderHookWithProps({ entityVersion: ENTITY_VERSION_V5 });
|
||||
act(() => {
|
||||
result.current.handleChangeDataSource(DataSource.TRACES);
|
||||
});
|
||||
|
||||
expect(mockHandleSetQueryData).toHaveBeenLastCalledWith(
|
||||
0,
|
||||
expect.objectContaining({
|
||||
dataSource: DataSource.TRACES,
|
||||
aggregations: [{ expression }],
|
||||
}),
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -29,6 +29,11 @@ import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||
import { getMetricsOperatorsByAttributeType } from 'lib/newQueryBuilder/getMetricsOperatorsByAttributeType';
|
||||
import { getOperatorsBySourceAndPanelType } from 'lib/newQueryBuilder/getOperatorsBySourceAndPanelType';
|
||||
import { findDataTypeOfOperator } from 'lib/query/findDataTypeOfOperator';
|
||||
import {
|
||||
aggregatesDistributionField,
|
||||
setDistributionField,
|
||||
toDistributionAggregation,
|
||||
} from 'lib/query/distributionField';
|
||||
import { isEmpty, isEqual } from 'lodash-es';
|
||||
import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
import {
|
||||
@@ -476,7 +481,12 @@ export const useQueryOperations: UseQueryOperations = ({
|
||||
newQueryData = newQueryData ? newQueryData : newQuery;
|
||||
|
||||
setOperators(newOperators);
|
||||
handleSetQueryData(index, newQueryData);
|
||||
handleSetQueryData(
|
||||
index,
|
||||
aggregatesDistributionField(panelType, newQueryData.dataSource)
|
||||
? toDistributionAggregation(newQueryData)
|
||||
: newQueryData,
|
||||
);
|
||||
},
|
||||
[
|
||||
isRawQuery,
|
||||
@@ -506,13 +516,18 @@ export const useQueryOperations: UseQueryOperations = ({
|
||||
const handleChangeQueryData: HandleChangeQueryData | HandleChangeQueryDataV5 =
|
||||
useCallback(
|
||||
(key: string, value: any) => {
|
||||
const newQuery = {
|
||||
...query,
|
||||
[key]:
|
||||
key === LEGEND && typeof value === 'string'
|
||||
? getFormatedLegend(value)
|
||||
: value,
|
||||
};
|
||||
// A heatmap's sort names its field, so it follows a field change.
|
||||
const newQuery =
|
||||
key === 'aggregations' &&
|
||||
aggregatesDistributionField(panelType, query.dataSource)
|
||||
? setDistributionField(query, value?.[0]?.expression ?? '')
|
||||
: {
|
||||
...query,
|
||||
[key]:
|
||||
key === LEGEND && typeof value === 'string'
|
||||
? getFormatedLegend(value)
|
||||
: value,
|
||||
};
|
||||
|
||||
if (isForTraceOperator) {
|
||||
handleSetTraceOperatorData(index, newQuery);
|
||||
@@ -523,6 +538,7 @@ export const useQueryOperations: UseQueryOperations = ({
|
||||
[
|
||||
query,
|
||||
index,
|
||||
panelType,
|
||||
handleSetQueryData,
|
||||
handleSetTraceOperatorData,
|
||||
isForTraceOperator,
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { parseAggregations } from '../aggregationExpression';
|
||||
|
||||
describe('parseAggregations', () => {
|
||||
it.each([
|
||||
['duration_nano', [{ expression: 'duration_nano' }]],
|
||||
['attribute.queue_depth', [{ expression: 'attribute.queue_depth' }]],
|
||||
['attribute.queue-depth', [{ expression: 'attribute.queue-depth' }]],
|
||||
['body.latency as lat', [{ expression: 'body.latency', alias: 'lat' }]],
|
||||
[
|
||||
"count() as 'total' avg(code.lineno)",
|
||||
[
|
||||
{ expression: 'count()', alias: 'total' },
|
||||
{ expression: 'avg(code.lineno)' },
|
||||
],
|
||||
],
|
||||
// Words beside a call are not aggregations of their own.
|
||||
['count() AS total', [{ expression: 'count()' }]],
|
||||
['p99(duration_nano) by service', [{ expression: 'p99(duration_nano)' }]],
|
||||
['sum(a', []],
|
||||
])('parses %s', (input, expected) => {
|
||||
expect(parseAggregations(input, undefined, true)).toStrictEqual(expected);
|
||||
});
|
||||
|
||||
it('leaves a field out unless asked to read one', () => {
|
||||
expect(parseAggregations('duration_nano')).toStrictEqual([]);
|
||||
});
|
||||
});
|
||||
193
frontend/src/lib/query/__tests__/distributionField.test.ts
Normal file
193
frontend/src/lib/query/__tests__/distributionField.test.ts
Normal file
@@ -0,0 +1,193 @@
|
||||
import { initialQueriesMap } from 'constants/queryBuilder';
|
||||
import type { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
|
||||
import {
|
||||
getDistributionFieldPlaceholder,
|
||||
setDistributionField,
|
||||
toDistributionAggregation,
|
||||
fromDistributionAggregation,
|
||||
} from '../distributionField';
|
||||
|
||||
const queryOf = (
|
||||
dataSource: DataSource,
|
||||
expressions: string[],
|
||||
): IBuilderQuery => ({
|
||||
...(initialQueriesMap[dataSource].builder.queryData[0] as IBuilderQuery),
|
||||
aggregations: expressions.map((expression) => ({ expression })),
|
||||
});
|
||||
|
||||
describe('getDistributionFieldPlaceholder', () => {
|
||||
it.each([
|
||||
[DataSource.TRACES, 'Numeric field to bucket, e.g. duration_nano'],
|
||||
[DataSource.LOGS, 'Numeric field to bucket'],
|
||||
])('%s → %s', (dataSource, expected) => {
|
||||
expect(getDistributionFieldPlaceholder(dataSource)).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('toDistributionAggregation', () => {
|
||||
it.each([DataSource.TRACES, DataSource.LOGS])(
|
||||
'clears a %s count() for the user to pick a field',
|
||||
(dataSource) => {
|
||||
expect(
|
||||
toDistributionAggregation(queryOf(dataSource, ['count()'])).aggregations,
|
||||
).toStrictEqual([{ expression: '' }]);
|
||||
},
|
||||
);
|
||||
|
||||
it.each(['attribute.batch_size', 'attribute.queue-depth'])(
|
||||
'keeps the bare field %s',
|
||||
(field) => {
|
||||
const query = queryOf(DataSource.LOGS, [field]);
|
||||
expect(toDistributionAggregation(query)).toBe(query);
|
||||
},
|
||||
);
|
||||
|
||||
it('keeps the field of a one-argument call', () => {
|
||||
expect(
|
||||
toDistributionAggregation(
|
||||
queryOf(DataSource.LOGS, ['avg(attribute.latency)']),
|
||||
).aggregations,
|
||||
).toStrictEqual([{ expression: 'attribute.latency' }]);
|
||||
});
|
||||
|
||||
it.each(['count_distinct(service.name)', 'countIf(status>=500)'])(
|
||||
'clears the field rather than bucket the argument of %s',
|
||||
(expression) => {
|
||||
expect(
|
||||
toDistributionAggregation(queryOf(DataSource.TRACES, [expression]))
|
||||
.aggregations,
|
||||
).toStrictEqual([{ expression: '' }]);
|
||||
},
|
||||
);
|
||||
|
||||
it('keeps a field with an alias', () => {
|
||||
const query = queryOf(DataSource.LOGS, ['body.latency as lat']);
|
||||
expect(toDistributionAggregation(query)).toBe(query);
|
||||
});
|
||||
|
||||
it('renames an order on the aggregation alias to the field', () => {
|
||||
const query = {
|
||||
...queryOf(DataSource.TRACES, []),
|
||||
aggregations: [{ expression: 'p99(duration_nano)', alias: 'lat' }],
|
||||
orderBy: [{ columnName: 'lat', order: 'desc' }],
|
||||
};
|
||||
expect(toDistributionAggregation(query).orderBy).toStrictEqual([
|
||||
{ columnName: 'duration_nano', order: 'desc' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('keeps the field of an inline-aliased call and moves the order on its alias', () => {
|
||||
const query = {
|
||||
...queryOf(DataSource.TRACES, ["p99(duration_nano) as 'lat'"]),
|
||||
orderBy: [{ columnName: 'lat', order: 'desc' }],
|
||||
};
|
||||
const next = toDistributionAggregation(query);
|
||||
expect(next.aggregations).toStrictEqual([{ expression: 'duration_nano' }]);
|
||||
expect(next.orderBy).toStrictEqual([
|
||||
{ columnName: 'duration_nano', order: 'desc' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('drops the order on an aggregation it clears', () => {
|
||||
const query = {
|
||||
...queryOf(DataSource.LOGS, ['count()']),
|
||||
orderBy: [
|
||||
{ columnName: 'count()', order: 'desc' },
|
||||
{ columnName: 'timestamp', order: 'asc' },
|
||||
],
|
||||
};
|
||||
expect(toDistributionAggregation(query).orderBy).toStrictEqual([
|
||||
{ columnName: 'timestamp', order: 'asc' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('drops orders on every aggregation it clears', () => {
|
||||
const query = {
|
||||
...queryOf(DataSource.TRACES, [
|
||||
'avg(duration_nano) max(attribute.quantity)',
|
||||
'count() as total',
|
||||
]),
|
||||
orderBy: [
|
||||
{ columnName: 'max(attribute.quantity)', order: 'desc' },
|
||||
{ columnName: 'total', order: 'asc' },
|
||||
{ columnName: 'timestamp', order: 'asc' },
|
||||
],
|
||||
};
|
||||
expect(toDistributionAggregation(query).orderBy).toStrictEqual([
|
||||
{ columnName: 'timestamp', order: 'asc' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('renames an order on the aggregation to the field', () => {
|
||||
const query = {
|
||||
...queryOf(DataSource.TRACES, ['p99(duration_nano)']),
|
||||
orderBy: [{ columnName: 'p99(duration_nano)', order: 'desc' }],
|
||||
};
|
||||
expect(toDistributionAggregation(query).orderBy).toStrictEqual([
|
||||
{ columnName: 'duration_nano', order: 'desc' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('leaves a metrics query alone', () => {
|
||||
const query = initialQueriesMap.metrics.builder.queryData[0];
|
||||
expect(toDistributionAggregation(query)).toBe(query);
|
||||
});
|
||||
});
|
||||
|
||||
describe('fromDistributionAggregation', () => {
|
||||
it.each([
|
||||
['duration_nano', 'p90(duration_nano)'],
|
||||
['', 'count()'],
|
||||
])('turns the field %j into %s', (field, expression) => {
|
||||
expect(
|
||||
fromDistributionAggregation(queryOf(DataSource.TRACES, [field]))
|
||||
.aggregations,
|
||||
).toStrictEqual([{ expression }]);
|
||||
});
|
||||
|
||||
it('drops the alias out of the field', () => {
|
||||
expect(
|
||||
fromDistributionAggregation(
|
||||
queryOf(DataSource.LOGS, ['body.latency as lat']),
|
||||
).aggregations,
|
||||
).toStrictEqual([{ expression: 'p90(body.latency)' }]);
|
||||
});
|
||||
|
||||
it('renames an order on the field to the new aggregation', () => {
|
||||
const query = {
|
||||
...queryOf(DataSource.TRACES, ['duration_nano']),
|
||||
orderBy: [{ columnName: 'duration_nano', order: 'asc' }],
|
||||
};
|
||||
expect(fromDistributionAggregation(query).orderBy).toStrictEqual([
|
||||
{ columnName: 'p90(duration_nano)', order: 'asc' },
|
||||
]);
|
||||
});
|
||||
|
||||
it.each([['count()'], ['count()', 'avg(x)']])(
|
||||
'leaves function aggregations %j alone',
|
||||
(...expressions) => {
|
||||
const query = queryOf(DataSource.LOGS, expressions);
|
||||
expect(fromDistributionAggregation(query)).toBe(query);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe('setDistributionField', () => {
|
||||
const sorted = {
|
||||
...queryOf(DataSource.TRACES, ['duration_nano']),
|
||||
orderBy: [{ columnName: 'duration_nano', order: 'desc' }],
|
||||
};
|
||||
|
||||
it('moves the sort on the old field to the new one', () => {
|
||||
expect(setDistributionField(sorted, 'attribute.quantity')).toMatchObject({
|
||||
aggregations: [{ expression: 'attribute.quantity' }],
|
||||
orderBy: [{ columnName: 'attribute.quantity', order: 'desc' }],
|
||||
});
|
||||
});
|
||||
|
||||
it('drops the sort when the field is cleared', () => {
|
||||
expect(setDistributionField(sorted, '').orderBy).toStrictEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -62,6 +62,28 @@ describe('handleQueryChange bucket options', () => {
|
||||
expect(result.builder.queryFormulas[0].bucketOptions).toBeUndefined();
|
||||
});
|
||||
|
||||
it.each([DataSource.LOGS, DataSource.TRACES])(
|
||||
'keeps the axis of a %s query that stays a heatmap',
|
||||
(dataSource) => {
|
||||
const base = initialQueriesMap[dataSource];
|
||||
const result = handleQueryChange(
|
||||
PANEL_TYPES.HEATMAP,
|
||||
{
|
||||
...base,
|
||||
builder: {
|
||||
...base.builder,
|
||||
queryData: [{ ...base.builder.queryData[0], bucketOptions }],
|
||||
},
|
||||
},
|
||||
PANEL_TYPES.HEATMAP,
|
||||
);
|
||||
|
||||
expect(result.builder.queryData[0].bucketOptions).toStrictEqual(
|
||||
bucketOptions,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it('leaves the rest of the formula intact', () => {
|
||||
const result = handleQueryChange(
|
||||
PANEL_TYPES.TIME_SERIES,
|
||||
@@ -102,6 +124,17 @@ describe('handleQueryChange trace operator', () => {
|
||||
expect(result.builder.queryTraceOperator).toStrictEqual([]);
|
||||
});
|
||||
|
||||
// A heatmap request takes one builder query and rejects a trace operator.
|
||||
it('drops the trace operator when switching to a heatmap', () => {
|
||||
const result = handleQueryChange(
|
||||
PANEL_TYPES.HEATMAP,
|
||||
queryWithTraceOperator(),
|
||||
PANEL_TYPES.TIME_SERIES,
|
||||
);
|
||||
|
||||
expect(result.builder.queryTraceOperator).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it('keeps the trace operator when switching to a table', () => {
|
||||
const result = handleQueryChange(
|
||||
PANEL_TYPES.TABLE,
|
||||
|
||||
46
frontend/src/lib/query/aggregationExpression.ts
Normal file
46
frontend/src/lib/query/aggregationExpression.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
/** An `as` alias: quoted, or an unquoted word that may carry dashes. */
|
||||
export const ALIAS = `(?:'[^']*'|"[^"]*"|[a-zA-Z0-9_-]+)`;
|
||||
|
||||
export const unquoteAlias = (alias: string): string =>
|
||||
alias.replace(/^['"]|['"]$/g, '');
|
||||
|
||||
/**
|
||||
* A logs or traces heatmap's aggregation: one field with an optional alias.
|
||||
* The field mirrors the querier's HeatmapAggregationField: no call, no whitespace.
|
||||
*/
|
||||
export const DISTRIBUTION_FIELD = new RegExp(
|
||||
`^\\s*([^\\s()]+)(?:\\s+as\\s+(${ALIAS}))?\\s*$`,
|
||||
);
|
||||
|
||||
// Utility to parse aggregation expressions with optional alias
|
||||
export function parseAggregations(
|
||||
expression: string,
|
||||
availableAlias?: string,
|
||||
allowDistributionField = false,
|
||||
): { expression: string; alias?: string }[] {
|
||||
const result: { expression: string; alias?: string }[] = [];
|
||||
// Matches function calls like "count()" or "sum(field)" with optional alias like "as 'alias'"
|
||||
// Handles quoted ('alias'), dash-separated (field-name), and unquoted values after "as" keyword
|
||||
const regex = new RegExp(
|
||||
`([a-zA-Z0-9_]+\\([^)]*\\))(?:\\s*as\\s+(${ALIAS}))?`,
|
||||
'g',
|
||||
);
|
||||
// With no call at all, the whole expression may be the field a logs/traces
|
||||
// heatmap buckets, e.g. "duration_nano"
|
||||
let match =
|
||||
regex.exec(expression) ??
|
||||
(allowDistributionField ? DISTRIBUTION_FIELD.exec(expression) : null);
|
||||
while (match !== null) {
|
||||
const expr = match[1];
|
||||
let alias = match[2] || availableAlias; // Use provided alias or availableAlias if not matched
|
||||
if (alias) {
|
||||
// Remove quotes if present
|
||||
alias = unquoteAlias(alias);
|
||||
result.push({ expression: expr, alias });
|
||||
} else {
|
||||
result.push({ expression: expr });
|
||||
}
|
||||
match = regex.exec(expression);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
140
frontend/src/lib/query/distributionField.ts
Normal file
140
frontend/src/lib/query/distributionField.ts
Normal file
@@ -0,0 +1,140 @@
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import type {
|
||||
IBuilderQuery,
|
||||
OrderByPayload,
|
||||
} from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
import type { LogAggregation, TraceAggregation } from 'types/api/v5/queryRange';
|
||||
|
||||
import {
|
||||
ALIAS,
|
||||
DISTRIBUTION_FIELD,
|
||||
parseAggregations,
|
||||
unquoteAlias,
|
||||
} from './aggregationExpression';
|
||||
|
||||
// A numeric one-argument call such as `p99(duration_nano) as lat`; group 1 is the
|
||||
// field, group 2 the inline alias. Other functions (`count_distinct`, `countIf`)
|
||||
// take text or a condition.
|
||||
const NUMERIC_FIELD_CALL = new RegExp(
|
||||
`^\\s*(?:avg|sum|min|max|p\\d{2})\\(\\s*([^\\s(),]+)\\s*\\)(?:\\s+as\\s+(${ALIAS}))?\\s*$`,
|
||||
);
|
||||
|
||||
/** The percentile a field or histogram metric gets when it leaves a heatmap. */
|
||||
export const DEFAULT_PERCENTILE = 'p90';
|
||||
|
||||
type FieldAggregation = TraceAggregation | LogAggregation;
|
||||
|
||||
const fieldAggregations = (query: IBuilderQuery): FieldAggregation[] =>
|
||||
(query.aggregations ?? []).filter(
|
||||
(aggregation): aggregation is FieldAggregation => 'expression' in aggregation,
|
||||
);
|
||||
|
||||
function isLogsOrTraces(
|
||||
dataSource: DataSource,
|
||||
): dataSource is DataSource.LOGS | DataSource.TRACES {
|
||||
return dataSource === DataSource.LOGS || dataSource === DataSource.TRACES;
|
||||
}
|
||||
|
||||
/** Whether the query's aggregation is a field rather than a function call. */
|
||||
export function aggregatesDistributionField(
|
||||
panelType: string | null | undefined,
|
||||
dataSource: DataSource,
|
||||
): boolean {
|
||||
return panelType === PANEL_TYPES.HEATMAP && isLogsOrTraces(dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces every aggregation with `to`. Order-by names an aggregation by its alias
|
||||
* when it has one, else its expression: the order on `from` moves to `to`, or is
|
||||
* dropped when `to` is empty, and orders on `removedKeys` go.
|
||||
*/
|
||||
function replaceAggregation(
|
||||
query: IBuilderQuery,
|
||||
from: Partial<FieldAggregation> | undefined,
|
||||
to: string,
|
||||
removedKeys: string[] = [],
|
||||
): IBuilderQuery {
|
||||
const fromKey = from?.alias || from?.expression;
|
||||
const isFrom = (order: OrderByPayload): boolean =>
|
||||
Boolean(fromKey) && order.columnName === fromKey;
|
||||
return {
|
||||
...query,
|
||||
aggregations: [{ expression: to }],
|
||||
orderBy: query.orderBy
|
||||
?.filter((order) =>
|
||||
isFrom(order) ? Boolean(to) : !removedKeys.includes(order.columnName),
|
||||
)
|
||||
.map((order) => (isFrom(order) ? { ...order, columnName: to } : order)),
|
||||
};
|
||||
}
|
||||
|
||||
export function getDistributionFieldPlaceholder(
|
||||
dataSource: DataSource,
|
||||
): string {
|
||||
return dataSource === DataSource.TRACES
|
||||
? 'Numeric field to bucket, e.g. duration_nano'
|
||||
: 'Numeric field to bucket';
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs and traces heatmaps bucket a field; any function aggregation is
|
||||
* rejected, so a numeric `fn(field)` keeps its field and anything else leaves
|
||||
* the field for the user to pick.
|
||||
*/
|
||||
export function toDistributionAggregation(query: IBuilderQuery): IBuilderQuery {
|
||||
if (!isLogsOrTraces(query.dataSource)) {
|
||||
return query;
|
||||
}
|
||||
const aggregations = fieldAggregations(query);
|
||||
const [first] = aggregations;
|
||||
const hasOneAggregation = aggregations.length === 1;
|
||||
if (hasOneAggregation && DISTRIBUTION_FIELD.test(first.expression ?? '')) {
|
||||
return query;
|
||||
}
|
||||
const fieldCall = hasOneAggregation
|
||||
? NUMERIC_FIELD_CALL.exec(first.expression ?? '')
|
||||
: null;
|
||||
const inlineAlias = fieldCall?.[2] && unquoteAlias(fieldCall[2]);
|
||||
const removedKeys = aggregations
|
||||
.flatMap(({ expression, alias }) =>
|
||||
parseAggregations(expression ?? '', alias),
|
||||
)
|
||||
.map(({ expression, alias }) => alias || expression);
|
||||
return replaceAggregation(
|
||||
query,
|
||||
{ ...first, alias: first?.alias || inlineAlias },
|
||||
fieldCall?.[1] ?? '',
|
||||
removedKeys,
|
||||
);
|
||||
}
|
||||
|
||||
/** Picks `field` as the heatmap's aggregation; a sort on the old field follows it. */
|
||||
export function setDistributionField(
|
||||
query: IBuilderQuery,
|
||||
field: string,
|
||||
): IBuilderQuery {
|
||||
const [first] = fieldAggregations(query);
|
||||
return replaceAggregation(query, first, field);
|
||||
}
|
||||
|
||||
/** Inverse of `toDistributionAggregation`: every other panel needs a function aggregation. */
|
||||
export function fromDistributionAggregation(
|
||||
query: IBuilderQuery,
|
||||
): IBuilderQuery {
|
||||
const aggregations = fieldAggregations(query);
|
||||
if (!isLogsOrTraces(query.dataSource) || aggregations.length !== 1) {
|
||||
return query;
|
||||
}
|
||||
const [first] = aggregations;
|
||||
const expression = first.expression?.trim() ?? '';
|
||||
const field = DISTRIBUTION_FIELD.exec(expression)?.[1];
|
||||
if (expression && !field) {
|
||||
return query;
|
||||
}
|
||||
return replaceAggregation(
|
||||
query,
|
||||
{ alias: first.alias, expression: field },
|
||||
field ? `${DEFAULT_PERCENTILE}(${field})` : 'count()',
|
||||
);
|
||||
}
|
||||
@@ -175,7 +175,9 @@ export function rebuildBuilderForPanelType(
|
||||
}),
|
||||
queryFormulas: withHeatmapBucketOptions(builder.queryFormulas, newPanelType),
|
||||
queryTraceOperator:
|
||||
newPanelType === PANEL_TYPES.LIST || newPanelType === PANEL_TYPES.SCATTER
|
||||
newPanelType === PANEL_TYPES.LIST ||
|
||||
newPanelType === PANEL_TYPES.SCATTER ||
|
||||
newPanelType === PANEL_TYPES.HEATMAP
|
||||
? []
|
||||
: builder.queryTraceOperator,
|
||||
};
|
||||
|
||||
@@ -122,12 +122,10 @@ const RAW_ROWS_METRICS: readonly BuilderField[] = omit(
|
||||
// `functions` and `having` are dropped rather than carried: the heatmap request
|
||||
// rejects both. Logs and traces keep the metrics aggregations too, because the map is
|
||||
// keyed by the query's own signal, which a switch can still be holding.
|
||||
const HEATMAP: readonly BuilderField[] = omit(
|
||||
SERIES_METRICS,
|
||||
'functions',
|
||||
'having',
|
||||
);
|
||||
const HEATMAP_METRICS: readonly BuilderField[] = [...HEATMAP, 'bucketOptions'];
|
||||
const HEATMAP: readonly BuilderField[] = [
|
||||
...omit(SERIES_METRICS, 'functions', 'having'),
|
||||
'bucketOptions',
|
||||
];
|
||||
|
||||
/** Each cell gets its own copy; a shared instance would let cells contaminate
|
||||
* each other. */
|
||||
@@ -150,7 +148,7 @@ export const panelTypeDataSourceFormValuesMap: Record<
|
||||
[PANEL_TYPES.AREA]: bySource(SERIES, SERIES_METRICS),
|
||||
[PANEL_TYPES.BAR]: bySource(SERIES, SERIES_METRICS),
|
||||
[PANEL_TYPES.HISTOGRAM]: bySource(SERIES, SERIES_METRICS),
|
||||
[PANEL_TYPES.HEATMAP]: bySource(HEATMAP, HEATMAP_METRICS),
|
||||
[PANEL_TYPES.HEATMAP]: bySource(HEATMAP, HEATMAP),
|
||||
[PANEL_TYPES.TABLE]: bySource(SERIES, SCALAR_METRICS),
|
||||
[PANEL_TYPES.PIE]: bySource(SERIES, SCALAR_METRICS),
|
||||
[PANEL_TYPES.SCATTER]: bySource(SERIES, SCALAR_METRICS),
|
||||
|
||||
@@ -52,6 +52,14 @@
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.bucketLabel {
|
||||
padding: var(--spacing-2) var(--gutter) 0;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--muted-foreground);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.filter {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -38,6 +38,7 @@ export default function HeatmapTooltip({
|
||||
series,
|
||||
visibleGroups,
|
||||
groupColor,
|
||||
bucketLabel,
|
||||
yAxisUnit,
|
||||
decimalPrecision,
|
||||
timezone,
|
||||
@@ -139,6 +140,15 @@ export default function HeatmapTooltip({
|
||||
{isPinned && <TooltipPinnedBadge />}
|
||||
</div>
|
||||
|
||||
{bucketLabel && (
|
||||
<div
|
||||
className={Styles.bucketLabel}
|
||||
data-testid="heatmap-tooltip-bucket-label"
|
||||
>
|
||||
{bucketLabel}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{filterLabel && (
|
||||
<div
|
||||
className={Styles.filter}
|
||||
|
||||
@@ -112,6 +112,22 @@ describe('HeatmapTooltip — cell identity', () => {
|
||||
expect(screen.getByTestId('heatmap-tooltip-count')).toHaveTextContent('455');
|
||||
});
|
||||
|
||||
it('names what the grid measures when the panel supplies it', () => {
|
||||
renderTooltip({ bucketLabel: 'Traces · duration_nano' });
|
||||
|
||||
expect(screen.getByTestId('heatmap-tooltip-bucket-label')).toHaveTextContent(
|
||||
'Traces · duration_nano',
|
||||
);
|
||||
});
|
||||
|
||||
it('leaves the bucket label out when there is none', () => {
|
||||
renderTooltip();
|
||||
|
||||
expect(
|
||||
screen.queryByTestId('heatmap-tooltip-bucket-label'),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('marks the surface as pinned so the border picks up the ring', () => {
|
||||
renderTooltip({ isPinned: true });
|
||||
|
||||
|
||||
@@ -121,6 +121,8 @@ export interface HeatmapTooltipProps
|
||||
visibleGroups: string[];
|
||||
/** Same colour the legend and the densest cells use. */
|
||||
groupColor: string;
|
||||
/** What the bucket axis measures, e.g. `Traces · duration_nano`. */
|
||||
bucketLabel?: string;
|
||||
}
|
||||
|
||||
export interface ScatterTooltipProps
|
||||
|
||||
@@ -68,6 +68,7 @@ export default function Heatmap(props: HeatmapChartProps): JSX.Element {
|
||||
yAxisUnit,
|
||||
decimalPrecision,
|
||||
timezone,
|
||||
bucketLabel,
|
||||
showVisualMap = true,
|
||||
showLegend = true,
|
||||
legendPosition = LegendPosition.BOTTOM,
|
||||
@@ -253,6 +254,7 @@ export default function Heatmap(props: HeatmapChartProps): JSX.Element {
|
||||
yAxisUnit={yAxisUnit}
|
||||
decimalPrecision={boundaryPrecision}
|
||||
timezone={timezone}
|
||||
bucketLabel={bucketLabel}
|
||||
canPinTooltip={canPinTooltip}
|
||||
renderTooltipFooter={renderTooltipFooter}
|
||||
/>
|
||||
@@ -267,6 +269,7 @@ export default function Heatmap(props: HeatmapChartProps): JSX.Element {
|
||||
yAxisUnit,
|
||||
boundaryPrecision,
|
||||
timezone,
|
||||
bucketLabel,
|
||||
canPinTooltip,
|
||||
renderTooltipFooter,
|
||||
],
|
||||
|
||||
@@ -142,6 +142,8 @@ export interface HeatmapChartProps {
|
||||
yAxisUnit?: string;
|
||||
decimalPrecision?: PrecisionOption;
|
||||
timezone?: Timezone;
|
||||
/** What the bucket axis measures, shown in the tooltip header, e.g. `Traces · duration_nano`. */
|
||||
bucketLabel?: string;
|
||||
/** Colour bar below the grid. Default true. */
|
||||
showVisualMap?: boolean;
|
||||
/** Default true; hidden anyway when there is only one group. The label isolates
|
||||
|
||||
@@ -87,9 +87,9 @@ describe('Dashboard settings - default time range', () => {
|
||||
|
||||
await user.click(await screen.findByTestId('dashboard-default-time-range'));
|
||||
|
||||
expect(
|
||||
await screen.findByRole('option', { name: 'Default (Last 30 minutes)' }),
|
||||
).toBeInTheDocument();
|
||||
await expect(
|
||||
screen.findByRole('option', { name: 'Default (Last 30 minutes)' }),
|
||||
).resolves.toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByRole('option', { name: 'Last 30 minutes', exact: true }),
|
||||
).not.toBeInTheDocument();
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
@include custom-scrollbar;
|
||||
}
|
||||
|
||||
// Without its own scroll area (View modal) it must not clip the where-clause autocomplete.
|
||||
.unclipped {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.scrollArea {
|
||||
// Top padding lives on the sticky tab nav instead, so the nav keeps its
|
||||
// breathing room both at rest and when pinned to the top.
|
||||
|
||||
@@ -193,7 +193,7 @@ function PanelEditorQueryBuilder({
|
||||
|
||||
return (
|
||||
<div
|
||||
className={styles.container}
|
||||
className={cx(styles.container, { [styles.unclipped]: !stickyHeader })}
|
||||
data-testid="panel-editor-v2-query-builder"
|
||||
onKeyDownCapture={handleKeyDownCapture}
|
||||
role="presentation"
|
||||
|
||||
@@ -304,6 +304,7 @@ describe('PanelEditorQueryBuilder field visibility (driven by the capabilities g
|
||||
expect(lastQueryBuilderProps().fieldsConfig).toStrictEqual({
|
||||
functions: { state: 'hidden' },
|
||||
having: { state: 'hidden' },
|
||||
trace_operator: { state: 'hidden' },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -327,10 +328,14 @@ describe('PanelEditorQueryBuilder signal dropdown (driven by the capabilities gu
|
||||
});
|
||||
});
|
||||
|
||||
it('offers metrics alone for the Heatmap kind — the only signal with a bucket axis', () => {
|
||||
it('offers every signal for the Heatmap kind', () => {
|
||||
renderBuilder('signoz/HeatmapPanel');
|
||||
|
||||
expect(lastQueryBuilderProps().allowedDataSources).toStrictEqual(['metrics']);
|
||||
expect(lastQueryBuilderProps().allowedDataSources).toStrictEqual([
|
||||
'metrics',
|
||||
'logs',
|
||||
'traces',
|
||||
]);
|
||||
});
|
||||
|
||||
it('offers logs and traces for the List kind, which reads raw rows', () => {
|
||||
|
||||
@@ -68,6 +68,17 @@ const CONVERTED = [{ id: 'converted' }] as unknown as NonNullable<
|
||||
>;
|
||||
const SWITCHED_SPEC = { switched: true } as unknown;
|
||||
|
||||
const tracesBuilder = (expression: string): Query['builder'] => ({
|
||||
...initialQueriesMap.traces.builder,
|
||||
queryData: [
|
||||
{
|
||||
...initialQueriesMap.traces.builder.queryData[0],
|
||||
aggregations: [{ expression }],
|
||||
},
|
||||
],
|
||||
queryFormulas: [],
|
||||
});
|
||||
|
||||
function makeSpec(
|
||||
kind: string,
|
||||
pluginSpec: unknown,
|
||||
@@ -290,6 +301,50 @@ describe('usePanelKindChange', () => {
|
||||
expect(persisted.builder.queryFormulas).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it('keeps the field of a traces function aggregation when switching to a Heatmap panel', () => {
|
||||
const setSpec = jest.fn();
|
||||
mockUseQueryBuilder.mockReturnValue(
|
||||
builderState(fakeQuery('ts-current', 'builder')),
|
||||
);
|
||||
mockRebuildBuilder.mockReturnValue(tracesBuilder('p99(duration_nano)'));
|
||||
|
||||
const { result } = renderHook(() =>
|
||||
usePanelKindChange({
|
||||
spec: makeSpec('signoz/TimeSeriesPanel', {}, TABLE_QUERIES),
|
||||
panelType: PANEL_TYPES.TIME_SERIES,
|
||||
setSpec,
|
||||
}),
|
||||
);
|
||||
act(() => result.current.onChangePanelKind('signoz/HeatmapPanel'));
|
||||
|
||||
const [persisted] = mockToPerses.mock.calls[0] as [Query];
|
||||
expect(persisted.builder.queryData[0].aggregations).toMatchObject([
|
||||
{ expression: 'duration_nano' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('wraps a traces heatmap field in a function when switching to a TimeSeries panel', () => {
|
||||
const setSpec = jest.fn();
|
||||
mockUseQueryBuilder.mockReturnValue(
|
||||
builderState(fakeQuery('heatmap-current', 'builder')),
|
||||
);
|
||||
mockRebuildBuilder.mockReturnValue(tracesBuilder('duration_nano'));
|
||||
|
||||
const { result } = renderHook(() =>
|
||||
usePanelKindChange({
|
||||
spec: makeSpec('signoz/HeatmapPanel', {}, TABLE_QUERIES),
|
||||
panelType: PANEL_TYPES.HEATMAP,
|
||||
setSpec,
|
||||
}),
|
||||
);
|
||||
act(() => result.current.onChangePanelKind('signoz/TimeSeriesPanel'));
|
||||
|
||||
const [persisted] = mockToPerses.mock.calls[0] as [Query];
|
||||
expect(persisted.builder.queryData[0].aggregations).toMatchObject([
|
||||
{ expression: 'p90(duration_nano)' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('swaps a percentile spatial aggregation for count when switching to a Heatmap panel', () => {
|
||||
const setSpec = jest.fn();
|
||||
mockUseQueryBuilder.mockReturnValue(
|
||||
|
||||
@@ -9,6 +9,10 @@ import type {
|
||||
import type { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { QueryBuilderField } from 'components/QueryBuilderV2/queryBuilderFields.types';
|
||||
import { resolveQueryBuilderField } from 'components/QueryBuilderV2/queryBuilderFields.utils';
|
||||
import {
|
||||
fromDistributionAggregation,
|
||||
toDistributionAggregation,
|
||||
} from 'lib/query/distributionField';
|
||||
import { rebuildBuilderForPanelType } from 'lib/query/panelQuery';
|
||||
import type { PartialPanelTypes } from 'lib/query/panelTypeDataSourceFormValuesMap';
|
||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||
@@ -182,9 +186,16 @@ export function usePanelKindChange({
|
||||
: transformed,
|
||||
newKind,
|
||||
);
|
||||
return newKind === 'signoz/HeatmapPanel'
|
||||
? withSingleHeatmapQuery(ordered)
|
||||
: withPercentileHistogramAggregation(ordered);
|
||||
const isHeatmap = newKind === 'signoz/HeatmapPanel';
|
||||
const converted = {
|
||||
...ordered,
|
||||
queryData: ordered.queryData.map(
|
||||
isHeatmap ? toDistributionAggregation : fromDistributionAggregation,
|
||||
),
|
||||
};
|
||||
return isHeatmap
|
||||
? withSingleHeatmapQuery(converted)
|
||||
: withPercentileHistogramAggregation(converted);
|
||||
};
|
||||
|
||||
// Revisit → restore the stash (the reversibility path) on the tab in use, an AI
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ATTRIBUTE_TYPES } from 'constants/queryBuilder';
|
||||
import { DEFAULT_PERCENTILE } from 'lib/query/distributionField';
|
||||
import type {
|
||||
IBuilderQuery,
|
||||
Query,
|
||||
@@ -21,8 +22,6 @@ const HISTOGRAM_ATTRIBUTE_TYPES = new Set<string>([
|
||||
ATTRIBUTE_TYPES.EXPONENTIAL_HISTOGRAM,
|
||||
]);
|
||||
|
||||
const DEFAULT_HISTOGRAM_SPACE_AGGREGATION = 'p90';
|
||||
|
||||
/** What a heatmap cell holds, and the one space aggregation the kind offers. */
|
||||
const HEATMAP_HISTOGRAM_SPACE_AGGREGATION = 'count';
|
||||
|
||||
@@ -106,7 +105,7 @@ export function withPercentileHistogramAggregation(
|
||||
function withoutCount<T extends string | undefined>(spaceAggregation: T): T {
|
||||
return (
|
||||
spaceAggregation === HEATMAP_HISTOGRAM_SPACE_AGGREGATION
|
||||
? DEFAULT_HISTOGRAM_SPACE_AGGREGATION
|
||||
? DEFAULT_PERCENTILE
|
||||
: spaceAggregation
|
||||
) as T;
|
||||
}
|
||||
|
||||
@@ -77,8 +77,7 @@ const EXPECTED_SIGNALS: Record<PanelKind, TelemetrytypesSignalDTO[]> = {
|
||||
'signoz/AreaChartPanel': [metrics, logs, traces],
|
||||
'signoz/NumberPanel': [metrics, logs, traces],
|
||||
'signoz/HistogramPanel': [metrics, logs, traces],
|
||||
// A heatmap needs a bucket axis, which only a metric carries.
|
||||
'signoz/HeatmapPanel': [metrics],
|
||||
'signoz/HeatmapPanel': [metrics, logs, traces],
|
||||
'signoz/PieChartPanel': [metrics, logs, traces],
|
||||
'signoz/GeoMapPanel': [metrics, logs, traces],
|
||||
'signoz/TopListPanel': [metrics, logs, traces],
|
||||
@@ -196,6 +195,7 @@ const ALL_KINDS = Object.keys(EXPECTED_QUERY_TYPES) as PanelKind[];
|
||||
const HIDES_TRACE_OPERATOR: PanelKind[] = [
|
||||
'signoz/ScatterPlotPanel',
|
||||
'signoz/GeoMapPanel',
|
||||
'signoz/HeatmapPanel',
|
||||
];
|
||||
|
||||
describe('panel capabilities guard', () => {
|
||||
|
||||
@@ -25,6 +25,7 @@ import { getPanelTimeRange } from '../../utils/getPanelTimeRange';
|
||||
import {
|
||||
prepareHeatmapData,
|
||||
resolveHeatmapStep,
|
||||
resolveBucketLabel,
|
||||
resolveRequestedBucketKind,
|
||||
} from './prepareData';
|
||||
|
||||
@@ -86,6 +87,11 @@ function HeatmapPanelRenderer({
|
||||
[spec.axes?.y?.scale, data.requestPayload],
|
||||
);
|
||||
|
||||
const bucketLabel = useMemo(
|
||||
() => resolveBucketLabel(data.requestPayload),
|
||||
[data.requestPayload],
|
||||
);
|
||||
|
||||
const decimalPrecision = useMemo(
|
||||
() => resolveDecimalPrecision(spec.formatting?.decimalPrecision),
|
||||
[spec.formatting?.decimalPrecision],
|
||||
@@ -132,6 +138,7 @@ function HeatmapPanelRenderer({
|
||||
axisScale={axisScale}
|
||||
yAxisUnit={spec.formatting?.unit}
|
||||
decimalPrecision={decimalPrecision}
|
||||
bucketLabel={bucketLabel}
|
||||
legendPosition={legendPosition}
|
||||
timezone={timezone}
|
||||
isDarkMode={isDarkMode}
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
FALLBACK_STEP_SECONDS,
|
||||
prepareHeatmapData,
|
||||
resolveHeatmapStep,
|
||||
resolveBucketLabel,
|
||||
resolveRequestedBucketKind,
|
||||
} from '../prepareData';
|
||||
|
||||
@@ -156,14 +157,12 @@ describe('resolveHeatmapStep', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveRequestedBucketKind', () => {
|
||||
const request = (
|
||||
queries: unknown[],
|
||||
): Querybuildertypesv5QueryRangeRequestDTO =>
|
||||
({
|
||||
compositeQuery: { queries },
|
||||
}) as Querybuildertypesv5QueryRangeRequestDTO;
|
||||
const request = (queries: unknown[]): Querybuildertypesv5QueryRangeRequestDTO =>
|
||||
({
|
||||
compositeQuery: { queries },
|
||||
}) as Querybuildertypesv5QueryRangeRequestDTO;
|
||||
|
||||
describe('resolveRequestedBucketKind', () => {
|
||||
it('reads the kind off the query that carries a bucket axis', () => {
|
||||
expect(
|
||||
resolveRequestedBucketKind(
|
||||
@@ -205,3 +204,49 @@ describe('resolveRequestedBucketKind', () => {
|
||||
expect(resolveRequestedBucketKind(undefined)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveBucketLabel', () => {
|
||||
it.each([
|
||||
[
|
||||
'a metric',
|
||||
[
|
||||
{
|
||||
spec: {
|
||||
signal: 'metrics',
|
||||
aggregations: [{ metricName: 'http_latency' }],
|
||||
},
|
||||
},
|
||||
],
|
||||
'Metrics · http_latency',
|
||||
],
|
||||
[
|
||||
'a traces field',
|
||||
[
|
||||
{
|
||||
spec: {
|
||||
signal: 'traces',
|
||||
aggregations: [{ expression: 'duration_nano' }],
|
||||
},
|
||||
},
|
||||
],
|
||||
'Traces · duration_nano',
|
||||
],
|
||||
[
|
||||
'the enabled query, past a disabled one',
|
||||
[
|
||||
{
|
||||
spec: {
|
||||
signal: 'logs',
|
||||
disabled: true,
|
||||
aggregations: [{ expression: 'code.lineno' }],
|
||||
},
|
||||
},
|
||||
{ spec: { signal: 'logs', aggregations: [{ expression: 'quantity' }] } },
|
||||
],
|
||||
'Logs · quantity',
|
||||
],
|
||||
['nothing for ClickHouse', [{ spec: { query: 'SELECT 1' } }], undefined],
|
||||
])('names %s', (_label, queries, expected) => {
|
||||
expect(resolveBucketLabel(request(queries))).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,10 +22,14 @@ export const definition: PanelDefinition<'signoz/HeatmapPanel'> = {
|
||||
EditorPane: QueryBuilderEditorPane,
|
||||
sections,
|
||||
supportedQueryTypesKindMap: {
|
||||
// Only metrics carry a bucket axis; the request rejects the other signals.
|
||||
// Logs and traces bucket the field named as the aggregation.
|
||||
[EQueryType.QUERY_BUILDER]: {
|
||||
kind: QueryTypeKind.SIGNAL,
|
||||
signals: [TelemetrytypesSignalDTO.metrics],
|
||||
signals: [
|
||||
TelemetrytypesSignalDTO.metrics,
|
||||
TelemetrytypesSignalDTO.logs,
|
||||
TelemetrytypesSignalDTO.traces,
|
||||
],
|
||||
},
|
||||
[EQueryType.CLICKHOUSE]: { kind: QueryTypeKind.SIGNAL_LESS },
|
||||
[EQueryType.PROM]: { kind: QueryTypeKind.SIGNAL_LESS },
|
||||
@@ -34,6 +38,8 @@ export const definition: PanelDefinition<'signoz/HeatmapPanel'> = {
|
||||
queryBuilderFields: {
|
||||
[QueryBuilderField.Functions]: { state: 'hidden' },
|
||||
[QueryBuilderField.Having]: { state: 'hidden' },
|
||||
// The request takes one builder query and has no case for a trace operator.
|
||||
[QueryBuilderField.TraceOperator]: { state: 'hidden' },
|
||||
},
|
||||
// Every timestamp is a full column of cells, so the request asks for a step interval
|
||||
// wide enough to keep the grid legible: at raw resolution a multi-day range is tens of
|
||||
|
||||
@@ -5,11 +5,13 @@ import type {
|
||||
Querybuildertypesv5TimeSeriesDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
import getLabelName from 'lib/getLabelName';
|
||||
import { upperFirst } from 'lodash-es';
|
||||
import type {
|
||||
HeatmapSeries,
|
||||
HeatmapSeriesLabel,
|
||||
HeatmapSeriesPoint,
|
||||
} from 'lib/uPlotV2/plugins/HeatmapPlugin/types';
|
||||
import type { QuerySpecView } from 'pages/DashboardPage/DashboardContainer/queryV5/buildQueryRangeRequest';
|
||||
|
||||
const MS_PER_SECOND = 1000;
|
||||
|
||||
@@ -82,6 +84,25 @@ export function resolveRequestedBucketKind(
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* What the grid buckets, named for the tooltip: `<Signal> · <metric or field>`, off
|
||||
* the first enabled builder query. `undefined` for ClickHouse and PromQL, which name
|
||||
* neither.
|
||||
*/
|
||||
export function resolveBucketLabel(
|
||||
request: Querybuildertypesv5QueryRangeRequestDTO | undefined,
|
||||
): string | undefined {
|
||||
for (const envelope of request?.compositeQuery?.queries ?? []) {
|
||||
const spec = envelope.spec as QuerySpecView | undefined;
|
||||
const [aggregation] = spec?.aggregations ?? [];
|
||||
const bucketed = aggregation?.metricName || aggregation?.expression;
|
||||
if (spec?.signal && !spec.disabled && bucketed) {
|
||||
return `${upperFirst(spec.signal)} · ${bucketed}`;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Column width in seconds. The server's effective step is authoritative — the
|
||||
* last column has no successor to infer a width from — so the timestamp delta is
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
.queryBuilder {
|
||||
flex: 0 0 auto;
|
||||
overflow: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
@@ -477,6 +477,47 @@ describe('extractLegendMap', () => {
|
||||
});
|
||||
|
||||
describe('hasRunnableQueries', () => {
|
||||
const heatmapQuery = (
|
||||
signal: string,
|
||||
aggregations: Record<string, unknown>[],
|
||||
): DashboardtypesQueryDTO[] =>
|
||||
compositeQuery([
|
||||
{ type: 'builder_query', spec: { name: 'A', signal, aggregations } },
|
||||
]).map((query) => ({ ...query, kind: 'heatmap' }) as DashboardtypesQueryDTO);
|
||||
|
||||
it.each([
|
||||
['logs', [], false],
|
||||
['traces', [{ expression: ' ' }], false],
|
||||
['traces', [{ expression: 'duration_nano' }], true],
|
||||
['metrics', [{ metricName: 'http_latency' }], true],
|
||||
])(
|
||||
'%s heatmap with aggregations %j is runnable: %s',
|
||||
(signal, aggregations, runnable) => {
|
||||
expect(hasRunnableQueries(heatmapQuery(signal, aggregations))).toBe(
|
||||
runnable,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it('ignores a disabled heatmap query with no field', () => {
|
||||
const queries = compositeQuery([
|
||||
{
|
||||
type: 'builder_query',
|
||||
spec: {
|
||||
name: 'A',
|
||||
signal: 'traces',
|
||||
aggregations: [{ expression: 'duration_nano' }],
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'builder_query',
|
||||
spec: { name: 'B', signal: 'logs', aggregations: [], disabled: true },
|
||||
},
|
||||
]).map((query) => ({ ...query, kind: 'heatmap' }) as DashboardtypesQueryDTO);
|
||||
|
||||
expect(hasRunnableQueries(queries)).toBe(true);
|
||||
});
|
||||
|
||||
it('false when the panel has no queries', () => {
|
||||
expect(hasRunnableQueries([])).toBe(false);
|
||||
});
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
Querybuildertypesv5QueryEnvelopeBuilderDTOType,
|
||||
Querybuildertypesv5QueryEnvelopeClickHouseSQLDTOType,
|
||||
Querybuildertypesv5QueryEnvelopePromQLDTOType,
|
||||
Querybuildertypesv5RequestTypeDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
|
||||
import type { PanelQueryCapabilities } from '../Panels/types/panelCapabilities';
|
||||
@@ -26,12 +27,13 @@ import {
|
||||
|
||||
// Narrow view over the envelope spec variants. Orval erases envelope `spec` to `unknown`, so
|
||||
// shared fields are read through this view with a localized cast at the envelope boundary.
|
||||
interface QuerySpecView {
|
||||
export interface QuerySpecView {
|
||||
name?: string;
|
||||
legend?: string;
|
||||
signal?: string;
|
||||
stepInterval?: number | string;
|
||||
aggregations?: { metricName?: string }[];
|
||||
disabled?: boolean;
|
||||
aggregations?: { metricName?: string; expression?: string }[];
|
||||
order?: Querybuildertypesv5OrderByDTO[];
|
||||
}
|
||||
|
||||
@@ -325,8 +327,9 @@ export function extractLegendMap(
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch gate. False with no queries, or when every metrics builder query lacks a metric name —
|
||||
* skipping a guaranteed 400 (V1 parity: `validateMetricNameForMetricsDataSource`).
|
||||
* Fetch gate. False with no queries, when every metrics builder query lacks a metric name —
|
||||
* skipping a guaranteed 400 (V1 parity: `validateMetricNameForMetricsDataSource`) — or when a
|
||||
* logs/traces heatmap names no field to bucket.
|
||||
*/
|
||||
export function hasRunnableQueries(queries: DashboardtypesQueryDTO[]): boolean {
|
||||
const envelopes = toQueryEnvelopes(queries);
|
||||
@@ -334,10 +337,23 @@ export function hasRunnableQueries(queries: DashboardtypesQueryDTO[]): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
const metricsSpecs = envelopes
|
||||
const builderSpecs = envelopes
|
||||
.filter(isBuilderEnvelope)
|
||||
.map((envelope) => envelope.spec as QuerySpecView)
|
||||
.filter((spec) => spec.signal === 'metrics');
|
||||
.map((envelope) => envelope.spec as QuerySpecView);
|
||||
|
||||
if (
|
||||
queries[0].kind === Querybuildertypesv5RequestTypeDTO.heatmap &&
|
||||
builderSpecs.some(
|
||||
(spec) =>
|
||||
!spec.disabled &&
|
||||
spec.signal !== 'metrics' &&
|
||||
!spec.aggregations?.[0]?.expression?.trim(),
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const metricsSpecs = builderSpecs.filter((spec) => spec.signal === 'metrics');
|
||||
|
||||
if (metricsSpecs.length === 0) {
|
||||
return true;
|
||||
|
||||
@@ -56,6 +56,7 @@ import {
|
||||
EDITOR_METRICS,
|
||||
NEW_PANEL_KINDS,
|
||||
newPanelKindOf,
|
||||
numericFieldKeysResponse,
|
||||
type NewPanelKind,
|
||||
} from './__story_mockdata__/panelEditor';
|
||||
|
||||
@@ -192,7 +193,11 @@ export const panelEditorMocks = defineStoryMocks({
|
||||
|
||||
rest.get(
|
||||
'http://localhost/api/v1/fields/keys',
|
||||
response.json(() => fieldKeysResponse(EDITOR_FIELD_KEYS)),
|
||||
response.json((req) =>
|
||||
req.url.searchParams.get('fieldDataType') === 'number'
|
||||
? numericFieldKeysResponse()
|
||||
: fieldKeysResponse(EDITOR_FIELD_KEYS),
|
||||
),
|
||||
),
|
||||
|
||||
rest.get(
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
openClickHouseQuery,
|
||||
openPanelTypeSwitcher,
|
||||
openPromQLQuery,
|
||||
pickHeatmapTracesField,
|
||||
saveAndExpectToast,
|
||||
} from './__story_mockdata__/panelEditor.play';
|
||||
|
||||
@@ -188,6 +189,15 @@ export const ConfigHeatmap: Story = {
|
||||
play: expandConfigSections,
|
||||
};
|
||||
|
||||
/**
|
||||
* A new heatmap switched to traces: the aggregation becomes a picker of the
|
||||
* signal's numeric fields.
|
||||
*/
|
||||
export const HeatmapTracesField: Story = {
|
||||
args: { panel: 'new', newPanelKind: 'heatmap' },
|
||||
play: pickHeatmapTracesField,
|
||||
};
|
||||
|
||||
/** A new list panel's config pane, every section expanded. */
|
||||
export const ConfigList: Story = {
|
||||
args: { panel: 'new', newPanelKind: 'list' },
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
hasClickHouseTab,
|
||||
hasDisconnectValues,
|
||||
hasPromQLTab,
|
||||
openConfigSelect,
|
||||
type PanelEditorArgs,
|
||||
pickSegment,
|
||||
savePanel,
|
||||
@@ -114,6 +115,25 @@ export const openAIQueryBuilder = async ({
|
||||
}
|
||||
};
|
||||
|
||||
/** Switches a new heatmap to traces and opens its field picker. */
|
||||
export const pickHeatmapTracesField = async ({
|
||||
args,
|
||||
}: Pick<PlayContext, 'args'>): Promise<void> => {
|
||||
await openConfigSelect('query-data-source-selector-0');
|
||||
await userEvent.click(await screen.findByTitle('Traces'));
|
||||
|
||||
await userEvent.click(
|
||||
await screen.findByTestId('distribution-field-select', {}, EDITOR_LOAD),
|
||||
);
|
||||
if (args.dataState === 'loaded') {
|
||||
await screen.findByTestId(
|
||||
'distribution-field-select-item-attribute.retry.count',
|
||||
{},
|
||||
EDITOR_LOAD,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const openClickHouseQuery = async ({
|
||||
canvasElement,
|
||||
args,
|
||||
|
||||
@@ -4,10 +4,15 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
type GetFieldsKeys200,
|
||||
MetrictypesTemporalityDTO,
|
||||
MetrictypesTypeDTO,
|
||||
TelemetrytypesFieldContextDTO,
|
||||
TelemetrytypesSignalDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
|
||||
import { fieldKeysResponse } from '@/storybook/msw/__story_mockdata__/fields';
|
||||
|
||||
import {
|
||||
metricSeed,
|
||||
type MetricSeed,
|
||||
@@ -104,3 +109,21 @@ export const EDITOR_METRICS: MetricSeed[] = [
|
||||
MetrictypesTemporalityDTO.unspecified,
|
||||
),
|
||||
];
|
||||
|
||||
/** The numeric keys a logs or traces heatmap's field picker asks for. */
|
||||
export const numericFieldKeysResponse = (): GetFieldsKeys200 => {
|
||||
const signal = TelemetrytypesSignalDTO.traces;
|
||||
const span = fieldKeysResponse(['duration_nano'], {
|
||||
signal,
|
||||
fieldContext: TelemetrytypesFieldContextDTO.span,
|
||||
});
|
||||
const attribute = fieldKeysResponse(['retry.count', 'http.response.size'], {
|
||||
signal,
|
||||
fieldContext: TelemetrytypesFieldContextDTO.attribute,
|
||||
});
|
||||
|
||||
return {
|
||||
...span,
|
||||
data: { ...span.data, keys: { ...span.data.keys, ...attribute.data.keys } },
|
||||
};
|
||||
};
|
||||
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
HEATMAP_COUNT_RANGES,
|
||||
HEATMAP_FIXED_COUNTS,
|
||||
HEATMAP_PALETTES,
|
||||
HEATMAP_SOURCES,
|
||||
HEATMAP_Y_SCALES,
|
||||
LEGEND_POSITIONS,
|
||||
LINE_STYLES,
|
||||
@@ -61,6 +62,7 @@ import type {
|
||||
BucketWidth,
|
||||
Gaps,
|
||||
HeatmapCountRange,
|
||||
HeatmapSource,
|
||||
PanelArgs,
|
||||
PanelKind,
|
||||
PanelResult,
|
||||
@@ -135,6 +137,13 @@ export const panelsMocks = defineStoryMocks({
|
||||
options: HEATMAP_COUNT_RANGES,
|
||||
value: 'auto',
|
||||
}),
|
||||
heatmapSource: choiceControl<HeatmapSource>('Heatmap source', {
|
||||
group: PANEL,
|
||||
description:
|
||||
'The signal the heatmap buckets: a metric, a log field (`attribute.queue_depth`), a span field (`duration_nano`), or a traces query whose field was cleared, which the panel does not run.',
|
||||
options: HEATMAP_SOURCES,
|
||||
value: 'metrics',
|
||||
}),
|
||||
bucketWidth: choiceControl<BucketWidth>('Histogram bucket width', {
|
||||
group: PANEL,
|
||||
description:
|
||||
|
||||
@@ -112,6 +112,24 @@ export const HeatmapLog: Story = {
|
||||
play: playPanel,
|
||||
};
|
||||
|
||||
/** A traces heatmap bucketing each span's `duration_nano`. */
|
||||
export const HeatmapTraces: Story = {
|
||||
args: { kind: 'Heatmap', heatmapSource: 'traces' },
|
||||
play: playPanel,
|
||||
};
|
||||
|
||||
/** A logs heatmap bucketing the `attribute.queue_depth` log field. */
|
||||
export const HeatmapLogs: Story = {
|
||||
args: { kind: 'Heatmap', heatmapSource: 'logs' },
|
||||
play: playPanel,
|
||||
};
|
||||
|
||||
/** A traces heatmap with no field to bucket: the panel waits for one instead of querying. */
|
||||
export const HeatmapNoField: Story = {
|
||||
args: { kind: 'Heatmap', heatmapSource: 'no field' },
|
||||
play: playPanel,
|
||||
};
|
||||
|
||||
/** The heatmap's colour bar pinned to a fixed 5–250 count range. */
|
||||
export const HeatmapCountRange: Story = {
|
||||
args: { kind: 'Heatmap', heatmapCounts: 'fixed' },
|
||||
|
||||
@@ -54,6 +54,19 @@ export const HEATMAP_Y_SCALES = Object.values(HeatmapYScale);
|
||||
|
||||
export const HEATMAP_COUNT_RANGES = ['auto', 'fixed'] as const;
|
||||
|
||||
export const HEATMAP_SOURCES = [
|
||||
'metrics',
|
||||
'logs',
|
||||
'traces',
|
||||
'no field',
|
||||
] as const;
|
||||
|
||||
/** The field a logs or traces heatmap buckets. */
|
||||
export const HEATMAP_FIELDS = {
|
||||
logs: 'attribute.queue_depth',
|
||||
traces: 'duration_nano',
|
||||
} as const;
|
||||
|
||||
/** The colour bar's bounds under the `fixed` count range. */
|
||||
export const HEATMAP_FIXED_COUNTS = { min: 5, max: 250 };
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import {
|
||||
import {
|
||||
comparisonThresholds,
|
||||
labelThresholds,
|
||||
eventHeatmapQuery,
|
||||
logQuery,
|
||||
metricQuery,
|
||||
tableThresholds,
|
||||
@@ -132,7 +133,9 @@ export const panelShape = (args: PanelArgs): PanelShape => {
|
||||
},
|
||||
},
|
||||
queries: [
|
||||
metricQuery(RequestType.heatmap, { grouped: true, heatmap: true }),
|
||||
args.heatmapSource === 'metrics'
|
||||
? metricQuery(RequestType.heatmap, { grouped: true, heatmap: true })
|
||||
: eventHeatmapQuery(args.heatmapSource),
|
||||
],
|
||||
};
|
||||
case 'Pie':
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
Querybuildertypesv5OrderDirectionDTO as OrderDirection,
|
||||
Querybuildertypesv5QueryBuilderQueryGithubComSigNozSignozPkgTypesQuerybuildertypesQuerybuildertypesv5LogAggregationDTOSignal as LogSignal,
|
||||
Querybuildertypesv5QueryBuilderQueryGithubComSigNozSignozPkgTypesQuerybuildertypesQuerybuildertypesv5MetricAggregationDTOSignal as MetricSignal,
|
||||
Querybuildertypesv5QueryBuilderQueryGithubComSigNozSignozPkgTypesQuerybuildertypesQuerybuildertypesv5TraceAggregationDTOSignal as TraceSignal,
|
||||
Querybuildertypesv5RequestTypeDTO as RequestType,
|
||||
type DashboardtypesComparisonThresholdDTO,
|
||||
type DashboardtypesQueryDTO,
|
||||
@@ -20,17 +21,19 @@ import {
|
||||
type DashboardtypesThresholdWithLabelDTO,
|
||||
type Querybuildertypesv5QueryBuilderQueryGithubComSigNozSignozPkgTypesQuerybuildertypesQuerybuildertypesv5LogAggregationDTO as LogBuilderQuery,
|
||||
type Querybuildertypesv5QueryBuilderQueryGithubComSigNozSignozPkgTypesQuerybuildertypesQuerybuildertypesv5MetricAggregationDTO as MetricBuilderQuery,
|
||||
type Querybuildertypesv5QueryBuilderQueryGithubComSigNozSignozPkgTypesQuerybuildertypesQuerybuildertypesv5TraceAggregationDTO as TraceBuilderQuery,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
|
||||
import {
|
||||
CHART_THRESHOLD_VALUE,
|
||||
HEATMAP_FIELDS,
|
||||
NUMBER_THRESHOLD_VALUE,
|
||||
QUERY_NAME,
|
||||
TABLE_THRESHOLD_VALUE,
|
||||
TABLE_VALUE_COLUMN,
|
||||
THRESHOLD_COLOR,
|
||||
} from './constants';
|
||||
import type { TextSample } from './types';
|
||||
import type { HeatmapSource, TextSample } from './types';
|
||||
|
||||
export const labelThresholds = (
|
||||
on: boolean,
|
||||
@@ -149,3 +152,42 @@ export const logQuery = (): DashboardtypesQueryDTO => {
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
/** `no field` is a traces heatmap whose field was cleared: it saves with no aggregation. */
|
||||
export const eventHeatmapQuery = (
|
||||
source: Exclude<HeatmapSource, 'metrics'>,
|
||||
): DashboardtypesQueryDTO => {
|
||||
const groupBy = [{ name: 'service.name' }];
|
||||
const legend = '{{service.name}}';
|
||||
const bucketOptions = {
|
||||
kind: LinearBuckets.linear,
|
||||
spec: { maxValue: 1000, numBuckets: 10 },
|
||||
};
|
||||
const spec: LogBuilderQuery | TraceBuilderQuery =
|
||||
source === 'logs'
|
||||
? {
|
||||
name: QUERY_NAME,
|
||||
signal: LogSignal.logs,
|
||||
aggregations: [{ expression: HEATMAP_FIELDS.logs }],
|
||||
groupBy,
|
||||
legend,
|
||||
bucketOptions,
|
||||
}
|
||||
: {
|
||||
name: QUERY_NAME,
|
||||
signal: TraceSignal.traces,
|
||||
aggregations:
|
||||
source === 'traces' ? [{ expression: HEATMAP_FIELDS.traces }] : [],
|
||||
groupBy,
|
||||
legend,
|
||||
bucketOptions,
|
||||
};
|
||||
|
||||
return {
|
||||
kind: RequestType.heatmap,
|
||||
spec: {
|
||||
name: QUERY_NAME,
|
||||
plugin: { kind: BuilderQueryKind['signoz/BuilderQuery'], spec },
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -18,6 +18,7 @@ import type {
|
||||
BUCKET_WIDTHS,
|
||||
GAPS,
|
||||
HEATMAP_COUNT_RANGES,
|
||||
HEATMAP_SOURCES,
|
||||
PANEL_KINDS,
|
||||
PANEL_RESULTS,
|
||||
PIE_SLICES,
|
||||
@@ -36,6 +37,8 @@ export type PanelUnit = (typeof UNITS)[number];
|
||||
|
||||
export type HeatmapCountRange = (typeof HEATMAP_COUNT_RANGES)[number];
|
||||
|
||||
export type HeatmapSource = (typeof HEATMAP_SOURCES)[number];
|
||||
|
||||
export type BucketWidth = (typeof BUCKET_WIDTHS)[number];
|
||||
|
||||
export type TextSample = (typeof TEXT_SAMPLES)[number];
|
||||
@@ -60,6 +63,7 @@ export interface PanelArgs {
|
||||
palette: HeatmapPalette;
|
||||
heatmapScale: HeatmapYScale;
|
||||
heatmapCounts: HeatmapCountRange;
|
||||
heatmapSource: HeatmapSource;
|
||||
bucketWidth: BucketWidth;
|
||||
textSample: TextSample;
|
||||
textAlign: TextAlign;
|
||||
|
||||
@@ -58,6 +58,12 @@ export const expectPanel = async (
|
||||
|
||||
await within(root).findByText(PANEL_NAME[args.kind], {}, PANEL_LOAD);
|
||||
|
||||
if (args.kind === 'Heatmap' && args.heatmapSource === 'no field') {
|
||||
await within(root).findByTestId('panel-no-query', {}, PANEL_LOAD);
|
||||
await expect(findPlot(root)).toBeUndefined();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hasData(args)) {
|
||||
await expectNoData(root, args);
|
||||
return;
|
||||
|
||||
@@ -23,21 +23,6 @@
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.headerZone {
|
||||
// Sticks to the top of the scroll area so the heading + filters stay put while
|
||||
// the results scroll beneath. Its own stacking context sits above the rows; the
|
||||
// DSL suggestion popup (z-index 1000) still layers above everything.
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 5;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
padding: 20px 24px;
|
||||
background: var(--l2-background);
|
||||
border-bottom: 1px solid var(--l2-border);
|
||||
}
|
||||
|
||||
.emptyWrap {
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import DashboardsFilterZone from '../DashboardsFilterZone/DashboardsFilterZone';
|
||||
import NewDashboardModal from '../NewDashboardModal/NewDashboardModal';
|
||||
import type { ReactElement } from 'react';
|
||||
import ListCommandHeader from 'components/ListViews/ListCommandHeader/ListCommandHeader';
|
||||
import ListHeaderZone from 'components/ListViews/ListHeaderZone/ListHeaderZone';
|
||||
import ListStatusBar from 'components/ListViews/ListStatusBar/ListStatusBar';
|
||||
import type { ViewSaveMode } from 'components/ListViews/types';
|
||||
import ViewsRail from 'components/ListViews/ViewsRail/ViewsRail';
|
||||
@@ -324,60 +325,62 @@ function DashboardsList(): JSX.Element {
|
||||
/>
|
||||
<div className={styles.main}>
|
||||
<div className={styles.mainScroll}>
|
||||
<ListHeaderZone testId="dashboards-header-zone">
|
||||
<ListCommandHeader
|
||||
label={activeLabel}
|
||||
count={total}
|
||||
isCountLoading={isFetching}
|
||||
isModified={isModified}
|
||||
action={
|
||||
isWorkspaceEmpty ? undefined : (
|
||||
<NewDashboardButton onClick={openCreate} />
|
||||
)
|
||||
}
|
||||
/>
|
||||
<DashboardsFilterZone
|
||||
query={query}
|
||||
creatorOptions={creatorOptions}
|
||||
source={source}
|
||||
disabled={!canList}
|
||||
onQueryChange={handleQueryChange}
|
||||
/>
|
||||
</ListHeaderZone>
|
||||
{isWorkspaceEmpty ? (
|
||||
<WorkspaceEmptyState onCreate={openCreate} />
|
||||
) : (
|
||||
<>
|
||||
<div className={styles.headerZone}>
|
||||
<ListCommandHeader
|
||||
label={activeLabel}
|
||||
count={total}
|
||||
isCountLoading={isFetching}
|
||||
isModified={isModified}
|
||||
action={<NewDashboardButton onClick={openCreate} />}
|
||||
/>
|
||||
<DashboardsFilterZone
|
||||
query={query}
|
||||
creatorOptions={creatorOptions}
|
||||
source={source}
|
||||
disabled={!canList}
|
||||
onQueryChange={handleQueryChange}
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.viewContent}>
|
||||
{/* Fails closed, unlike the guard's default: the fetch is
|
||||
<div className={styles.viewContent}>
|
||||
{/* Fails closed, unlike the guard's default: the fetch is
|
||||
already gated on the same check, so falling open would
|
||||
render the table shell with nothing in it and no reason
|
||||
given. */}
|
||||
<AuthZGuardContent checks={LIST_CHECKS} onFailRenderContent={false}>
|
||||
<DashboardsResults
|
||||
isLoading={isLoading}
|
||||
hasError={!!error}
|
||||
isCloudUser={!!isCloudUser}
|
||||
onRetry={(): void => {
|
||||
void refetch();
|
||||
}}
|
||||
errorHttpStatus={errorHttpStatus}
|
||||
errorMessage={errorMessage}
|
||||
dashboards={dashboards}
|
||||
activeViewId={activeViewId}
|
||||
searchValue={query}
|
||||
hasFilters={!filtersEmpty}
|
||||
sortColumn={sortColumn}
|
||||
onSortChange={onSortChange}
|
||||
sortOrder={sortOrder}
|
||||
onOrderChange={onOrderChange}
|
||||
page={page}
|
||||
pageSize={clientView ? CLIENT_VIEW_LIMIT : PAGE_SIZE}
|
||||
total={total}
|
||||
onPageChange={setPage}
|
||||
showUpdatedAt={visibleColumns.updatedAt}
|
||||
showUpdatedBy={visibleColumns.updatedBy}
|
||||
loading={isFetching}
|
||||
/>
|
||||
</AuthZGuardContent>
|
||||
</div>
|
||||
</>
|
||||
<AuthZGuardContent checks={LIST_CHECKS} onFailRenderContent={false}>
|
||||
<DashboardsResults
|
||||
isLoading={isLoading}
|
||||
hasError={!!error}
|
||||
isCloudUser={!!isCloudUser}
|
||||
onRetry={(): void => {
|
||||
void refetch();
|
||||
}}
|
||||
errorHttpStatus={errorHttpStatus}
|
||||
errorMessage={errorMessage}
|
||||
dashboards={dashboards}
|
||||
activeViewId={activeViewId}
|
||||
searchValue={query}
|
||||
hasFilters={!filtersEmpty}
|
||||
sortColumn={sortColumn}
|
||||
onSortChange={onSortChange}
|
||||
sortOrder={sortOrder}
|
||||
onOrderChange={onOrderChange}
|
||||
page={page}
|
||||
pageSize={clientView ? CLIENT_VIEW_LIMIT : PAGE_SIZE}
|
||||
total={total}
|
||||
onPageChange={setPage}
|
||||
showUpdatedAt={visibleColumns.updatedAt}
|
||||
showUpdatedBy={visibleColumns.updatedBy}
|
||||
loading={isFetching}
|
||||
/>
|
||||
</AuthZGuardContent>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<ListStatusBar
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { NuqsTestingAdapter } from 'nuqs/adapters/testing';
|
||||
import { render, screen } from 'tests/test-utils';
|
||||
import { setupAuthzAdmin } from 'lib/authz/utils/authz-test-utils';
|
||||
|
||||
import DashboardsList from '../DashboardsList';
|
||||
|
||||
const LIST_URL = 'http://localhost/api/v2/users/me/dashboards';
|
||||
const VIEWS_URL = 'http://localhost/api/v2/dashboard_views';
|
||||
|
||||
describe('DashboardsList - empty workspace', () => {
|
||||
afterEach(() => {
|
||||
server.resetHandlers();
|
||||
});
|
||||
|
||||
it('keeps the query bar above the empty state', async () => {
|
||||
server.use(
|
||||
setupAuthzAdmin(),
|
||||
rest.get(VIEWS_URL, (_req, res, ctx) =>
|
||||
res(ctx.status(200), ctx.json({ status: 'success', data: [] })),
|
||||
),
|
||||
rest.get(LIST_URL, (_req, res, ctx) =>
|
||||
res(
|
||||
ctx.status(200),
|
||||
ctx.json({
|
||||
status: 'success',
|
||||
data: { dashboards: [], total: 0, tags: [] },
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
render(
|
||||
<NuqsTestingAdapter searchParams={{}} hasMemory>
|
||||
<DashboardsList />
|
||||
</NuqsTestingAdapter>,
|
||||
);
|
||||
|
||||
await screen.findByTestId('learn-more');
|
||||
expect(screen.getByTestId('dashboards-list-search')).toBeInTheDocument();
|
||||
expect(screen.getAllByTestId('new-dashboard-cta')).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
MetricAggregation,
|
||||
TraceAggregation,
|
||||
} from 'types/api/v5/queryRange';
|
||||
import type { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
@@ -104,16 +105,19 @@ export function getAggregationOptionsForOrderBy(query: {
|
||||
* Enhanced function that uses createAggregation to parse aggregations first
|
||||
* then converts them to BaseAutocompleteData format for OrderByFilter
|
||||
*/
|
||||
export function getParsedAggregationOptionsForOrderBy(query: {
|
||||
aggregations?: TraceAggregation[] | LogAggregation[] | MetricAggregation[];
|
||||
dataSource: DataSource;
|
||||
aggregateAttribute?: { key: string };
|
||||
spaceAggregation?: string;
|
||||
timeAggregation?: string;
|
||||
temporality?: string;
|
||||
}): BaseAutocompleteData[] {
|
||||
export function getParsedAggregationOptionsForOrderBy(
|
||||
query: {
|
||||
aggregations?: TraceAggregation[] | LogAggregation[] | MetricAggregation[];
|
||||
dataSource: DataSource;
|
||||
aggregateAttribute?: { key: string };
|
||||
spaceAggregation?: string;
|
||||
timeAggregation?: string;
|
||||
temporality?: string;
|
||||
},
|
||||
panelType?: PANEL_TYPES,
|
||||
): BaseAutocompleteData[] {
|
||||
// First, use createAggregation to parse the aggregations
|
||||
const parsedAggregations = createAggregation(query);
|
||||
const parsedAggregations = createAggregation(query, panelType);
|
||||
|
||||
// Then convert the parsed aggregations to BaseAutocompleteData format
|
||||
return convertAggregationsToBaseAutocompleteData(
|
||||
|
||||
@@ -29,6 +29,7 @@ const QUERIES = {
|
||||
const ALL = ['group_by', 'having', 'order_by', 'limit', 'legend_format'];
|
||||
const NO_HAVING = ['group_by', 'order_by', 'limit', 'legend_format'];
|
||||
const METRICS = ['having', 'order_by', 'limit', 'legend_format'];
|
||||
const HEATMAP = [...NO_HAVING, 'bucket_options'];
|
||||
|
||||
/**
|
||||
* Add-on toggles each panel kind offers per signal. Metrics group by lives in
|
||||
@@ -44,7 +45,7 @@ const ADD_ONS: Record<
|
||||
[PanelKind.Table]: ALL,
|
||||
[PanelKind.PieChart]: ALL,
|
||||
[PanelKind.Number]: ['legend_format'],
|
||||
[PanelKind.Heatmap]: NO_HAVING,
|
||||
[PanelKind.Heatmap]: HEATMAP,
|
||||
},
|
||||
traces: {
|
||||
[PanelKind.TimeSeries]: ALL,
|
||||
@@ -52,7 +53,7 @@ const ADD_ONS: Record<
|
||||
[PanelKind.Table]: ALL,
|
||||
[PanelKind.PieChart]: ALL,
|
||||
[PanelKind.Number]: ['legend_format'],
|
||||
[PanelKind.Heatmap]: NO_HAVING,
|
||||
[PanelKind.Heatmap]: HEATMAP,
|
||||
},
|
||||
metrics: {
|
||||
[PanelKind.TimeSeries]: METRICS,
|
||||
|
||||
Reference in New Issue
Block a user