From 66f807a6712635ab3f7852724eed5b71f991cc23 Mon Sep 17 00:00:00 2001
From: Dominik Broj <dominik.broj@grafana.com>
Date: Mon, 3 Jun 2024 16:14:16 +0200
Subject: [PATCH] Fix escaping quotes in Insights queries (#4442)

# What this PR does

Use backticks to correctly escape quotes in queries

## Which issue(s) this PR closes

Closes https://github.com/grafana/oncall/issues/4439

<!--
*Note*: if you have more than one GitHub issue that this PR closes, be
sure to preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
---
 .../dashboards/oncall_metrics_dashboard.json  | 36 +++++++++----------
 .../scenes/AlertGroupsByIntegration.tsx       |  2 +-
 .../insights/scenes/AlertGroupsByTeam.tsx     |  2 +-
 .../pages/insights/scenes/MTTRAverageStat.tsx |  2 +-
 .../insights/scenes/MTTRByIntegration.tsx     |  2 +-
 .../src/pages/insights/scenes/MTTRByTeam.tsx  |  2 +-
 .../insights/scenes/MTTRChangedTimeseries.tsx |  2 +-
 .../pages/insights/scenes/NewAlertGroups.tsx  |  2 +-
 .../NewAlertGroupsNotificationsTable.tsx      |  2 +-
 .../NewAlertGroupsNotificationsTimeseries.tsx |  2 +-
 .../scenes/NewAlertGroupsTimeseries.tsx       |  2 +-
 .../src/pages/insights/variables.ts           | 12 +++----
 12 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/grafana-plugin/src/dashboards/oncall_metrics_dashboard.json b/grafana-plugin/src/dashboards/oncall_metrics_dashboard.json
index aa42406517..1296babbc9 100644
--- a/grafana-plugin/src/dashboards/oncall_metrics_dashboard.json
+++ b/grafana-plugin/src/dashboards/oncall_metrics_dashboard.json
@@ -182,7 +182,7 @@
           "editorMode": "code",
           "excludeNullMetadata": false,
           "exemplar": false,
-          "expr": "round(delta(sum($alert_groups_total{slug=~\"$instance\", team=~\"$team\", integration=~\"$integration\", service_name=~\"$service_name\"})[$__range:])) >= 0",
+          "expr": "round(delta(sum($alert_groups_total{slug=~`$instance`, team=~`$team`, integration=~`$integration`, service_name=~`$service_name`})[$__range:])) >= 0",
           "format": "time_series",
           "fullMetaSearch": false,
           "includeNullMetadata": true,
@@ -266,7 +266,7 @@
           },
           "editorMode": "code",
           "exemplar": false,
-          "expr": "avg_over_time((sum($alert_groups_response_time_seconds_sum{slug=~\"$instance\", team=~\"$team\", integration=~\"$integration\", service_name=~\"$service_name\"}) / sum($alert_groups_response_time_seconds_count{slug=~\"$instance\", team=~\"$team\", integration=~\"$integration\", service_name=~\"$service_name\"}))[$__range:])",
+          "expr": "avg_over_time((sum($alert_groups_response_time_seconds_sum{slug=~`$instance`, team=~`$team`, integration=~`$integration`, service_name=~`$service_name`}) / sum($alert_groups_response_time_seconds_count{slug=~`$instance`, team=~`$team`, integration=~`$integration`, service_name=~`$service_name`}))[$__range:])",
           "instant": true,
           "legendFormat": "__auto",
           "range": false,
@@ -389,7 +389,7 @@
           "editorMode": "code",
           "excludeNullMetadata": false,
           "exemplar": false,
-          "expr": "round(delta(sum by (integration) ($alert_groups_total{slug=~\"$instance\", team=~\"$team\", integration=~\"$integration\", service_name=~\"$service_name\"})[$__interval:])) >= 0",
+          "expr": "round(delta(sum by (integration) ($alert_groups_total{slug=~`$instance`, team=~`$team`, integration=~`$integration`, service_name=~`$service_name`})[$__interval:])) >= 0",
           "fullMetaSearch": false,
           "hide": false,
           "instant": false,
