SigNoz/signoz · warning · model.ApiError

error while getting ttl. ttl type should be metrics|traces,

Error message

error while getting ttl. ttl type should be metrics|traces, got %v

What it means

Returned by GetTTL when ttlParams.Type is not one of the supported values (metrics, traces, logs handled in the switch). It is a request-validation error (model.ErrorExec) indicating an unrecognized ttl type reached the default branch.

Source

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

		}
		dbResp, apiErr := getLogsTTL()
		if apiErr != nil {
			return nil, apiErr
		}
		ttlQuery, apiErr := r.checkTTLStatusItem(ctx, orgID, tableNameArray[0])
		if apiErr != nil {
			return nil, apiErr
		}
		ttlQuery.TTL = ttlQuery.TTL / 3600 // convert to hours
		if ttlQuery.ColdStorageTTL != -1 {
			ttlQuery.ColdStorageTTL = ttlQuery.ColdStorageTTL / 3600 // convert to hours
		}

		delTTL, moveTTL := parseTTL(dbResp.EngineFull)
		return &retentiontypes.GetTTLResponseItem{LogsTime: delTTL, LogsMoveTime: moveTTL, ExpectedLogsTime: ttlQuery.TTL, ExpectedLogsMoveTime: ttlQuery.ColdStorageTTL, Status: status}, nil

	default:
		return nil, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error while getting ttl. ttl type should be metrics|traces, got %v",
			ttlParams.Type)}
	}

}

func (r *ClickHouseReader) ListErrors(ctx context.Context, queryParams *model.ListErrorsParams) (*[]model.Error, *model.ApiError) {

	ctx = ctxtypes.NewContextWithCommentVals(ctx, map[string]string{
		instrumentationtypes.TelemetrySignal:  telemetrytypes.SignalTraces.StringValue(),
		instrumentationtypes.CodeNamespace:    "clickhouse-reader",
		instrumentationtypes.CodeFunctionName: "ListErrors",
	})
	var getErrorResponses []model.Error

	query := "SELECT any(exceptionMessage) as exceptionMessage, count() AS exceptionCount, min(timestamp) as firstSeen, max(timestamp) as lastSeen, groupID"
	if len(queryParams.ServiceName) != 0 {
		query = query + ", serviceName"
	} else {

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Send a supported value: metrics or traces (and logs on versions that support it)
  2. Upgrade SigNoz query-service if you need the logs TTL type and your build lacks it
  3. Validate/normalize the type parameter before calling GetTTL (lowercase, whitelist)
  4. If writing a wrapper API, reject unknown types early with a 400 instead of forwarding

Example fix

// before
params := retentiontypes.TTLQueryParams{Type: "Metric"} // -> error while getting ttl. ttl type should be metrics|traces, got Metric
// after
params := retentiontypes.TTLQueryParams{Type: "metrics"} // ok
Defensive patterns

Strategy: validation

Validate before calling

allowed := map[string]bool{"metrics": true, "traces": true, "logs": logsSupported}
if !allowed[ttlParams.Type] { return fmt.Errorf("unsupported ttl type %q; use metrics|traces", ttlParams.Type) }

Type guard

func isValidTTLType(t string, logsSupported bool) bool { if t=="metrics"||t=="traces" {return true}; return logsSupported && t=="logs" }

Try / catch

if apiErr, ok := err.(*model.ApiError); ok && strings.Contains(apiErr.Err.Error(), "ttl type should be") { return 400, apiErr.Err }

Prevention

When it happens

Trigger: Calling the TTL endpoint with a type value outside the accepted set, e.g. type=logs on an older build that only handles metrics|traces, or a typo like type=metric.

Common situations: Version mismatch where the frontend/API caller sends 'logs' but the deployed query-service predates logs support; custom scripts passing arbitrary strings; parameter typos; case-sensitive value ('Metrics' vs 'metrics').

Related errors


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