mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 03:29:02 +08:00
chore(telemetry): add telemetry for metrics query type and count prom… (#5627)
This commit is contained in:
parent
fff61379fe
commit
16dc90bbd1
@ -634,16 +634,20 @@ type TagsInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AlertsInfo struct {
|
type AlertsInfo struct {
|
||||||
TotalAlerts int `json:"totalAlerts"`
|
TotalAlerts int `json:"totalAlerts"`
|
||||||
LogsBasedAlerts int `json:"logsBasedAlerts"`
|
LogsBasedAlerts int `json:"logsBasedAlerts"`
|
||||||
MetricBasedAlerts int `json:"metricBasedAlerts"`
|
MetricBasedAlerts int `json:"metricBasedAlerts"`
|
||||||
TracesBasedAlerts int `json:"tracesBasedAlerts"`
|
TracesBasedAlerts int `json:"tracesBasedAlerts"`
|
||||||
SlackChannels int `json:"slackChannels"`
|
SlackChannels int `json:"slackChannels"`
|
||||||
WebHookChannels int `json:"webHookChannels"`
|
WebHookChannels int `json:"webHookChannels"`
|
||||||
PagerDutyChannels int `json:"pagerDutyChannels"`
|
PagerDutyChannels int `json:"pagerDutyChannels"`
|
||||||
OpsGenieChannels int `json:"opsGenieChannels"`
|
OpsGenieChannels int `json:"opsGenieChannels"`
|
||||||
EmailChannels int `json:"emailChannels"`
|
EmailChannels int `json:"emailChannels"`
|
||||||
MSTeamsChannels int `json:"microsoftTeamsChannels"`
|
MSTeamsChannels int `json:"microsoftTeamsChannels"`
|
||||||
|
MetricsBuilderQueries int `json:"metricsBuilderQueries"`
|
||||||
|
MetricsClickHouseQueries int `json:"metricsClickHouseQueries"`
|
||||||
|
MetricsPrometheusQueries int `json:"metricsPrometheusQueries"`
|
||||||
|
SpanMetricsPrometheusQueries int `json:"spanMetricsPrometheusQueries"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SavedViewsInfo struct {
|
type SavedViewsInfo struct {
|
||||||
|
@ -5,12 +5,14 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
"go.signoz.io/signoz/pkg/query-service/auth"
|
"go.signoz.io/signoz/pkg/query-service/auth"
|
||||||
"go.signoz.io/signoz/pkg/query-service/common"
|
"go.signoz.io/signoz/pkg/query-service/common"
|
||||||
"go.signoz.io/signoz/pkg/query-service/model"
|
"go.signoz.io/signoz/pkg/query-service/model"
|
||||||
|
v3 "go.signoz.io/signoz/pkg/query-service/model/v3"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -322,6 +324,20 @@ func (r *ruleDB) GetAlertsInfo(ctx context.Context) (*model.AlertsInfo, error) {
|
|||||||
alertsInfo.LogsBasedAlerts = alertsInfo.LogsBasedAlerts + 1
|
alertsInfo.LogsBasedAlerts = alertsInfo.LogsBasedAlerts + 1
|
||||||
} else if rule.AlertType == "METRIC_BASED_ALERT" {
|
} else if rule.AlertType == "METRIC_BASED_ALERT" {
|
||||||
alertsInfo.MetricBasedAlerts = alertsInfo.MetricBasedAlerts + 1
|
alertsInfo.MetricBasedAlerts = alertsInfo.MetricBasedAlerts + 1
|
||||||
|
if rule.RuleCondition != nil && rule.RuleCondition.CompositeQuery != nil {
|
||||||
|
if rule.RuleCondition.CompositeQuery.QueryType == v3.QueryTypeBuilder {
|
||||||
|
alertsInfo.MetricsBuilderQueries = alertsInfo.MetricsBuilderQueries + 1
|
||||||
|
} else if rule.RuleCondition.CompositeQuery.QueryType == v3.QueryTypeClickHouseSQL {
|
||||||
|
alertsInfo.MetricsClickHouseQueries = alertsInfo.MetricsClickHouseQueries + 1
|
||||||
|
} else if rule.RuleCondition.CompositeQuery.QueryType == v3.QueryTypePromQL {
|
||||||
|
alertsInfo.MetricsPrometheusQueries = alertsInfo.MetricsPrometheusQueries + 1
|
||||||
|
for _, query := range rule.RuleCondition.CompositeQuery.PromQueries {
|
||||||
|
if strings.Contains(query.Query, "signoz_") {
|
||||||
|
alertsInfo.SpanMetricsPrometheusQueries = alertsInfo.SpanMetricsPrometheusQueries + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if rule.AlertType == "TRACES_BASED_ALERT" {
|
} else if rule.AlertType == "TRACES_BASED_ALERT" {
|
||||||
alertsInfo.TracesBasedAlerts = alertsInfo.TracesBasedAlerts + 1
|
alertsInfo.TracesBasedAlerts = alertsInfo.TracesBasedAlerts + 1
|
||||||
}
|
}
|
||||||
|
@ -331,6 +331,10 @@ func createTelemetry() {
|
|||||||
"opsGenieChannels": alertsInfo.OpsGenieChannels,
|
"opsGenieChannels": alertsInfo.OpsGenieChannels,
|
||||||
"emailChannels": alertsInfo.EmailChannels,
|
"emailChannels": alertsInfo.EmailChannels,
|
||||||
"msteamsChannels": alertsInfo.MSTeamsChannels,
|
"msteamsChannels": alertsInfo.MSTeamsChannels,
|
||||||
|
"metricsBuilderQueries": alertsInfo.MetricsBuilderQueries,
|
||||||
|
"metricsClickHouseQueries": alertsInfo.MetricsClickHouseQueries,
|
||||||
|
"metricsPrometheusQueries": alertsInfo.MetricsPrometheusQueries,
|
||||||
|
"spanMetricsPrometheusQueries": alertsInfo.SpanMetricsPrometheusQueries,
|
||||||
}
|
}
|
||||||
// send event only if there are dashboards or alerts or channels
|
// send event only if there are dashboards or alerts or channels
|
||||||
if (dashboardsInfo.TotalDashboards > 0 || alertsInfo.TotalAlerts > 0 || len(*channels) > 0 || savedViewsInfo.TotalSavedViews > 0) && apiErr == nil {
|
if (dashboardsInfo.TotalDashboards > 0 || alertsInfo.TotalAlerts > 0 || len(*channels) > 0 || savedViewsInfo.TotalSavedViews > 0) && apiErr == nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user