mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 17:19:00 +08:00
fix: raw query is updated to query (#2881)
This commit is contained in:
parent
5af5cb0cf0
commit
f3e077ce52
@ -146,7 +146,6 @@ export const initialQueryPromQLData: IPromQLQuery = {
|
||||
|
||||
export const initialClickHouseData: IClickHouseQuery = {
|
||||
name: createNewBuilderItemName({ existNames: [], sourceNames: alphabet }),
|
||||
rawQuery: '',
|
||||
legend: '',
|
||||
disabled: false,
|
||||
query: '',
|
||||
|
@ -39,7 +39,6 @@ export const alertDefaults: AlertDef = {
|
||||
A: {
|
||||
name: 'A',
|
||||
query: ``,
|
||||
rawQuery: ``,
|
||||
legend: '',
|
||||
disabled: false,
|
||||
},
|
||||
@ -73,7 +72,6 @@ export const logAlertDefaults: AlertDef = {
|
||||
A: {
|
||||
name: 'A',
|
||||
query: `select \ntoStartOfInterval(fromUnixTimestamp64Nano(timestamp), INTERVAL 30 MINUTE) AS interval, \ntoFloat64(count()) as value \nFROM signoz_logs.distributed_logs \nWHERE timestamp BETWEEN {{.start_timestamp_nano}} AND {{.end_timestamp_nano}} \nGROUP BY interval;\n\n-- available variables:\n-- \t{{.start_timestamp_nano}}\n-- \t{{.end_timestamp_nano}}\n\n-- required columns (or alias):\n-- \tvalue\n-- \tinterval`,
|
||||
rawQuery: `select \ntoStartOfInterval(fromUnixTimestamp64Nano(timestamp), INTERVAL 30 MINUTE) AS interval, \ntoFloat64(count()) as value \nFROM signoz_logs.distributed_logs \nWHERE timestamp BETWEEN {{.start_timestamp_nano}} AND {{.end_timestamp_nano}} \nGROUP BY interval;\n\n-- available variables:\n-- \t{{.start_timestamp_nano}}\n-- \t{{.end_timestamp_nano}}\n\n-- required columns (or alias):\n-- \tvalue\n-- \tinterval`,
|
||||
legend: '',
|
||||
disabled: false,
|
||||
},
|
||||
@ -107,7 +105,6 @@ export const traceAlertDefaults: AlertDef = {
|
||||
chQueries: {
|
||||
A: {
|
||||
name: 'A',
|
||||
rawQuery: `SELECT \n\ttoStartOfInterval(timestamp, INTERVAL 1 MINUTE) AS interval, \n\ttagMap['peer.service'] AS op_name, \n\ttoFloat64(avg(durationNano)) AS value \nFROM signoz_traces.distributed_signoz_index_v2 \nWHERE tagMap['peer.service']!='' \nAND timestamp BETWEEN {{.start_datetime}} AND {{.end_datetime}} \nGROUP BY (op_name, interval);\n\n-- available variables:\n-- \t{{.start_datetime}}\n-- \t{{.end_datetime}}\n\n-- required column alias:\n-- \tvalue\n-- \tinterval`,
|
||||
query: `SELECT \n\ttoStartOfInterval(timestamp, INTERVAL 1 MINUTE) AS interval, \n\ttagMap['peer.service'] AS op_name, \n\ttoFloat64(avg(durationNano)) AS value \nFROM signoz_traces.distributed_signoz_index_v2 \nWHERE tagMap['peer.service']!='' \nAND timestamp BETWEEN {{.start_datetime}} AND {{.end_datetime}} \nGROUP BY (op_name, interval);\n\n-- available variables:\n-- \t{{.start_datetime}}\n-- \t{{.end_datetime}}\n\n-- required column alias:\n-- \tvalue\n-- \tinterval`,
|
||||
legend: '',
|
||||
disabled: false,
|
||||
@ -142,7 +139,6 @@ export const exceptionAlertDefaults: AlertDef = {
|
||||
chQueries: {
|
||||
A: {
|
||||
name: 'A',
|
||||
rawQuery: `SELECT \n\tcount() as value,\n\ttoStartOfInterval(timestamp, toIntervalMinute(1)) AS interval,\n\tserviceName\nFROM signoz_traces.distributed_signoz_error_index_v2\nWHERE exceptionType !='OSError'\nAND timestamp BETWEEN {{.start_datetime}} AND {{.end_datetime}}\nGROUP BY serviceName, interval;\n\n-- available variables:\n-- \t{{.start_datetime}}\n-- \t{{.end_datetime}}\n\n-- required column alias:\n-- \tvalue\n-- \tinterval`,
|
||||
query: `SELECT \n\tcount() as value,\n\ttoStartOfInterval(timestamp, toIntervalMinute(1)) AS interval,\n\tserviceName\nFROM signoz_traces.distributed_signoz_error_index_v2\nWHERE exceptionType !='OSError'\nAND timestamp BETWEEN {{.start_datetime}} AND {{.end_datetime}}\nGROUP BY serviceName, interval;\n\n-- available variables:\n-- \t{{.start_datetime}}\n-- \t{{.end_datetime}}\n\n-- required column alias:\n-- \tvalue\n-- \tinterval`,
|
||||
legend: '',
|
||||
disabled: false,
|
||||
|
@ -60,7 +60,7 @@ function ChartPreview({
|
||||
case EQueryType.CLICKHOUSE:
|
||||
return (
|
||||
query.clickhouse_sql?.length > 0 &&
|
||||
query.clickhouse_sql[0].rawQuery?.length > 0
|
||||
query.clickhouse_sql[0].query?.length > 0
|
||||
);
|
||||
case EQueryType.QUERY_BUILDER:
|
||||
return (
|
||||
|
@ -162,7 +162,7 @@ function FormAlertRules({
|
||||
}
|
||||
|
||||
currentQuery.clickhouse_sql.forEach((item) => {
|
||||
if (item.rawQuery === '') {
|
||||
if (item.query === '') {
|
||||
notifications.error({
|
||||
message: 'Error',
|
||||
description: t('chquery_required'),
|
||||
|
@ -50,7 +50,7 @@ function ClickHouseQueryBuilder({
|
||||
|
||||
const handleUpdateEditor = useCallback(
|
||||
(value: string) => {
|
||||
handleUpdateQuery('rawQuery', value);
|
||||
handleUpdateQuery('query', value);
|
||||
},
|
||||
[handleUpdateQuery],
|
||||
);
|
||||
@ -75,7 +75,7 @@ function ClickHouseQueryBuilder({
|
||||
language="sql"
|
||||
height="200px"
|
||||
onChange={handleUpdateEditor}
|
||||
value={queryData.rawQuery}
|
||||
value={queryData.query}
|
||||
options={{
|
||||
scrollbar: {
|
||||
alwaysConsumeMouseWheel: false,
|
||||
|
@ -2,7 +2,7 @@ import { IClickHouseQuery } from 'types/api/queryBuilder/queryBuilderData';
|
||||
|
||||
export interface IClickHouseQueryHandleChange {
|
||||
queryIndex: number | string;
|
||||
rawQuery?: IClickHouseQuery['rawQuery'];
|
||||
query?: IClickHouseQuery['query'];
|
||||
legend?: IClickHouseQuery['legend'];
|
||||
toggleDisable?: IClickHouseQuery['disabled'];
|
||||
toggleDelete?: boolean;
|
||||
|
@ -22,7 +22,7 @@ export const mapQueryDataFromApi = (
|
||||
? Object.keys(compositeQuery.chQueries).map((key) => ({
|
||||
...compositeQuery.chQueries[key],
|
||||
name: key,
|
||||
rawQuery: compositeQuery.chQueries[key].query,
|
||||
query: compositeQuery.chQueries[key].query,
|
||||
}))
|
||||
: initialQuery.clickhouse_sql;
|
||||
|
||||
|
@ -55,9 +55,9 @@ export async function GetMetricQueryRange({
|
||||
case EQueryType.CLICKHOUSE: {
|
||||
const chQueries = {};
|
||||
queryData.map((query) => {
|
||||
if (!query.rawQuery) return;
|
||||
if (!query.query) return;
|
||||
chQueries[query.name] = {
|
||||
query: query.rawQuery,
|
||||
query: query.query,
|
||||
disabled: query.disabled,
|
||||
};
|
||||
legendMap[query.name] = query.legend;
|
||||
|
@ -63,7 +63,6 @@ export type IBuilderQuery = {
|
||||
|
||||
export interface IClickHouseQuery {
|
||||
name: string;
|
||||
rawQuery: string;
|
||||
legend: string;
|
||||
disabled: boolean;
|
||||
query: string;
|
||||
|
Loading…
x
Reference in New Issue
Block a user