{"record":{"id":"993355eb5f2c15fc","repo":"SigNoz/signoz","slug":"error-fetching-metric-metadata-s","errorCode":null,"errorMessage":"error fetching metric metadata: %s","messagePattern":"error fetching metric metadata: (.+?)","errorType":"exception","errorClass":null,"httpStatus":500,"severity":"error","filePath":"pkg/query-service/app/clickhouseReader/reader.go","lineNumber":3241,"sourceCode":"\t}\n\n\treturn &attributeValues, nil\n}\n\nfunc (r *ClickHouseReader) GetMetricMetadata(ctx context.Context, orgID valuer.UUID, metricName, serviceName string) (*v3.MetricMetadataResponse, error) {\n\n\tctx = ctxtypes.NewContextWithCommentVals(ctx, map[string]string{\n\t\tinstrumentationtypes.TelemetrySignal:  telemetrytypes.SignalMetrics.StringValue(),\n\t\tinstrumentationtypes.CodeNamespace:    \"clickhouse-reader\",\n\t\tinstrumentationtypes.CodeFunctionName: \"GetMetricMetadata\",\n\t})\n\tunixMilli := common.PastDayRoundOff()\n\n\t// 1. Fetch metadata from cache/db using unified function\n\tmetadataMap, apiError := r.GetUpdatedMetricsMetadata(ctx, orgID, metricName)\n\tif apiError != nil {\n\t\tr.logger.Error(\"Error in getting metric cached metadata\", errorsV2.Attr(apiError))\n\t\treturn nil, fmt.Errorf(\"error fetching metric metadata: %s\", apiError.Err.Error())\n\t}\n\n\t// Defaults in case metadata is not found\n\tvar (\n\t\tdeltaExists bool\n\t\tisMonotonic bool\n\t\ttemporality string\n\t\tdescription string\n\t\tmetricType  string\n\t\tunit        string\n\t)\n\n\tmetadata, ok := metadataMap[metricName]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"metric metadata not found: %s\", metricName)\n\t}\n\n\tmetricType = string(metadata.MetricType)","sourceCodeStart":3223,"sourceCodeEnd":3259,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/clickhouseReader/reader.go#L3223-L3259","documentation":"Thrown by SigNoz query-service ClickHouse reader when GetUpdatedMetricsMetadata fails to load metric metadata (from cache or the metadata DB) for a metric name. The wrapped apiError carries the underlying cause, typically a DB connectivity or missing metadata table issue. It aborts downstream metric operations such as histogram bucket queries that depend on temporality/isMonotonic metadata.","triggerScenarios":"Calling a metrics API endpoint (e.g. histogram bucket listing / metric metadata dependent handlers) when the metrics metadata table is unreachable, empty, or the cache layer returns an API error for the orgID+metricName pair.","commonSituations":"Fresh SigNoz install where the metadata migration hasn't run; ClickHouse/Postgres down or misconfigured (SQLEX or CH default); orgID mismatch after changing auth config; upgrading SigNoz versions where the metadata table schema changed.","solutions":["Verify ClickHouse and the metadata store are reachable from the query-service (check CLICKHOUSE_URL / storage config)","Inspect query-service logs for the wrapped apiError to identify the true cause","Confirm the metric name exists (it was recently ingested) by querying the time_series table directly","Re-run metadata migrations or wait for the metadata cache refresh cycle if the metric is brand new"],"exampleFix":"// before\nmetadataMap, apiError := r.GetUpdatedMetricsMetadata(ctx, orgID, metricName)\nif apiError != nil {\n    return nil, fmt.Errorf(\"error fetching metric metadata: %s\", apiError.Err.Error())\n}\n\n// after: fall back to defaults so the caller can still proceed\nmetadataMap, apiError := r.GetUpdatedMetricsMetadata(ctx, orgID, metricName)\nif apiError != nil {\n    r.logger.Error(\"metadata lookup failed, using defaults\", errorsV2.Attr(apiError))\n    metadataMap = map[string]v3.MetricMetadata{}\n}","handlingStrategy":"try-catch","validationCode":"// Precheck metadata availability\nif _, apiErr := reader.GetUpdatedMetricsMetadata(ctx, orgID, metricName); apiErr != nil {\n    log.Warn(\"metadata unavailable\", apiErr)\n}","typeGuard":null,"tryCatchPattern":"// In Go: wrap the call, inspect error, degrade gracefully\nif err := svc.FetchMetricMeta(ctx, orgID, name); err != nil {\n    if strings.Contains(err.Error(), \"error fetching metric metadata\") {\n        // fallback to defaults / retry later\n    }\n}","preventionTips":["Monitor ClickHouse and metadata DB health","Run migrations before upgrading query-service","Alert on metadata lookup error rates"],"tags":["signoz","clickhouse","metrics","metadata","database"],"backgroundTag":"metadata-lookup-failed","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}