diff --git a/public/app/features/alerting/unified/triage/scene/TriageScene.tsx b/public/app/features/alerting/unified/triage/scene/TriageScene.tsx index d5c7c96d71b..598af13c43d 100644 --- a/public/app/features/alerting/unified/triage/scene/TriageScene.tsx +++ b/public/app/features/alerting/unified/triage/scene/TriageScene.tsx @@ -58,6 +58,8 @@ export const triageScene = new EmbeddedSceneWithContext({ baseFilters: [], layout: 'combobox', expressionBuilder: prometheusExpressionBuilder, + // Filter out __name__ from options as this is the metric name not a filterable label + tagKeyRegexFilter: /^(?!__name__$).*/, }), ], }), diff --git a/public/app/features/alerting/unified/triage/scene/dataTransform.ts b/public/app/features/alerting/unified/triage/scene/dataTransform.ts index d8677cad946..303742bbf93 100644 --- a/public/app/features/alerting/unified/triage/scene/dataTransform.ts +++ b/public/app/features/alerting/unified/triage/scene/dataTransform.ts @@ -33,7 +33,7 @@ export function convertToWorkbenchRows(series: DataFrame[], groupBy: string[] = const ruleUIDIndex = fieldIndex.get('grafana_rule_uid'); // These should always exist due to validation above, but handle gracefully - if (!alertnameIndex || !folderIndex || !ruleUIDIndex) { + if (alertnameIndex === undefined || folderIndex === undefined || ruleUIDIndex === undefined) { return []; } diff --git a/public/app/features/alerting/unified/triage/scene/expressionBuilder.ts b/public/app/features/alerting/unified/triage/scene/expressionBuilder.ts index ff3d01f73e4..18360552379 100644 --- a/public/app/features/alerting/unified/triage/scene/expressionBuilder.ts +++ b/public/app/features/alerting/unified/triage/scene/expressionBuilder.ts @@ -4,9 +4,12 @@ import { AdHocFilterWithLabels } from '@grafana/scenes'; * Custom expression builder for Prometheus that properly handles regex operators. * Unlike the default builder, this doesn't escape regex metacharacters when using =~ or !~ * operators, allowing users to enter raw regex patterns. + * + * Note: __name__ is excluded from filters as it represents the metric name itself, + * not a label, and should be handled separately in query construction. */ export function prometheusExpressionBuilder(filters: AdHocFilterWithLabels[]): string { - const applicableFilters = filters.filter((f) => !f.nonApplicable && !f.hidden); + const applicableFilters = filters.filter((f) => !f.nonApplicable && !f.hidden && f.key !== '__name__'); return applicableFilters.map(renderFilter).join(','); }