@@ -507,7 +507,7 @@
           },
           "editorMode": "code",
           "exemplar": false,
-          "expr": "avg(sum($alert_groups_response_time_seconds_sum{slug=~\"$instance\", team=~\"$team\", integration=~\"$integration\", service_name=~\"$service_name\"}) / sum($alert_groups_response_time_seconds_count{slug=~\"$instance\", team=~\"$team\", integration=~\"$integration\", service_name=~\"$service_name\"}))",
+          "expr": "avg(sum($alert_groups_response_time_seconds_sum{slug=~`$instance`, team=~`$team`, integration=~`$integration`, service_name=~`$service_name`}) / sum($alert_groups_response_time_seconds_count{slug=~`$instance`, team=~`$team`, integration=~`$integration`, service_name=~`$service_name`}))",
           "instant": false,
           "legendFormat": "__auto",
           "range": true,
@@ -613,7 +613,7 @@
           },
           "editorMode": "code",
           "exemplar": false,
-          "expr": "sort_desc(round(delta(sum by (integration)($alert_groups_total{slug=~\"$instance\", team=~\"$team\", integration=~\"$integration\", service_name=~\"$service_name\"})[$__range:])) >= 0)",
+          "expr": "sort_desc(round(delta(sum by (integration)($alert_groups_total{slug=~`$instance`, team=~`$team`, integration=~`$integration`, service_name=~`$service_name`})[$__range:])) >= 0)",
           "format": "table",
           "instant": true,
           "legendFormat": "__auto",
@@ -729,7 +729,7 @@
           },
           "editorMode": "code",
           "exemplar": false,
-          "expr": "sort_desc(avg_over_time((sum by (integration)($alert_groups_response_time_seconds_sum{slug=~\"$instance\", team=~\"$team\", integration=~\"$integration\", service_name=~\"$service_name\"}) / sum by (integration)($alert_groups_response_time_seconds_count{slug=~\"$instance\", team=~\"$team\", integration=~\"$integration\", service_name=~\"$service_name\"}))[$__range:]))",
+          "expr": "sort_desc(avg_over_time((sum by (integration)($alert_groups_response_time_seconds_sum{slug=~`$instance`, team=~`$team`, integration=~`$integration`, service_name=~`$service_name`}) / sum by (integration)($alert_groups_response_time_seconds_count{slug=~`$instance`, team=~`$team`, integration=~`$integration`, service_name=~`$service_name`}))[$__range:]))",
           "format": "table",
           "instant": true,
           "legendFormat": "__auto",
@@ -862,7 +862,7 @@
           },
           "editorMode": "code",
           "exemplar": false,
-          "expr": "sort_desc(round(delta(sum by (team)($alert_groups_total{slug=~\"$instance\", team=~\"$team\", integration=~\"$integration\", service_name=~\"$service_name\"})[$__range:])) >= 0)",
+          "expr": "sort_desc(round(delta(sum by (team)($alert_groups_total{slug=~`$instance`, team=~`$team`, integration=~`$integration`, service_name=~`$service_name`})[$__range:])) >= 0)",
           "format": "table",
           "instant": true,
           "legendFormat": "__auto",
@@ -979,7 +979,7 @@
           },
           "editorMode": "code",
           "exemplar": false,
-          "expr": "sort_desc(avg_over_time((sum by(team) ($alert_groups_response_time_seconds_sum{slug=~\"$instance\", team=~\"$team\", integration=~\"$integration\", service_name=~\"$service_name\"}) / sum by(team)($alert_groups_response_time_seconds_count{slug=~\"$instance\", team=~\"$team\", integration=~\"$integration\", service_name=~\"$service_name\"}))[$__range:]))",
+          "expr": "sort_desc(avg_over_time((sum by(team) ($alert_groups_response_time_seconds_sum{slug=~`$instance`, team=~`$team`, integration=~`$integration`, service_name=~`$service_name`}) / sum by(team)($alert_groups_response_time_seconds_count{slug=~`$instance`, team=~`$team`, integration=~`$integration`, service_name=~`$service_name`}))[$__range:]))",
           "format": "table",
           "instant": true,
           "legendFormat": "__auto",
