mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-01 04:11:59 +08:00
feat: added exception based alerts (#1752)
This commit is contained in:
parent
b0ec619881
commit
33d34af2a6
@ -102,9 +102,11 @@
|
|||||||
"user_tooltip_more_help": "More details on how to create alerts",
|
"user_tooltip_more_help": "More details on how to create alerts",
|
||||||
"choose_alert_type": "Choose a type for the alert:",
|
"choose_alert_type": "Choose a type for the alert:",
|
||||||
"metric_based_alert": "Metric based Alert",
|
"metric_based_alert": "Metric based Alert",
|
||||||
"metric_based_alert_desc": "Send a notification when a condition occurs in metric data",
|
"metric_based_alert_desc": "Send a notification when a condition occurs in the metric data",
|
||||||
"log_based_alert": "Log-based Alert",
|
"log_based_alert": "Log-based Alert",
|
||||||
"log_based_alert_desc": "Send a notification when a condition occurs in logs data.",
|
"log_based_alert_desc": "Send a notification when a condition occurs in the logs data.",
|
||||||
"traces_based_alert": "Trace-based Alert",
|
"traces_based_alert": "Trace-based Alert",
|
||||||
"traces_based_alert_desc": "Send a notification when a condition occurs in traces data."
|
"traces_based_alert_desc": "Send a notification when a condition occurs in the traces data.",
|
||||||
|
"exceptions_based_alert": "Exceptions-based Alert",
|
||||||
|
"exceptions_based_alert_desc": "Send a notification when a condition occurs in the exceptions data."
|
||||||
}
|
}
|
@ -102,9 +102,11 @@
|
|||||||
"user_tooltip_more_help": "More details on how to create alerts",
|
"user_tooltip_more_help": "More details on how to create alerts",
|
||||||
"choose_alert_type": "Choose a type for the alert:",
|
"choose_alert_type": "Choose a type for the alert:",
|
||||||
"metric_based_alert": "Metric based Alert",
|
"metric_based_alert": "Metric based Alert",
|
||||||
"metric_based_alert_desc": "Send a notification when a condition occurs in metric data",
|
"metric_based_alert_desc": "Send a notification when a condition occurs in the metric data",
|
||||||
"log_based_alert": "Log-based Alert",
|
"log_based_alert": "Log-based Alert",
|
||||||
"log_based_alert_desc": "Send a notification when a condition occurs in logs data.",
|
"log_based_alert_desc": "Send a notification when a condition occurs in the logs data.",
|
||||||
"traces_based_alert": "Trace-based Alert",
|
"traces_based_alert": "Trace-based Alert",
|
||||||
"traces_based_alert_desc": "Send a notification when a condition occurs in traces data."
|
"traces_based_alert_desc": "Send a notification when a condition occurs in the traces data.",
|
||||||
|
"exceptions_based_alert": "Exceptions-based Alert",
|
||||||
|
"exceptions_based_alert_desc": "Send a notification when a condition occurs in the exceptions data."
|
||||||
}
|
}
|
@ -1,8 +1,9 @@
|
|||||||
|
import { Row } from 'antd';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { AlertTypes } from 'types/api/alerts/alertTypes';
|
import { AlertTypes } from 'types/api/alerts/alertTypes';
|
||||||
|
|
||||||
import { AlertTypeCard, AlertTypeCards, SelectTypeContainer } from './styles';
|
import { AlertTypeCard, SelectTypeContainer } from './styles';
|
||||||
|
|
||||||
interface OptionType {
|
interface OptionType {
|
||||||
title: string;
|
title: string;
|
||||||
@ -30,6 +31,11 @@ function SelectAlertType({ onSelect }: SelectAlertTypeProps): JSX.Element {
|
|||||||
selection: AlertTypes.TRACES_BASED_ALERT,
|
selection: AlertTypes.TRACES_BASED_ALERT,
|
||||||
description: t('traces_based_alert_desc'),
|
description: t('traces_based_alert_desc'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: t('exceptions_based_alert'),
|
||||||
|
selection: AlertTypes.EXCEPTIONS_BASED_ALERT,
|
||||||
|
description: t('exceptions_based_alert_desc'),
|
||||||
|
},
|
||||||
];
|
];
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -50,7 +56,7 @@ function SelectAlertType({ onSelect }: SelectAlertTypeProps): JSX.Element {
|
|||||||
return (
|
return (
|
||||||
<SelectTypeContainer>
|
<SelectTypeContainer>
|
||||||
<h3> {t('choose_alert_type')} </h3>
|
<h3> {t('choose_alert_type')} </h3>
|
||||||
<AlertTypeCards>{renderOptions()}</AlertTypeCards>
|
<Row>{renderOptions()}</Row>
|
||||||
</SelectTypeContainer>
|
</SelectTypeContainer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Card, Row } from 'antd';
|
import { Card } from 'antd';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
export const SelectTypeContainer = styled.div`
|
export const SelectTypeContainer = styled.div`
|
||||||
@ -7,12 +7,6 @@ export const SelectTypeContainer = styled.div`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const AlertTypeCards = styled(Row)`
|
|
||||||
&&& {
|
|
||||||
flex-wrap: nowrap;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const AlertTypeCard = styled(Card)`
|
export const AlertTypeCard = styled(Card)`
|
||||||
&&& {
|
&&& {
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
|
@ -117,8 +117,8 @@ export const traceAlertDefaults: AlertDef = {
|
|||||||
chQueries: {
|
chQueries: {
|
||||||
A: {
|
A: {
|
||||||
name: 'A',
|
name: 'A',
|
||||||
rawQuery: `SELECT \n\tcount() as value,\n\ttoStartOfInterval(timestamp, toIntervalMinute(1)) AS interval,\n\tserviceName\nFROM signoz_traces.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`,
|
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.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\tcount() as value,\n\ttoStartOfInterval(timestamp, toIntervalMinute(1)) AS interval,\n\tserviceName\nFROM signoz_traces.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\ttoStartOfInterval(timestamp, INTERVAL 1 MINUTE) AS interval, \n\ttagMap['peer.service'] AS op_name, \n\ttoFloat64(avg(durationNano)) AS value \nFROM signoz_traces.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: '',
|
legend: '',
|
||||||
disabled: false,
|
disabled: false,
|
||||||
},
|
},
|
||||||
@ -137,3 +137,50 @@ export const traceAlertDefaults: AlertDef = {
|
|||||||
},
|
},
|
||||||
evalWindow: defaultEvalWindow,
|
evalWindow: defaultEvalWindow,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const exceptionAlertDefaults: AlertDef = {
|
||||||
|
alertType: AlertTypes.EXCEPTIONS_BASED_ALERT,
|
||||||
|
condition: {
|
||||||
|
compositeMetricQuery: {
|
||||||
|
builderQueries: {
|
||||||
|
A: {
|
||||||
|
queryName: 'A',
|
||||||
|
name: 'A',
|
||||||
|
formulaOnly: false,
|
||||||
|
metricName: '',
|
||||||
|
tagFilters: {
|
||||||
|
op: 'AND',
|
||||||
|
items: [],
|
||||||
|
},
|
||||||
|
groupBy: [],
|
||||||
|
aggregateOperator: 1,
|
||||||
|
expression: 'A',
|
||||||
|
disabled: false,
|
||||||
|
toggleDisable: false,
|
||||||
|
toggleDelete: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
promQueries: {},
|
||||||
|
chQueries: {
|
||||||
|
A: {
|
||||||
|
name: 'A',
|
||||||
|
rawQuery: `SELECT \n\tcount() as value,\n\ttoStartOfInterval(timestamp, toIntervalMinute(1)) AS interval,\n\tserviceName\nFROM signoz_traces.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.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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
queryType: 2,
|
||||||
|
},
|
||||||
|
op: defaultCompareOp,
|
||||||
|
matchType: '4',
|
||||||
|
},
|
||||||
|
labels: {
|
||||||
|
severity: 'warning',
|
||||||
|
details: `${window.location.protocol}//${window.location.host}/exceptions`,
|
||||||
|
},
|
||||||
|
annotations: {
|
||||||
|
description: 'A new exceptions-based alert',
|
||||||
|
},
|
||||||
|
evalWindow: defaultEvalWindow,
|
||||||
|
};
|
||||||
|
@ -5,6 +5,7 @@ import { AlertTypes } from 'types/api/alerts/alertTypes';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
alertDefaults,
|
alertDefaults,
|
||||||
|
exceptionAlertDefaults,
|
||||||
logAlertDefaults,
|
logAlertDefaults,
|
||||||
traceAlertDefaults,
|
traceAlertDefaults,
|
||||||
} from './defaults';
|
} from './defaults';
|
||||||
@ -27,6 +28,9 @@ function CreateRules(): JSX.Element {
|
|||||||
case AlertTypes.TRACES_BASED_ALERT:
|
case AlertTypes.TRACES_BASED_ALERT:
|
||||||
setInitValues(traceAlertDefaults);
|
setInitValues(traceAlertDefaults);
|
||||||
break;
|
break;
|
||||||
|
case AlertTypes.EXCEPTIONS_BASED_ALERT:
|
||||||
|
setInitValues(exceptionAlertDefaults);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
setInitValues(alertDefaults);
|
setInitValues(alertDefaults);
|
||||||
}
|
}
|
||||||
|
@ -292,6 +292,7 @@ function QuerySection({
|
|||||||
switch (typ) {
|
switch (typ) {
|
||||||
case AlertTypes.TRACES_BASED_ALERT:
|
case AlertTypes.TRACES_BASED_ALERT:
|
||||||
case AlertTypes.LOGS_BASED_ALERT:
|
case AlertTypes.LOGS_BASED_ALERT:
|
||||||
|
case AlertTypes.EXCEPTIONS_BASED_ALERT:
|
||||||
return (
|
return (
|
||||||
<Tabs
|
<Tabs
|
||||||
type="card"
|
type="card"
|
||||||
|
@ -108,7 +108,6 @@ export const prepareStagedQuery = (
|
|||||||
// convert map[string]IChQuery to IChQuery[]
|
// convert map[string]IChQuery to IChQuery[]
|
||||||
if (c) {
|
if (c) {
|
||||||
Object.keys(c).forEach((key) => {
|
Object.keys(c).forEach((key) => {
|
||||||
console.log('c:', c[key]);
|
|
||||||
chQueryList.push({ ...c[key], name: key, rawQuery: c[key].query });
|
chQueryList.push({ ...c[key], name: key, rawQuery: c[key].query });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -4,4 +4,5 @@ export enum AlertTypes {
|
|||||||
METRICS_BASED_ALERT = 'METRIC_BASED_ALERT',
|
METRICS_BASED_ALERT = 'METRIC_BASED_ALERT',
|
||||||
LOGS_BASED_ALERT = 'LOGS_BASED_ALERT',
|
LOGS_BASED_ALERT = 'LOGS_BASED_ALERT',
|
||||||
TRACES_BASED_ALERT = 'TRACES_BASED_ALERT',
|
TRACES_BASED_ALERT = 'TRACES_BASED_ALERT',
|
||||||
|
EXCEPTIONS_BASED_ALERT = 'EXCEPTIONS_BASED_ALERT',
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user