SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix: use the correct formatter for the description (#5388)
Srikanth Chekuri326dec21fdbd
diff --git a/pkg/query-service/model/v3/v3.go b/pkg/query-service/model/v3/v3.goindex 7b9fd8d989..7facd2ff50 100644--- a/pkg/query-service/model/v3/v3.go+++ b/pkg/query-service/model/v3/v3.go@@ -401,8 +401,11 @@ type CompositeQuery struct {PromQueries map[string]*PromQuery `json:"promQueries,omitempty"`PanelType PanelType `json:"panelType"`QueryType QueryType `json:"queryType"`- Unit string `json:"unit,omitempty"`- FillGaps bool `json:"fillGaps,omitempty"`+ // Unit for the time series data shown in the graph+ // This is used in alerts to format the value and threshold+ Unit string `json:"unit,omitempty"`+ // FillGaps is used to fill the gaps in the time series data+ FillGaps bool `json:"fillGaps,omitempty"`}func (c *CompositeQuery) EnabledQueries() int {diff --git a/pkg/query-service/rules/promRule.go b/pkg/query-service/rules/promRule.goindex a998de243e..fd00363abf 100644--- a/pkg/query-service/rules/promRule.go+++ b/pkg/query-service/rules/promRule.go@@ -111,13 +111,22 @@ func (r *PromRule) Condition() *RuleCondition {return r.ruleCondition}+// targetVal returns the target value for the rule condition+// when the y-axis and target units are non-empty, it+// converts the target value to the y-axis unitfunc (r *PromRule) targetVal() float64 {if r.ruleCondition == nil || r.ruleCondition.Target == nil {return 0}+ // get the converter for the target unitunitConverter := converter.FromUnit(converter.Unit(r.ruleCondition.TargetUnit))- value := unitConverter.Convert(converter.Value{F: *r.ruleCondition.Target, U: converter.Unit(r.ruleCondition.TargetUnit)}, converter.Unit(r.Unit()))+ // convert the target value to the y-axis unit+ value := unitConverter.Convert(converter.Value{+ F: *r.ruleCondition.Target,+ U: converter.Unit(r.ruleCondition.TargetUnit),+ }, converter.Unit(r.Unit()))+return value.F}@@ -370,8 +379,7 @@ func (r *PromRule) Eval(ctx context.Context, ts time.Time, queriers *Queriers) (}zap.L().Debug("alerting for series", zap.String("name", r.Name()), zap.Any("series", series))- thresholdFormatter := formatter.FromUnit(r.ruleCondition.TargetUnit)- threshold := thresholdFormatter.Format(r.targetVal(), r.ruleCondition.TargetUnit)+ threshold := valueFormatter.Format(r.targetVal(), r.Unit())tmplData := AlertTemplateData(l, valueFormatter.Format(alertSmpl.F, r.Unit()), threshold)// Inject some convenience variables that are easier to remember for usersdiff --git a/pkg/query-service/rules/thresholdRule.go b/pkg/query-service/rules/thresholdRule.goindex 051476e6b8..e642fb3a0a 100644--- a/pkg/query-service/rules/thresholdRule.go+++ b/pkg/query-service/rules/thresholdRule.go@@ -165,13 +165,22 @@ func (r *ThresholdRule) PreferredChannels() []string {return r.preferredChannels}+// targetVal returns the target value for the rule condition+// when the y-axis and target units are non-empty, it+// converts the target value to the y-axis unitfunc (r *ThresholdRule) targetVal() float64 {if r.ruleCondition == nil || r.ruleCondition.Target == nil {return 0}+ // get the converter for the target unitunitConverter := converter.FromUnit(converter.Unit(r.ruleCondition.TargetUnit))- value := unitConverter.Convert(converter.Value{F: *r.ruleCondition.Target, U: converter.Unit(r.ruleCondition.TargetUnit)}, converter.Unit(r.Unit()))+ // convert the target value to the y-axis unit+ value := unitConverter.Convert(converter.Value{+ F: *r.ruleCondition.Target,+ U: converter.Unit(r.ruleCondition.TargetUnit),+ }, converter.Unit(r.Unit()))+return value.F}@@ -874,8 +883,7 @@ func (r *ThresholdRule) Eval(ctx context.Context, ts time.Time, queriers *Querie}value := valueFormatter.Format(smpl.V, r.Unit())- thresholdFormatter := formatter.FromUnit(r.ruleCondition.TargetUnit)- threshold := thresholdFormatter.Format(r.targetVal(), r.ruleCondition.TargetUnit)+ threshold := valueFormatter.Format(r.targetVal(), r.Unit())zap.L().Debug("Alert template data for rule", zap.String("name", r.Name()), zap.String("formatter", valueFormatter.Name()), zap.String("value", value), zap.String("threshold", threshold))tmplData := AlertTemplateData(l, value, threshold)