@@ -1129,7 +1129,7 @@
           "editorMode": "code",
           "excludeNullMetadata": false,
           "exemplar": false,
-          "expr": "round(delta(sum by (username)($user_was_notified_of_alert_groups_total{slug=~\"$instance\"})[$__interval:])) >= 0",
+          "expr": "round(delta(sum by (username)($user_was_notified_of_alert_groups_total{slug=~`$instance`})[$__interval:])) >= 0",
           "fullMetaSearch": false,
           "instant": false,
           "legendFormat": "__auto",
@@ -1222,7 +1222,7 @@
           },
           "editorMode": "code",
           "exemplar": false,
-          "expr": "sort_desc(round(delta(sum by (username)($user_was_notified_of_alert_groups_total{slug=~\"$instance\"})[$__range:])) >= 0)",
+          "expr": "sort_desc(round(delta(sum by (username)($user_was_notified_of_alert_groups_total{slug=~`$instance`})[$__range:])) >= 0)",
           "format": "table",
           "instant": true,
           "legendFormat": "__auto",
@@ -1430,7 +1430,7 @@
           "type": "prometheus",
           "uid": "${datasource}"
         },
-        "definition": "label_values(${alert_groups_total}{slug=~\"$instance\"},team)",
+        "definition": "label_values(${alert_groups_total}{slug=~`$instance`},team)",
         "hide": 0,
         "includeAll": true,
         "label": "Team",
@@ -1438,7 +1438,7 @@
         "name": "team",
         "options": [],
         "query": {
-          "query": "label_values(${alert_groups_total}{slug=~\"$instance\"},team)",
+          "query": "label_values(${alert_groups_total}{slug=~`$instance`},team)",
           "refId": "PrometheusVariableQueryEditor-VariableQuery"
         },
         "refresh": 2,
@@ -1458,7 +1458,7 @@
           "type": "prometheus",
           "uid": "${datasource}"
         },
-        "definition": "label_values(${alert_groups_total}{team=~\"$team\",slug=~\"$instance\"},integration)",
+        "definition": "label_values(${alert_groups_total}{team=~`$team`,slug=~`$instance`},integration)",
         "hide": 0,
         "includeAll": true,
         "label": "Integration",
@@ -1466,7 +1466,7 @@
         "name": "integration",
         "options": [],
         "query": {
-          "query": "label_values(${alert_groups_total}{team=~\"$team\",slug=~\"$instance\"},integration)",
+          "query": "label_values(${alert_groups_total}{team=~`$team`,slug=~`$instance`},integration)",
           "refId": "PrometheusVariableQueryEditor-VariableQuery"
         },
         "refresh": 2,
@@ -1486,7 +1486,7 @@
           "type": "prometheus",
           "uid": "${datasource}"
         },
-        "definition": "label_values(${alert_groups_total}{slug=~\"$instance\", team=~\"$team\"},service_name)",
+        "definition": "label_values(${alert_groups_total}{slug=~`$instance`, team=~`$team`},service_name)",
         "hide": 0,
         "includeAll": true,
         "label": "Service name",
@@ -1495,7 +1495,7 @@
         "options": [],
         "query": {
           "qryType": 1,
-          "query": "label_values(${alert_groups_total}{slug=~\"$instance\", team=~\"$team\"},service_name)",
+          "query": "label_values(${alert_groups_total}{slug=~`$instance`, team=~`$team`},service_name)",
           "refId": "PrometheusVariableQueryEditor-VariableQuery"
         },
         "refresh": 2,
