mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 12:28:59 +08:00
Merge branch 'develop' into release/v0.16.0
This commit is contained in:
commit
cf93712286
@ -6,6 +6,16 @@ import {
|
|||||||
defaultMatchType,
|
defaultMatchType,
|
||||||
} from 'types/api/alerts/def';
|
} from 'types/api/alerts/def';
|
||||||
|
|
||||||
|
const defaultAlertDescription =
|
||||||
|
'This alert is fired when the defined metric (current value: {{$value}}) crosses the threshold ({{$threshold}})';
|
||||||
|
const defaultAlertSummary =
|
||||||
|
'The rule threshold is set to {{$threshold}}, and the observed metric value is {{$value}}';
|
||||||
|
|
||||||
|
const defaultAnnotations = {
|
||||||
|
description: defaultAlertDescription,
|
||||||
|
summary: defaultAlertSummary,
|
||||||
|
};
|
||||||
|
|
||||||
export const alertDefaults: AlertDef = {
|
export const alertDefaults: AlertDef = {
|
||||||
alertType: AlertTypes.METRICS_BASED_ALERT,
|
alertType: AlertTypes.METRICS_BASED_ALERT,
|
||||||
condition: {
|
condition: {
|
||||||
@ -38,9 +48,7 @@ export const alertDefaults: AlertDef = {
|
|||||||
labels: {
|
labels: {
|
||||||
severity: 'warning',
|
severity: 'warning',
|
||||||
},
|
},
|
||||||
annotations: {
|
annotations: defaultAnnotations,
|
||||||
description: 'A new alert',
|
|
||||||
},
|
|
||||||
evalWindow: defaultEvalWindow,
|
evalWindow: defaultEvalWindow,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -85,9 +93,7 @@ export const logAlertDefaults: AlertDef = {
|
|||||||
severity: 'warning',
|
severity: 'warning',
|
||||||
details: `${window.location.protocol}//${window.location.host}/logs`,
|
details: `${window.location.protocol}//${window.location.host}/logs`,
|
||||||
},
|
},
|
||||||
annotations: {
|
annotations: defaultAnnotations,
|
||||||
description: 'A new log-based alert',
|
|
||||||
},
|
|
||||||
evalWindow: defaultEvalWindow,
|
evalWindow: defaultEvalWindow,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -132,9 +138,7 @@ export const traceAlertDefaults: AlertDef = {
|
|||||||
severity: 'warning',
|
severity: 'warning',
|
||||||
details: `${window.location.protocol}//${window.location.host}/traces`,
|
details: `${window.location.protocol}//${window.location.host}/traces`,
|
||||||
},
|
},
|
||||||
annotations: {
|
annotations: defaultAnnotations,
|
||||||
description: 'A new trace-based alert',
|
|
||||||
},
|
|
||||||
evalWindow: defaultEvalWindow,
|
evalWindow: defaultEvalWindow,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -179,8 +183,6 @@ export const exceptionAlertDefaults: AlertDef = {
|
|||||||
severity: 'warning',
|
severity: 'warning',
|
||||||
details: `${window.location.protocol}//${window.location.host}/exceptions`,
|
details: `${window.location.protocol}//${window.location.host}/exceptions`,
|
||||||
},
|
},
|
||||||
annotations: {
|
annotations: defaultAnnotations,
|
||||||
description: 'A new exceptions-based alert',
|
|
||||||
},
|
|
||||||
evalWindow: defaultEvalWindow,
|
evalWindow: defaultEvalWindow,
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { getMinMax } from 'container/TopNav/AutoRefresh/config';
|
import { getMinMax } from 'container/TopNav/AutoRefresh/config';
|
||||||
|
import useUrlQuery from 'hooks/useUrlQuery';
|
||||||
import history from 'lib/history';
|
import history from 'lib/history';
|
||||||
import { parseQuery, reverseParser } from 'lib/logql';
|
import { parseQuery, reverseParser } from 'lib/logql';
|
||||||
import { ILogQLParsedQueryItem } from 'lib/logql/types';
|
import { ILogQLParsedQueryItem } from 'lib/logql/types';
|
||||||
import isEqual from 'lodash-es/isEqual';
|
import isEqual from 'lodash-es/isEqual';
|
||||||
import { useCallback, useEffect } from 'react';
|
import { useCallback, useEffect, useMemo } from 'react';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import { Dispatch } from 'redux';
|
import { Dispatch } from 'redux';
|
||||||
import { AppState } from 'store/reducers';
|
import { AppState } from 'store/reducers';
|
||||||
@ -27,6 +28,10 @@ export function useSearchParser(): {
|
|||||||
const {
|
const {
|
||||||
searchFilter: { parsedQuery, queryString },
|
searchFilter: { parsedQuery, queryString },
|
||||||
} = useSelector<AppState, ILogsReducer>((store) => store.logs);
|
} = useSelector<AppState, ILogsReducer>((store) => store.logs);
|
||||||
|
|
||||||
|
const urlQuery = useUrlQuery();
|
||||||
|
const parsedFilters = useMemo(() => urlQuery.get('q'), [urlQuery]);
|
||||||
|
|
||||||
const { minTime, maxTime, selectedTime } = useSelector<
|
const { minTime, maxTime, selectedTime } = useSelector<
|
||||||
AppState,
|
AppState,
|
||||||
GlobalReducer
|
GlobalReducer
|
||||||
@ -63,8 +68,12 @@ export function useSearchParser(): {
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateQueryString(queryString);
|
if (!queryString && parsedFilters) {
|
||||||
}, [queryString, updateQueryString]);
|
updateQueryString(parsedFilters);
|
||||||
|
} else if (queryString) {
|
||||||
|
updateQueryString(queryString);
|
||||||
|
}
|
||||||
|
}, [queryString, updateQueryString, parsedFilters]);
|
||||||
|
|
||||||
const updateParsedQuery = useCallback(
|
const updateParsedQuery = useCallback(
|
||||||
(updatedParsedPayload: ILogQLParsedQueryItem[]) => {
|
(updatedParsedPayload: ILogQLParsedQueryItem[]) => {
|
||||||
|
@ -197,8 +197,8 @@ func testTemplateParsing(rl *PostableRule) (errs []error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Trying to parse templates.
|
// Trying to parse templates.
|
||||||
tmplData := AlertTemplateData(make(map[string]string), 0)
|
tmplData := AlertTemplateData(make(map[string]string), 0, 0)
|
||||||
defs := "{{$labels := .Labels}}{{$value := .Value}}"
|
defs := "{{$labels := .Labels}}{{$value := .Value}}{{$threshold := .Threshold}}"
|
||||||
parseTest := func(text string) error {
|
parseTest := func(text string) error {
|
||||||
tmpl := NewTemplateExpander(
|
tmpl := NewTemplateExpander(
|
||||||
context.TODO(),
|
context.TODO(),
|
||||||
|
@ -108,6 +108,14 @@ func (r *PromRule) Condition() *RuleCondition {
|
|||||||
return r.ruleCondition
|
return r.ruleCondition
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *PromRule) targetVal() float64 {
|
||||||
|
if r.ruleCondition == nil || r.ruleCondition.Target == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return *r.ruleCondition.Target
|
||||||
|
}
|
||||||
|
|
||||||
func (r *PromRule) Type() RuleType {
|
func (r *PromRule) Type() RuleType {
|
||||||
return RuleTypeProm
|
return RuleTypeProm
|
||||||
}
|
}
|
||||||
@ -327,10 +335,10 @@ func (r *PromRule) Eval(ctx context.Context, ts time.Time, queriers *Queriers) (
|
|||||||
l[lbl.Name] = lbl.Value
|
l[lbl.Name] = lbl.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
tmplData := AlertTemplateData(l, smpl.V)
|
tmplData := AlertTemplateData(l, smpl.V, r.targetVal())
|
||||||
// Inject some convenience variables that are easier to remember for users
|
// Inject some convenience variables that are easier to remember for users
|
||||||
// who are not used to Go's templating system.
|
// who are not used to Go's templating system.
|
||||||
defs := "{{$labels := .Labels}}{{$value := .Value}}"
|
defs := "{{$labels := .Labels}}{{$value := .Value}}{{$threshold := .Threshold}}"
|
||||||
|
|
||||||
expand := func(text string) string {
|
expand := func(text string) string {
|
||||||
|
|
||||||
|
@ -21,8 +21,9 @@ import (
|
|||||||
// related to go templating in rule labels and annotations
|
// related to go templating in rule labels and annotations
|
||||||
|
|
||||||
type tmplQueryRecord struct {
|
type tmplQueryRecord struct {
|
||||||
Labels map[string]string
|
Labels map[string]string
|
||||||
Value float64
|
Value float64
|
||||||
|
Threshold float64
|
||||||
}
|
}
|
||||||
type tmplQueryResults []*tmplQueryRecord
|
type tmplQueryResults []*tmplQueryRecord
|
||||||
|
|
||||||
@ -200,13 +201,15 @@ func NewTemplateExpander(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AlertTemplateData returns the interface to be used in expanding the template.
|
// AlertTemplateData returns the interface to be used in expanding the template.
|
||||||
func AlertTemplateData(labels map[string]string, value float64) interface{} {
|
func AlertTemplateData(labels map[string]string, value float64, threshold float64) interface{} {
|
||||||
return struct {
|
return struct {
|
||||||
Labels map[string]string
|
Labels map[string]string
|
||||||
Value float64
|
Value float64
|
||||||
|
Threshold float64
|
||||||
}{
|
}{
|
||||||
Labels: labels,
|
Labels: labels,
|
||||||
Value: value,
|
Value: value,
|
||||||
|
Threshold: threshold,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -673,10 +673,10 @@ func (r *ThresholdRule) Eval(ctx context.Context, ts time.Time, queriers *Querie
|
|||||||
l[lbl.Name] = lbl.Value
|
l[lbl.Name] = lbl.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
tmplData := AlertTemplateData(l, smpl.V)
|
tmplData := AlertTemplateData(l, smpl.V, r.targetVal())
|
||||||
// Inject some convenience variables that are easier to remember for users
|
// Inject some convenience variables that are easier to remember for users
|
||||||
// who are not used to Go's templating system.
|
// who are not used to Go's templating system.
|
||||||
defs := "{{$labels := .Labels}}{{$value := .Value}}"
|
defs := "{{$labels := .Labels}}{{$value := .Value}}{{$threshold := .Threshold}}"
|
||||||
|
|
||||||
// utility function to apply go template on labels and annots
|
// utility function to apply go template on labels and annots
|
||||||
expand := func(text string) string {
|
expand := func(text string) string {
|
||||||
|
@ -11,3 +11,18 @@ func IgnoredPaths() map[string]struct{} {
|
|||||||
|
|
||||||
return ignoredPaths
|
return ignoredPaths
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ignoreEvents(event string, attributes map[string]interface{}) bool {
|
||||||
|
|
||||||
|
if event == TELEMETRY_EVENT_ACTIVE_USER || event == TELEMETRY_EVENT_ACTIVE_USER_PH {
|
||||||
|
for attr_key, attr_val := range attributes {
|
||||||
|
|
||||||
|
if attr_key == "any" && attr_val.(int8) == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
@ -46,13 +46,14 @@ const IP_NOT_FOUND_PLACEHOLDER = "NA"
|
|||||||
const DEFAULT_NUMBER_OF_SERVICES = 6
|
const DEFAULT_NUMBER_OF_SERVICES = 6
|
||||||
|
|
||||||
const HEART_BEAT_DURATION = 6 * time.Hour
|
const HEART_BEAT_DURATION = 6 * time.Hour
|
||||||
|
|
||||||
const ACTIVE_USER_DURATION = 30 * time.Minute
|
const ACTIVE_USER_DURATION = 30 * time.Minute
|
||||||
|
|
||||||
// const HEART_BEAT_DURATION = 30 * time.Second
|
// const HEART_BEAT_DURATION = 30 * time.Second
|
||||||
// const ACTIVE_USER_DURATION = 30 * time.Second
|
// const ACTIVE_USER_DURATION = 30 * time.Second
|
||||||
|
|
||||||
const RATE_LIMIT_CHECK_DURATION = 1 * time.Minute
|
const RATE_LIMIT_CHECK_DURATION = 1 * time.Minute
|
||||||
const RATE_LIMIT_VALUE = 2
|
const RATE_LIMIT_VALUE = 1
|
||||||
|
|
||||||
// const RATE_LIMIT_CHECK_DURATION = 20 * time.Second
|
// const RATE_LIMIT_CHECK_DURATION = 20 * time.Second
|
||||||
// const RATE_LIMIT_VALUE = 5
|
// const RATE_LIMIT_VALUE = 5
|
||||||
@ -301,6 +302,11 @@ func (a *Telemetry) SendEvent(event string, data map[string]interface{}, opts ..
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// drop events with properties matching
|
||||||
|
if ignoreEvents(event, data) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if rateLimitFlag {
|
if rateLimitFlag {
|
||||||
if a.rateLimits[event] < RATE_LIMIT_VALUE {
|
if a.rateLimits[event] < RATE_LIMIT_VALUE {
|
||||||
a.rateLimits[event] += 1
|
a.rateLimits[event] += 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user