diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.go index bc3df72bf1..afd7f93974 100644 --- a/pkg/query-service/app/clickhouseReader/reader.go +++ b/pkg/query-service/app/clickhouseReader/reader.go @@ -2955,6 +2955,16 @@ func (r *ClickHouseReader) GetSamplesInfoInLastHeartBeatInterval(ctx context.Con return totalSamples, nil } +func (r *ClickHouseReader) GetLogsInfoInLastHeartBeatInterval(ctx context.Context) (uint64, error) { + + var totalLogLines uint64 + + queryStr := fmt.Sprintf("select count() from %s.%s where timestamp > toUnixTimestamp(now()-toIntervalMinute(%d))*1000000000;", r.logsDB, r.logsTable, 30) + + r.db.QueryRow(ctx, queryStr).Scan(&totalLogLines) + + return totalLogLines, nil +} func (r *ClickHouseReader) GetLogFields(ctx context.Context) (*model.GetFieldsResponse, *model.ApiError) { // response will contain top level fields from the otel log model diff --git a/pkg/query-service/interfaces/interface.go b/pkg/query-service/interfaces/interface.go index a2dae6df01..5367021500 100644 --- a/pkg/query-service/interfaces/interface.go +++ b/pkg/query-service/interfaces/interface.go @@ -59,6 +59,7 @@ type Reader interface { GetSpansInLastHeartBeatInterval(ctx context.Context) (uint64, error) GetTimeSeriesInfo(ctx context.Context) (map[string]interface{}, error) GetSamplesInfoInLastHeartBeatInterval(ctx context.Context) (uint64, error) + GetLogsInfoInLastHeartBeatInterval(ctx context.Context) (uint64, error) // Logs GetLogFields(ctx context.Context) (*model.GetFieldsResponse, *model.ApiError) diff --git a/pkg/query-service/telemetry/telemetry.go b/pkg/query-service/telemetry/telemetry.go index ca402e4da8..43d27484e5 100644 --- a/pkg/query-service/telemetry/telemetry.go +++ b/pkg/query-service/telemetry/telemetry.go @@ -63,10 +63,13 @@ func createTelemetry() { getSamplesInfoInLastHeartBeatInterval, _ := telemetry.reader.GetSamplesInfoInLastHeartBeatInterval(context.Background()) tsInfo, _ := telemetry.reader.GetTimeSeriesInfo(context.Background()) + getLogsInfoInLastHeartBeatInterval, _ := telemetry.reader.GetLogsInfoInLastHeartBeatInterval(context.Background()) + data := map[string]interface{}{ "totalSpans": totalSpans, "spansInLastHeartBeatInterval": spansInLastHeartBeatInterval, "getSamplesInfoInLastHeartBeatInterval": getSamplesInfoInLastHeartBeatInterval, + "getLogsInfoInLastHeartBeatInterval": getLogsInfoInLastHeartBeatInterval, } for key, value := range tsInfo { data[key] = value