@@ -1516,7 +1516,7 @@
   },
   "timezone": "browser",
   "title": "OnCall Insights",
-  "version": 3,
-  "revision": 3,
+  "version": 4,
+  "revision": 4,
   "weekStart": ""
 }
diff --git a/grafana-plugin/src/pages/insights/scenes/AlertGroupsByIntegration.tsx b/grafana-plugin/src/pages/insights/scenes/AlertGroupsByIntegration.tsx
index fdc194d540..0425a62a31 100644
--- a/grafana-plugin/src/pages/insights/scenes/AlertGroupsByIntegration.tsx
+++ b/grafana-plugin/src/pages/insights/scenes/AlertGroupsByIntegration.tsx
@@ -10,7 +10,7 @@ export function getAlertGroupsByIntegrationScene({ datasource, stack }: Insights
       {
         editorMode: 'code',
         exemplar: false,
-        expr: `sort_desc(round(delta(sum by (integration)($alert_groups_total{slug=~"${stack}", team=~"$team", integration=~"$integration", service_name=~"$service_name"})[$__range:])) >= 0)`,
+        expr: `sort_desc(round(delta(sum by (integration)($alert_groups_total{slug=~\`${stack}\`, team=~\`$team\`, integration=~\`$integration\`, service_name=~\`$service_name\`})[$__range:])) >= 0)`,
         format: 'table',
         instant: true,
         legendFormat: '__auto',
diff --git a/grafana-plugin/src/pages/insights/scenes/AlertGroupsByTeam.tsx b/grafana-plugin/src/pages/insights/scenes/AlertGroupsByTeam.tsx
index 43352671d9..b73c6a3621 100644
--- a/grafana-plugin/src/pages/insights/scenes/AlertGroupsByTeam.tsx
+++ b/grafana-plugin/src/pages/insights/scenes/AlertGroupsByTeam.tsx
@@ -10,7 +10,7 @@ export function getAlertGroupsByTeamScene({ datasource, stack }: InsightsConfig)
       {
         editorMode: 'code',
         exemplar: false,
-        expr: `sort_desc(round(delta(sum by (team)($alert_groups_total{slug=~"${stack}", team=~"$team", integration=~"$integration", service_name=~"$service_name"})[$__range:])) >= 0)`,
+        expr: `sort_desc(round(delta(sum by (team)($alert_groups_total{slug=~\`${stack}\`, team=~\`$team\`, integration=~\`$integration\`, service_name=~\`$service_name\`})[$__range:])) >= 0)`,
         format: 'table',
         instant: true,
         legendFormat: '__auto',
diff --git a/grafana-plugin/src/pages/insights/scenes/MTTRAverageStat.tsx b/grafana-plugin/src/pages/insights/scenes/MTTRAverageStat.tsx
index 5f61359bc0..e00e85678f 100644
--- a/grafana-plugin/src/pages/insights/scenes/MTTRAverageStat.tsx
+++ b/grafana-plugin/src/pages/insights/scenes/MTTRAverageStat.tsx
@@ -10,7 +10,7 @@ export function getMTTRAverage({ datasource, stack }: InsightsConfig) {
       {
         editorMode: 'code',
         exemplar: false,
-        expr: `avg_over_time((sum($alert_groups_response_time_seconds_sum{slug=~"${stack}", team=~"$team", integration=~"$integration", service_name=~"$service_name"}) / sum($alert_groups_response_time_seconds_count{slug=~"${stack}", team=~"$team", integration=~"$integration", service_name=~"$service_name"}))[$__range:])`,
+        expr: `avg_over_time((sum($alert_groups_response_time_seconds_sum{slug=~\`${stack}\`, team=~\`$team\`, integration=~\`$integration\`, service_name=~\`$service_name\`}) / sum($alert_groups_response_time_seconds_count{slug=~\`${stack}\`, team=~\`$team\`, integration=~\`$integration\`, service_name=~\`$service_name\`}))[$__range:])`,
         instant: true,
         legendFormat: '__auto',
         range: false,
diff --git a/grafana-plugin/src/pages/insights/scenes/MTTRByIntegration.tsx b/grafana-plugin/src/pages/insights/scenes/MTTRByIntegration.tsx
index aab2c74631..2e5346f6fd 100644
--- a/grafana-plugin/src/pages/insights/scenes/MTTRByIntegration.tsx
+++ b/grafana-plugin/src/pages/insights/scenes/MTTRByIntegration.tsx
@@ -10,7 +10,7 @@ export function getMTTRByIntegrationScene({ datasource, stack }: InsightsConfig)
       {
         editorMode: 'code',
         exemplar: false,
-        expr: `sort_desc(avg_over_time((sum by (integration)($alert_groups_response_time_seconds_sum{slug=~"${stack}", team=~"$team", integration=~"$integration", service_name=~"$service_name"}) / sum by (integration)($alert_groups_response_time_seconds_count{slug=~"${stack}", team=~"$team", integration=~"$integration", service_name=~"$service_name"}))[$__range:]))`,
+        expr: `sort_desc(avg_over_time((sum by (integration)($alert_groups_response_time_seconds_sum{slug=~\`${stack}\`, team=~\`$team\`, integration=~\`$integration\`, service_name=~\`$service_name\`}) / sum by (integration)($alert_groups_response_time_seconds_count{slug=~\`${stack}\`, team=~\`$team\`, integration=~\`$integration\`, service_name=~\`$service_name\`}))[$__range:]))`,
         format: 'table',
         instant: true,
         legendFormat: '__auto',
diff --git a/grafana-plugin/src/pages/insights/scenes/MTTRByTeam.tsx b/grafana-plugin/src/pages/insights/scenes/MTTRByTeam.tsx
index d86fcedbc9..90f22fde5f 100644
--- a/grafana-plugin/src/pages/insights/scenes/MTTRByTeam.tsx
+++ b/grafana-plugin/src/pages/insights/scenes/MTTRByTeam.tsx
@@ -10,7 +10,7 @@ export function getMTTRByTeamScene({ datasource, stack }: InsightsConfig) {
       {
         editorMode: 'code',
         exemplar: false,
-        expr: `sort_desc(avg_over_time((sum by(team) ($alert_groups_response_time_seconds_sum{slug=~"${stack}", team=~"$team", integration=~"$integration", service_name=~"$service_name"}) / sum by(team)($alert_groups_response_time_seconds_count{slug=~"${stack}", team=~"$team", integration=~"$integration", service_name=~"$service_name"}))[$__range:]))`,
+        expr: `sort_desc(avg_over_time((sum by(team) ($alert_groups_response_time_seconds_sum{slug=~\`${stack}\`, team=~\`$team\`, integration=~\`$integration\`, service_name=~\`$service_name\`}) / sum by(team)($alert_groups_response_time_seconds_count{slug=~\`${stack}\`, team=~\`$team\`, integration=~\`$integration\`, service_name=~\`$service_name\`}))[$__range:]))`,
         format: 'table',
         instant: true,
         legendFormat: '__auto',
diff --git a/grafana-plugin/src/pages/insights/scenes/MTTRChangedTimeseries.tsx b/grafana-plugin/src/pages/insights/scenes/MTTRChangedTimeseries.tsx
index 1614bbb663..cedc5f0545 100644
--- a/grafana-plugin/src/pages/insights/scenes/MTTRChangedTimeseries.tsx
+++ b/grafana-plugin/src/pages/insights/scenes/MTTRChangedTimeseries.tsx
@@ -10,7 +10,7 @@ export function getMTTRChangedTimeseriesScene({ datasource, stack }: InsightsCon
       {
         editorMode: 'code',
         exemplar: false,
-        expr: `avg(sum($alert_groups_response_time_seconds_sum{slug=~"${stack}", team=~"$team", integration=~"$integration", service_name=~"$service_name"}) / sum($alert_groups_response_time_seconds_count{slug=~"${stack}", team=~"$team", integration=~"$integration", service_name=~"$service_name"}))`,
+        expr: `avg(sum($alert_groups_response_time_seconds_sum{slug=~\`${stack}\`, team=~\`$team\`, integration=~\`$integration\`, service_name=~\`$service_name\`}) / sum($alert_groups_response_time_seconds_count{slug=~\`${stack}\`, team=~\`$team\`, integration=~\`$integration\`, service_name=~\`$service_name\`}))`,
         instant: false,
         legendFormat: '__auto',
         range: true,
diff --git a/grafana-plugin/src/pages/insights/scenes/NewAlertGroups.tsx b/grafana-plugin/src/pages/insights/scenes/NewAlertGroups.tsx
index ab187c2479..b044de94bb 100644
--- a/grafana-plugin/src/pages/insights/scenes/NewAlertGroups.tsx
+++ b/grafana-plugin/src/pages/insights/scenes/NewAlertGroups.tsx
@@ -12,7 +12,7 @@ export function getNewAlertGroupsScene({ datasource, stack }: InsightsConfig) {
         editorMode: 'code',
         excludeNullMetadata: false,
         exemplar: false,
-        expr: `round(delta(sum($alert_groups_total{slug=~"${stack}", team=~"$team", integration=~"$integration", service_name=~"$service_name"})[$__range:])) >= 0`,
+        expr: `round(delta(sum($alert_groups_total{slug=~\`${stack}\`, team=~\`$team\`, integration=~\`$integration\`, service_name=~\`$service_name\`})[$__range:])) >= 0`,
         format: 'time_series',
         fullMetaSearch: false,
         includeNullMetadata: true,
diff --git a/grafana-plugin/src/pages/insights/scenes/NewAlertGroupsNotificationsTable.tsx b/grafana-plugin/src/pages/insights/scenes/NewAlertGroupsNotificationsTable.tsx
index f6d9e7ba7b..48e79ce99c 100644
--- a/grafana-plugin/src/pages/insights/scenes/NewAlertGroupsNotificationsTable.tsx
+++ b/grafana-plugin/src/pages/insights/scenes/NewAlertGroupsNotificationsTable.tsx
@@ -10,7 +10,7 @@ export function getNewAlertGroupsNotificationsTableScene({ datasource, stack }:
       {
         editorMode: 'code',
         exemplar: false,
-        expr: `sort_desc(round(delta(sum by (username)($user_was_notified_of_alert_groups_total{slug=~"${stack}"})[$__range:])) >= 0)`,
+        expr: `sort_desc(round(delta(sum by (username)($user_was_notified_of_alert_groups_total{slug=~\`${stack}\`})[$__range:])) >= 0)`,
         format: 'table',
         instant: true,
         legendFormat: '__auto',
diff --git a/grafana-plugin/src/pages/insights/scenes/NewAlertGroupsNotificationsTimeseries.tsx b/grafana-plugin/src/pages/insights/scenes/NewAlertGroupsNotificationsTimeseries.tsx
index bc2ae1566b..f97b111c5e 100644
--- a/grafana-plugin/src/pages/insights/scenes/NewAlertGroupsNotificationsTimeseries.tsx
+++ b/grafana-plugin/src/pages/insights/scenes/NewAlertGroupsNotificationsTimeseries.tsx
@@ -13,7 +13,7 @@ export function getNewAlertGroupsNotificationsTimeseriesScene({ datasource, stac
         editorMode: 'code',
         excludeNullMetadata: false,
         exemplar: false,
-        expr: `round(delta(sum by (username)($user_was_notified_of_alert_groups_total{slug=~"${stack}"})[$__interval:])) >= 0`,
+        expr: `round(delta(sum by (username)($user_was_notified_of_alert_groups_total{slug=~\`${stack}\`})[$__interval:])) >= 0`,
         fullMetaSearch: false,
         instant: false,
         legendFormat: '__auto',
diff --git a/grafana-plugin/src/pages/insights/scenes/NewAlertGroupsTimeseries.tsx b/grafana-plugin/src/pages/insights/scenes/NewAlertGroupsTimeseries.tsx
index cd55670855..0f1adab94f 100644
--- a/grafana-plugin/src/pages/insights/scenes/NewAlertGroupsTimeseries.tsx
+++ b/grafana-plugin/src/pages/insights/scenes/NewAlertGroupsTimeseries.tsx
@@ -13,7 +13,7 @@ export function getNewAlertGroupsTimeseriesScene({ datasource, stack }: Insights
         editorMode: 'code',
         excludeNullMetadata: false,
         exemplar: false,
-        expr: `round(delta(sum by (integration)($alert_groups_total{slug=~"${stack}", team=~"$team", integration=~"$integration", service_name=~"$service_name"})[$__interval:])) >= 0`,
+        expr: `round(delta(sum by (integration)($alert_groups_total{slug=~\`${stack}\`, team=~\`$team\`, integration=~\`$integration\`, service_name=~\`$service_name\`})[$__interval:])) >= 0`,
         fullMetaSearch: false,
         instant: false,
         legendFormat: '__auto',
diff --git a/grafana-plugin/src/pages/insights/variables.ts b/grafana-plugin/src/pages/insights/variables.ts
index b8dbd6e2fd..9dd28021d2 100644
--- a/grafana-plugin/src/pages/insights/variables.ts
+++ b/grafana-plugin/src/pages/insights/variables.ts
@@ -34,9 +34,9 @@ const getVariables = ({ isOpenSource, datasource, stack }: InsightsConfig) => ({
     text: ['All'],
     value: ['$__all'],
     datasource,
-    definition: `label_values(\${alert_groups_total}{slug=~"${stack}"},team)`,
+    definition: `label_values(\${alert_groups_total}{slug=~\`${stack}\`},team)`,
     query: {
-      query: `label_values(\${alert_groups_total}{slug=~"${stack}"},team)`,
+      query: `label_values(\${alert_groups_total}{slug=~\`${stack}\`},team)`,
       refId: 'PrometheusVariableQueryEditor-VariableQuery',
     },
     refresh: 2,
@@ -48,9 +48,9 @@ const getVariables = ({ isOpenSource, datasource, stack }: InsightsConfig) => ({
     text: ['All'],
     value: ['$__all'],
     datasource,
-    definition: `label_values(\${alert_groups_total}{team=~"$team",slug=~"${stack}"},integration)`,
+    definition: `label_values(\${alert_groups_total}{team=~\`$team\`,slug=~\`${stack}\`},integration)`,
     query: {
-      query: `label_values(\${alert_groups_total}{team=~"$team",slug=~"${stack}"},integration)`,
+      query: `label_values(\${alert_groups_total}{team=~\`$team\`,slug=~\`${stack}\`},integration)`,
       refId: 'PrometheusVariableQueryEditor-VariableQuery',
     },
     refresh: 2,
@@ -63,9 +63,9 @@ const getVariables = ({ isOpenSource, datasource, stack }: InsightsConfig) => ({
     value: ['$__all'],
     allValue: '($^)|(.+)',
     datasource,
-    definition: `label_values(\${alert_groups_total}{slug=~"${stack}",team=~"$team"},service_name)`,
+    definition: `label_values(\${alert_groups_total}{slug=~\`${stack}\`,team=~\`$team\`},service_name)`,
     query: {
-      query: `label_values(\${alert_groups_total}{slug=~"${stack}",team=~"$team"},service_name)`,
+      query: `label_values(\${alert_groups_total}{slug=~\`${stack}\`,team=~\`$team\`},service_name)`,
       refId: 'PrometheusVariableQueryEditor-VariableQuery',
     },
     refresh: 2,