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
chore: add additional info for host metrics onboarding (#6529)
Srikanth Chekuri2e4956c2f7ef
diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.goindex 1a0acde1b1..f63b4d3453 100644--- a/pkg/query-service/app/clickhouseReader/reader.go+++ b/pkg/query-service/app/clickhouseReader/reader.go@@ -3384,6 +3384,17 @@ func (r *ClickHouseReader) GetMetricMetadata(ctx context.Context, metricName, se}, nil}+// GetCountOfThings returns the count of things in the query+// This is a generic function that can be used to check if any data exists for a given query+func (r *ClickHouseReader) GetCountOfThings(ctx context.Context, query string) (uint64, error) {+ var count uint64+ err := r.db.QueryRow(ctx, query).Scan(&count)+ if err != nil {+ return 0, err+ }+ return count, nil+}+func (r *ClickHouseReader) GetLatestReceivedMetric(ctx context.Context, metricNames []string,) (*model.MetricStatus, *model.ApiError) {diff --git a/pkg/query-service/app/inframetrics/hosts.go b/pkg/query-service/app/inframetrics/hosts.goindex 8153c382c9..81e279140f 100644--- a/pkg/query-service/app/inframetrics/hosts.go+++ b/pkg/query-service/app/inframetrics/hosts.go@@ -2,6 +2,7 @@ package inframetricsimport ("context"+ "fmt""math""sort""strings"@@ -9,6 +10,7 @@ import ("go.signoz.io/signoz/pkg/query-service/app/metrics/v4/helpers""go.signoz.io/signoz/pkg/query-service/common"+ "go.signoz.io/signoz/pkg/query-service/constants""go.signoz.io/signoz/pkg/query-service/interfaces""go.signoz.io/signoz/pkg/query-service/model"v3 "go.signoz.io/signoz/pkg/query-service/model/v3"@@ -310,6 +312,45 @@ func (h *HostsRepo) getTopHostGroups(ctx context.Context, req model.HostListRequreturn topHostGroups, allHostGroups, nil}+func (h *HostsRepo) DidSendHostMetricsData(ctx context.Context, req model.HostListRequest) (bool, error) {++ names := []string{}+ for _, metricName := range metricNamesForHosts {+ names = append(names, metricName)+ }++ namesStr := "'" + strings.Join(names, "','") + "'"++ query := fmt.Sprintf("SELECT count() FROM %s.%s WHERE metric_name IN (%s)",+ constants.SIGNOZ_METRIC_DBNAME, constants.SIGNOZ_TIMESERIES_v4_1DAY_TABLENAME, namesStr)++ count, err := h.reader.GetCountOfThings(ctx, query)+ if err != nil {+ return false, err+ }++ return count > 0, nil+}++func (h *HostsRepo) IsSendingK8SAgentMetrics(ctx context.Context, req model.HostListRequest) (bool, error) {+ names := []string{}+ for _, metricName := range metricNamesForHosts {+ names = append(names, metricName)+ }+ namesStr := "'" + strings.Join(names, "','") + "'"++ query := fmt.Sprintf(`+ SELECT count()+ FROM %s.%s+ WHERE metric_name IN (%s)+ AND unix_milli >= toUnixTimestamp(now() - INTERVAL 60 MINUTE) * 1000+ AND JSONExtractString(labels, 'host_name') LIKE '%%-otel-agent%%'`,+ constants.SIGNOZ_METRIC_DBNAME, constants.SIGNOZ_TIMESERIES_V4_TABLENAME, namesStr)++ count, err := h.reader.GetCountOfThings(ctx, query)+ return count > 0, err+}+func (h *HostsRepo) GetHostList(ctx context.Context, req model.HostListRequest) (model.HostListResponse, error) {resp := model.HostListResponse{}@@ -330,6 +371,14 @@ func (h *HostsRepo) GetHostList(ctx context.Context, req model.HostListRequest)resp.Type = model.ResponseTypeGroupedList}+ // don't fail the request if we can't get these values+ if sendingK8SAgentMetrics, err := h.IsSendingK8SAgentMetrics(ctx, req); err == nil {+ resp.IsSendingK8SAgentMetrics = sendingK8SAgentMetrics+ }+ if sentAnyHostMetricsData, err := h.DidSendHostMetricsData(ctx, req); err == nil {+ resp.SentAnyHostMetricsData = sentAnyHostMetricsData+ }+step := int64(math.Max(float64(common.MinAllowedStepInterval(req.Start, req.End)), 60))query := HostsTableListQuery.Clone()diff --git a/pkg/query-service/constants/constants.go b/pkg/query-service/constants/constants.goindex 1ae3c1ed0b..7d6f087188 100644--- a/pkg/query-service/constants/constants.go+++ b/pkg/query-service/constants/constants.go@@ -243,6 +243,7 @@ const (SIGNOZ_SPAN_INDEX_LOCAL_TABLENAME = "signoz_index_v2"SIGNOZ_SPAN_INDEX_V3_LOCAL_TABLENAME = "signoz_index_v3"SIGNOZ_TIMESERIES_v4_LOCAL_TABLENAME = "time_series_v4"+ SIGNOZ_TIMESERIES_V4_TABLENAME = "distributed_time_series_v4"SIGNOZ_TIMESERIES_v4_6HRS_LOCAL_TABLENAME = "time_series_v4_6hrs"SIGNOZ_TIMESERIES_v4_1DAY_LOCAL_TABLENAME = "time_series_v4_1day"SIGNOZ_TIMESERIES_v4_1WEEK_LOCAL_TABLENAME = "time_series_v4_1week"diff --git a/pkg/query-service/interfaces/interface.go b/pkg/query-service/interfaces/interface.goindex 1cf32ede02..a2acd8c6c9 100644--- a/pkg/query-service/interfaces/interface.go+++ b/pkg/query-service/interfaces/interface.go@@ -107,6 +107,8 @@ type Reader interface {// Query Progress tracking helpers.ReportQueryStartForProgressTracking(queryId string) (reportQueryFinished func(), err *model.ApiError)SubscribeToQueryProgress(queryId string) (<-chan model.QueryProgress, func(), *model.ApiError)++ GetCountOfThings(ctx context.Context, query string) (uint64, error)}type Querier interface {diff --git a/pkg/query-service/model/infra.go b/pkg/query-service/model/infra.goindex 3c7dbc39e0..4904ea2399 100644--- a/pkg/query-service/model/infra.go+++ b/pkg/query-service/model/infra.go@@ -37,9 +37,11 @@ type HostListRecord struct {}type HostListResponse struct {- Type ResponseType `json:"type"`- Records []HostListRecord `json:"records"`- Total int `json:"total"`+ Type ResponseType `json:"type"`+ Records []HostListRecord `json:"records"`+ Total int `json:"total"`+ SentAnyHostMetricsData bool `json:"sentAnyHostMetricsData"`+ IsSendingK8SAgentMetrics bool `json:"isSendingK8SAgentMetrics"`}func (r *HostListResponse) SortBy(orderBy *v3.OrderBy) {