SigNoz/signoz · warning · model.BadRequest

atleast 1 metric name must be specified

Error message

atleast 1 metric name must be specified

What it means

Bad-request error from GetLatestReceivedMetric: the API requires at least one metric name because querying latest-received status without a name filter would scan the entire metrics store and be prohibitively slow. It's a deliberate guard, not an infrastructure failure.

Source

Thrown at pkg/query-service/app/clickhouseReader/reader.go:3349

		Unit:        unit,
		Type:        metricType,
		IsMonotonic: isMonotonic,
		Temporality: temporality,
	}, nil
}

func (r *ClickHouseReader) GetLatestReceivedMetric(
	ctx context.Context, orgID valuer.UUID, metricNames []string, labelValues map[string]string,
) (*model.MetricStatus, *model.ApiError) {
	ctx = ctxtypes.NewContextWithCommentVals(ctx, map[string]string{
		instrumentationtypes.TelemetrySignal:  telemetrytypes.SignalMetrics.StringValue(),
		instrumentationtypes.CodeNamespace:    "clickhouse-reader",
		instrumentationtypes.CodeFunctionName: "GetLatestReceivedMetric",
	})
	// at least 1 metric name must be specified.
	// this query can be too slow otherwise.
	if len(metricNames) < 1 {
		return nil, model.BadRequest(fmt.Errorf("atleast 1 metric name must be specified"))
	}

	quotedMetricNames := []string{}
	for _, m := range metricNames {
		quotedMetricNames = append(quotedMetricNames, utils.ClickHouseFormattedValue(m))
	}
	commaSeparatedMetricNames := strings.Join(quotedMetricNames, ", ")

	whereClauseParts := []string{
		fmt.Sprintf(`metric_name in (%s)`, commaSeparatedMetricNames),
	}

	for label, val := range labelValues {
		whereClauseParts = append(
			whereClauseParts,
			fmt.Sprintf(`JSONExtractString(labels, '%s') = '%s'`, label, val),
		)
	}

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Pass at least one concrete metric name in the request
  2. Fix the caller to validate required params before invoking the API
  3. Check the handler's param parsing if the client did send names

Example fix

// before
status, apiErr := reader.GetLatestReceivedMetric(ctx, []string{})

// after
if len(metricNames) == 0 {
    return nil, model.BadRequest(fmt.Errorf("atleast 1 metric name must be specified"))
}
status, apiErr := reader.GetLatestReceivedMetric(ctx, metricNames)
Defensive patterns

Strategy: validation

Validate before calling

if len(metricNames) == 0 {
    return model.BadRequest(fmt.Errorf("atleast 1 metric name must be specified"))
}

Prevention

When it happens

Trigger: Calling GetLatestReceivedMetric (or its HTTP handler) with an empty metricNames slice, e.g. an API request missing the metricNames query param or passing an empty array.

Common situations: Frontend bug sending empty metricNames; curl/API scripts omitting the required param; programmatic callers defaulting to empty slice.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28). Data as JSON: /api/errors/ae9f65939a3b65e9. Report an issue: GitHub.