@perses-dev/alert-manager-plugin 0.1.1 → 0.2.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mf/js/AlertManager.42d95b33.js +7 -0
- package/__mf/js/async/1299.d5af4767.js +1 -0
- package/__mf/js/async/1522.04dc197d.js +22 -0
- package/__mf/js/async/1616.0c9baa4c.js +1 -0
- package/__mf/js/async/1871.5e21fb62.js +1 -0
- package/__mf/js/async/1969.e54f3991.js +1 -0
- package/__mf/js/async/2043.4e8f2371.js +2 -0
- package/__mf/js/async/{430.74d85c4b.js.LICENSE.txt → 2043.4e8f2371.js.LICENSE.txt} +1 -41
- package/__mf/js/async/2197.53bcb69e.js +1 -0
- package/__mf/js/async/2218.8b7e30c2.js +2 -0
- package/__mf/js/async/2317.e656eab3.js +2 -0
- package/__mf/js/async/2377.5295b064.js +1 -0
- package/__mf/js/async/2650.0b5955b5.js +3 -0
- package/__mf/js/async/2657.e6a11726.js +1 -0
- package/__mf/js/async/3222.6ad1b128.js +1 -0
- package/__mf/js/async/3514.e71d5cb9.js +2 -0
- package/__mf/js/async/3910.1bd28e15.js +1 -0
- package/__mf/js/async/392.26ae5cc4.js +2 -0
- package/__mf/js/async/3963.181d3782.js +1 -0
- package/__mf/js/async/4077.91abd1da.js +1 -0
- package/__mf/js/async/4121.f9595b70.js +2 -0
- package/__mf/js/async/4133.cc678ae9.js +28 -0
- package/__mf/js/async/4213.005a1a65.js +1 -0
- package/__mf/js/async/{4466.a8145edd.js → 4466.7cca717d.js} +3 -3
- package/__mf/js/async/4481.5bc5aa13.js +2 -0
- package/__mf/js/async/4496.3760da2f.js +1 -0
- package/__mf/js/async/4978.f1550309.js +1 -0
- package/__mf/js/async/5038.b1e9133a.js +2 -0
- package/__mf/js/async/5071.eeb1c9b1.js +1 -0
- package/__mf/js/async/5428.6922d4df.js +1 -0
- package/__mf/js/async/5759.84fc4d0b.js +7 -0
- package/__mf/js/async/{3540.96681482.js.LICENSE.txt → 5759.84fc4d0b.js.LICENSE.txt} +41 -1
- package/__mf/js/async/6274.9f68ee7d.js +2 -0
- package/__mf/js/async/6390.0fd40bd8.js +2 -0
- package/__mf/js/async/6401.7bf2c4c2.js +1 -0
- package/__mf/js/async/6594.b3a19fc1.js +2 -0
- package/__mf/js/async/6854.f05f8da0.js +1 -0
- package/__mf/js/async/6911.bc380f0c.js +37 -0
- package/__mf/js/async/7177.83345474.js +1 -0
- package/__mf/js/async/7192.715c4cb3.js +1 -0
- package/__mf/js/async/733.8bc3bc96.js +1 -0
- package/__mf/js/async/7862.10a19eef.js +2 -0
- package/__mf/js/async/7978.4ca49c3a.js +1 -0
- package/__mf/js/async/8470.7ebe8e66.js +2 -0
- package/__mf/js/async/8697.7b6d10e1.js +1 -0
- package/__mf/js/async/873.fcc6e5b7.js +1 -0
- package/__mf/js/async/8907.5d1f9505.js +1 -0
- package/__mf/js/async/{9040.94717f28.js → 9040.8de751d6.js} +4 -4
- package/__mf/js/async/9184.307e83da.js +1 -0
- package/__mf/js/async/9235.1b0d1de0.js +1 -0
- package/__mf/js/async/941.36858244.js +2 -0
- package/__mf/js/async/9588.31544c69.js +1 -0
- package/__mf/js/async/9836.e4cf02db.js +1 -0
- package/__mf/js/async/__federation_expose_AlertManagerAlertsExplorer.4fbf2fa1.js +2 -0
- package/__mf/js/async/__federation_expose_AlertManagerAlertsQuery.27d99dac.js +1 -0
- package/__mf/js/async/__federation_expose_AlertManagerDatasource.c2b36e70.js +2 -0
- package/__mf/js/async/__federation_expose_AlertManagerSilencesExplorer.65e1901a.js +2 -0
- package/__mf/js/async/__federation_expose_AlertManagerSilencesQuery.f619a448.js +2 -0
- package/__mf/js/async/__federation_expose_AlertTable.6c37126b.js +1 -0
- package/__mf/js/async/__federation_expose_SilenceTable.3a614a2f.js +1 -0
- package/__mf/js/async/lib-router.20ba053c.js +2 -0
- package/__mf/js/{main.259f5b24.js → main.babca431.js} +2 -2
- package/lib/bootstrap.js +2 -2
- package/lib/components/ColumnsEditor.d.ts +1 -1
- package/lib/components/ColumnsEditor.d.ts.map +1 -1
- package/lib/components/ColumnsEditor.js +7 -7
- package/lib/components/ColumnsEditor.js.map +1 -1
- package/lib/components/LazyTextField.d.ts +1 -1
- package/lib/components/LazyTextField.d.ts.map +1 -1
- package/lib/components/LazyTextField.js +2 -2
- package/lib/components/LazyTextField.js.map +1 -1
- package/lib/components/MatcherEditor.d.ts +1 -1
- package/lib/components/MatcherEditor.d.ts.map +1 -1
- package/lib/components/MatcherEditor.js +4 -4
- package/lib/components/MatcherEditor.js.map +1 -1
- package/lib/components/MatchersList.d.ts +2 -2
- package/lib/components/MatchersList.d.ts.map +1 -1
- package/lib/components/MatchersList.js +1 -1
- package/lib/components/MatchersList.js.map +1 -1
- package/lib/components/SilenceForm.d.ts +2 -2
- package/lib/components/SilenceForm.d.ts.map +1 -1
- package/lib/components/SilenceForm.js +4 -4
- package/lib/components/SilenceForm.js.map +1 -1
- package/lib/components/StatusBadge.d.ts +1 -1
- package/lib/components/StatusBadge.d.ts.map +1 -1
- package/lib/components/StatusBadge.js +1 -1
- package/lib/components/StatusBadge.js.map +1 -1
- package/lib/components/index.js +5 -5
- package/lib/components/index.js.map +1 -1
- package/lib/explore/AlertManagerAlertsExplorer.d.ts +1 -1
- package/lib/explore/AlertManagerAlertsExplorer.d.ts.map +1 -1
- package/lib/explore/AlertManagerAlertsExplorer.js +5 -5
- package/lib/explore/AlertManagerAlertsExplorer.js.map +1 -1
- package/lib/explore/AlertManagerSilencesExplorer.d.ts +1 -1
- package/lib/explore/AlertManagerSilencesExplorer.d.ts.map +1 -1
- package/lib/explore/AlertManagerSilencesExplorer.js +10 -10
- package/lib/explore/AlertManagerSilencesExplorer.js.map +1 -1
- package/lib/getPluginModule.d.ts +1 -1
- package/lib/getPluginModule.d.ts.map +1 -1
- package/lib/getPluginModule.js +3 -1
- package/lib/getPluginModule.js.map +1 -1
- package/lib/index-federation.js +1 -1
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/model/alertmanager-client.d.ts +3 -3
- package/lib/model/alertmanager-client.d.ts.map +1 -1
- package/lib/model/alertmanager-client.js +4 -2
- package/lib/model/alertmanager-client.js.map +1 -1
- package/lib/model/alertmanager-selectors.d.ts +2 -2
- package/lib/model/alertmanager-selectors.d.ts.map +1 -1
- package/lib/model/alertmanager-selectors.js +1 -1
- package/lib/model/alertmanager-selectors.js.map +1 -1
- package/lib/model/index.js +3 -3
- package/lib/model/index.js.map +1 -1
- package/lib/plugins/AlertManagerDatasourceEditor.d.ts +2 -2
- package/lib/plugins/AlertManagerDatasourceEditor.d.ts.map +1 -1
- package/lib/plugins/AlertManagerDatasourceEditor.js +1 -1
- package/lib/plugins/AlertManagerDatasourceEditor.js.map +1 -1
- package/lib/plugins/alert-table/AlertTable.d.ts +3 -3
- package/lib/plugins/alert-table/AlertTable.d.ts.map +1 -1
- package/lib/plugins/alert-table/AlertTable.js +5 -5
- package/lib/plugins/alert-table/AlertTable.js.map +1 -1
- package/lib/plugins/alert-table/AlertTableColumnsEditor.d.ts +3 -3
- package/lib/plugins/alert-table/AlertTableColumnsEditor.d.ts.map +1 -1
- package/lib/plugins/alert-table/AlertTableColumnsEditor.js +4 -4
- package/lib/plugins/alert-table/AlertTableColumnsEditor.js.map +1 -1
- package/lib/plugins/alert-table/AlertTableDeduplicationEditor.d.ts +3 -3
- package/lib/plugins/alert-table/AlertTableDeduplicationEditor.d.ts.map +1 -1
- package/lib/plugins/alert-table/AlertTableDeduplicationEditor.js +4 -4
- package/lib/plugins/alert-table/AlertTableDeduplicationEditor.js.map +1 -1
- package/lib/plugins/alert-table/AlertTableLabelsEditor.d.ts +3 -3
- package/lib/plugins/alert-table/AlertTableLabelsEditor.d.ts.map +1 -1
- package/lib/plugins/alert-table/AlertTableLabelsEditor.js +6 -6
- package/lib/plugins/alert-table/AlertTableLabelsEditor.js.map +1 -1
- package/lib/plugins/alert-table/AlertTableOptionsEditor.d.ts +3 -3
- package/lib/plugins/alert-table/AlertTableOptionsEditor.d.ts.map +1 -1
- package/lib/plugins/alert-table/AlertTableOptionsEditor.js +5 -5
- package/lib/plugins/alert-table/AlertTableOptionsEditor.js.map +1 -1
- package/lib/plugins/alert-table/AlertTablePanel.d.ts +4 -4
- package/lib/plugins/alert-table/AlertTablePanel.d.ts.map +1 -1
- package/lib/plugins/alert-table/AlertTablePanel.js +21 -21
- package/lib/plugins/alert-table/AlertTablePanel.js.map +1 -1
- package/lib/plugins/alert-table/alert-table-model.d.ts +1 -1
- package/lib/plugins/alert-table/alert-table-model.d.ts.map +1 -1
- package/lib/plugins/alert-table/alert-table-model.js +2 -2
- package/lib/plugins/alert-table/alert-table-model.js.map +1 -1
- package/lib/plugins/alert-table/alert-table-sorting.d.ts +2 -2
- package/lib/plugins/alert-table/alert-table-sorting.d.ts.map +1 -1
- package/lib/plugins/alert-table/alert-table-sorting.js +1 -1
- package/lib/plugins/alert-table/alert-table-sorting.js.map +1 -1
- package/lib/plugins/alert-table/label-colors.d.ts +1 -1
- package/lib/plugins/alert-table/label-colors.d.ts.map +1 -1
- package/lib/plugins/alert-table/label-colors.js.map +1 -1
- package/lib/plugins/alertmanager-alerts-query/AlertManagerAlertsQuery.d.ts +2 -2
- package/lib/plugins/alertmanager-alerts-query/AlertManagerAlertsQuery.d.ts.map +1 -1
- package/lib/plugins/alertmanager-alerts-query/AlertManagerAlertsQuery.js +3 -3
- package/lib/plugins/alertmanager-alerts-query/AlertManagerAlertsQuery.js.map +1 -1
- package/lib/plugins/alertmanager-alerts-query/AlertManagerAlertsQueryEditor.d.ts +2 -2
- package/lib/plugins/alertmanager-alerts-query/AlertManagerAlertsQueryEditor.d.ts.map +1 -1
- package/lib/plugins/alertmanager-alerts-query/AlertManagerAlertsQueryEditor.js +7 -7
- package/lib/plugins/alertmanager-alerts-query/AlertManagerAlertsQueryEditor.js.map +1 -1
- package/lib/plugins/alertmanager-alerts-query/get-alerts-data.d.ts +3 -3
- package/lib/plugins/alertmanager-alerts-query/get-alerts-data.d.ts.map +1 -1
- package/lib/plugins/alertmanager-alerts-query/get-alerts-data.js +2 -2
- package/lib/plugins/alertmanager-alerts-query/get-alerts-data.js.map +1 -1
- package/lib/plugins/alertmanager-datasource.d.ts +3 -3
- package/lib/plugins/alertmanager-datasource.d.ts.map +1 -1
- package/lib/plugins/alertmanager-datasource.js +2 -2
- package/lib/plugins/alertmanager-datasource.js.map +1 -1
- package/lib/plugins/alertmanager-silences-query/AlertManagerSilencesQuery.d.ts +2 -2
- package/lib/plugins/alertmanager-silences-query/AlertManagerSilencesQuery.d.ts.map +1 -1
- package/lib/plugins/alertmanager-silences-query/AlertManagerSilencesQuery.js +3 -3
- package/lib/plugins/alertmanager-silences-query/AlertManagerSilencesQuery.js.map +1 -1
- package/lib/plugins/alertmanager-silences-query/AlertManagerSilencesQueryEditor.d.ts +2 -2
- package/lib/plugins/alertmanager-silences-query/AlertManagerSilencesQueryEditor.d.ts.map +1 -1
- package/lib/plugins/alertmanager-silences-query/AlertManagerSilencesQueryEditor.js +7 -7
- package/lib/plugins/alertmanager-silences-query/AlertManagerSilencesQueryEditor.js.map +1 -1
- package/lib/plugins/alertmanager-silences-query/get-silences-data.d.ts +3 -3
- package/lib/plugins/alertmanager-silences-query/get-silences-data.d.ts.map +1 -1
- package/lib/plugins/alertmanager-silences-query/get-silences-data.js +2 -2
- package/lib/plugins/alertmanager-silences-query/get-silences-data.js.map +1 -1
- package/lib/plugins/index.js +16 -16
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/silence-table/SilenceTable.d.ts +2 -2
- package/lib/plugins/silence-table/SilenceTable.d.ts.map +1 -1
- package/lib/plugins/silence-table/SilenceTable.js +3 -3
- package/lib/plugins/silence-table/SilenceTable.js.map +1 -1
- package/lib/plugins/silence-table/SilenceTableColumnsEditor.d.ts +3 -3
- package/lib/plugins/silence-table/SilenceTableColumnsEditor.d.ts.map +1 -1
- package/lib/plugins/silence-table/SilenceTableColumnsEditor.js +5 -5
- package/lib/plugins/silence-table/SilenceTableColumnsEditor.js.map +1 -1
- package/lib/plugins/silence-table/SilenceTableOptionsEditor.d.ts +3 -3
- package/lib/plugins/silence-table/SilenceTableOptionsEditor.d.ts.map +1 -1
- package/lib/plugins/silence-table/SilenceTableOptionsEditor.js +5 -5
- package/lib/plugins/silence-table/SilenceTableOptionsEditor.js.map +1 -1
- package/lib/plugins/silence-table/SilenceTablePanel.d.ts +4 -4
- package/lib/plugins/silence-table/SilenceTablePanel.d.ts.map +1 -1
- package/lib/plugins/silence-table/SilenceTablePanel.js +13 -13
- package/lib/plugins/silence-table/SilenceTablePanel.js.map +1 -1
- package/lib/plugins/silence-table/silence-table-model.d.ts +1 -1
- package/lib/plugins/silence-table/silence-table-model.d.ts.map +1 -1
- package/lib/plugins/silence-table/silence-table-model.js.map +1 -1
- package/lib/plugins/silence-table/silence-table-sorting.d.ts +2 -2
- package/lib/plugins/silence-table/silence-table-sorting.d.ts.map +1 -1
- package/lib/plugins/silence-table/silence-table-sorting.js +1 -1
- package/lib/plugins/silence-table/silence-table-sorting.js.map +1 -1
- package/lib/plugins/types.d.ts +3 -3
- package/lib/plugins/types.d.ts.map +1 -1
- package/lib/plugins/types.js.map +1 -1
- package/lib/setup-tests.d.ts +1 -1
- package/lib/setup-tests.d.ts.map +1 -1
- package/lib/setup-tests.js +2 -2
- package/lib/setup-tests.js.map +1 -1
- package/mf-manifest.json +302 -308
- package/mf-stats.json +308 -314
- package/package.json +12 -12
- package/__mf/js/AlertManager.377d377b.js +0 -7
- package/__mf/js/async/1616.24f00c9d.js +0 -1
- package/__mf/js/async/1728.8a326412.js +0 -1
- package/__mf/js/async/1871.23ff54b3.js +0 -1
- package/__mf/js/async/1969.a83b1b48.js +0 -1
- package/__mf/js/async/2218.7829c9d9.js +0 -2
- package/__mf/js/async/2377.f8875a4e.js +0 -1
- package/__mf/js/async/2657.fe8dd44f.js +0 -1
- package/__mf/js/async/2842.993baf22.js +0 -1
- package/__mf/js/async/3468.1679f87f.js +0 -1
- package/__mf/js/async/3540.96681482.js +0 -2
- package/__mf/js/async/392.7e11dd69.js +0 -2
- package/__mf/js/async/3963.fb6246d2.js +0 -1
- package/__mf/js/async/3981.84d12fdc.js +0 -4
- package/__mf/js/async/3981.84d12fdc.js.LICENSE.txt +0 -24
- package/__mf/js/async/4121.ec666be2.js +0 -2
- package/__mf/js/async/4133.e94df4f8.js +0 -28
- package/__mf/js/async/4213.a0c4f2eb.js +0 -1
- package/__mf/js/async/430.74d85c4b.js +0 -7
- package/__mf/js/async/4788.49ffeac3.js +0 -1
- package/__mf/js/async/5038.269393e3.js +0 -2
- package/__mf/js/async/5481.cf6703fd.js +0 -2
- package/__mf/js/async/5570.d4dd47e0.js +0 -1
- package/__mf/js/async/573.ce8ce2ef.js +0 -2
- package/__mf/js/async/6274.8c77cb1a.js +0 -2
- package/__mf/js/async/6390.3f6f279d.js +0 -2
- package/__mf/js/async/6401.1a59dbad.js +0 -1
- package/__mf/js/async/6594.b02adfd9.js +0 -2
- package/__mf/js/async/663.5445c7e0.js +0 -1
- package/__mf/js/async/6854.1d628838.js +0 -1
- package/__mf/js/async/7177.27c86137.js +0 -1
- package/__mf/js/async/7192.ede9860b.js +0 -1
- package/__mf/js/async/7283.8c1cb6ee.js +0 -2
- package/__mf/js/async/7984.163a6ddb.js +0 -22
- package/__mf/js/async/804.23da0d30.js +0 -37
- package/__mf/js/async/8470.2df0db71.js +0 -2
- package/__mf/js/async/8697.c13c6603.js +0 -1
- package/__mf/js/async/8711.c7dc09b8.js +0 -2
- package/__mf/js/async/8907.9e3edf43.js +0 -1
- package/__mf/js/async/9184.27a439a4.js +0 -1
- package/__mf/js/async/9235.00f9412f.js +0 -1
- package/__mf/js/async/941.d3bc6208.js +0 -2
- package/__mf/js/async/9537.36ff6f15.js +0 -1
- package/__mf/js/async/9634.3a366799.js +0 -1
- package/__mf/js/async/983.36857235.js +0 -1
- package/__mf/js/async/9836.cc839227.js +0 -1
- package/__mf/js/async/__federation_expose_AlertManagerAlertsExplorer.47ee46dc.js +0 -2
- package/__mf/js/async/__federation_expose_AlertManagerAlertsQuery.22b0e5bc.js +0 -1
- package/__mf/js/async/__federation_expose_AlertManagerDatasource.7ee7440a.js +0 -2
- package/__mf/js/async/__federation_expose_AlertManagerSilencesExplorer.35860f1b.js +0 -2
- package/__mf/js/async/__federation_expose_AlertManagerSilencesQuery.52a24c9e.js +0 -2
- package/__mf/js/async/__federation_expose_AlertTable.5d005bae.js +0 -1
- package/__mf/js/async/__federation_expose_SilenceTable.3fc487a4.js +0 -2
- package/__mf/js/async/__federation_expose_SilenceTable.3fc487a4.js.LICENSE.txt +0 -9
- package/__mf/js/async/lib-router.19f64904.js +0 -2
- package/lib/cjs/bootstrap.js +0 -26
- package/lib/cjs/components/ColumnsEditor.js +0 -271
- package/lib/cjs/components/LazyTextField.js +0 -50
- package/lib/cjs/components/MatcherEditor.js +0 -153
- package/lib/cjs/components/MatchersList.js +0 -46
- package/lib/cjs/components/SilenceForm.js +0 -205
- package/lib/cjs/components/StatusBadge.js +0 -71
- package/lib/cjs/components/index.js +0 -44
- package/lib/cjs/explore/AlertManagerAlertsExplorer.js +0 -79
- package/lib/cjs/explore/AlertManagerSilencesExplorer.js +0 -153
- package/lib/cjs/getPluginModule.js +0 -39
- package/lib/cjs/index-federation.js +0 -55
- package/lib/cjs/index.js +0 -39
- package/lib/cjs/model/alertmanager-client.js +0 -128
- package/lib/cjs/model/alertmanager-selectors.js +0 -66
- package/lib/cjs/model/api-types.js +0 -22
- package/lib/cjs/model/index.js +0 -32
- package/lib/cjs/plugins/AlertManagerDatasourceEditor.js +0 -71
- package/lib/cjs/plugins/alert-table/AlertTable.js +0 -56
- package/lib/cjs/plugins/alert-table/AlertTableColumnsEditor.js +0 -110
- package/lib/cjs/plugins/alert-table/AlertTableDeduplicationEditor.js +0 -138
- package/lib/cjs/plugins/alert-table/AlertTableLabelsEditor.js +0 -277
- package/lib/cjs/plugins/alert-table/AlertTableOptionsEditor.js +0 -128
- package/lib/cjs/plugins/alert-table/AlertTablePanel.js +0 -773
- package/lib/cjs/plugins/alert-table/alert-table-model.js +0 -142
- package/lib/cjs/plugins/alert-table/alert-table-sorting.js +0 -205
- package/lib/cjs/plugins/alert-table/label-colors.js +0 -170
- package/lib/cjs/plugins/alertmanager-alerts-query/AlertManagerAlertsQuery.js +0 -51
- package/lib/cjs/plugins/alertmanager-alerts-query/AlertManagerAlertsQueryEditor.js +0 -138
- package/lib/cjs/plugins/alertmanager-alerts-query/get-alerts-data.js +0 -124
- package/lib/cjs/plugins/alertmanager-datasource.js +0 -69
- package/lib/cjs/plugins/alertmanager-silences-query/AlertManagerSilencesQuery.js +0 -45
- package/lib/cjs/plugins/alertmanager-silences-query/AlertManagerSilencesQueryEditor.js +0 -78
- package/lib/cjs/plugins/alertmanager-silences-query/get-silences-data.js +0 -64
- package/lib/cjs/plugins/index.js +0 -74
- package/lib/cjs/plugins/silence-table/SilenceTable.js +0 -42
- package/lib/cjs/plugins/silence-table/SilenceTableColumnsEditor.js +0 -137
- package/lib/cjs/plugins/silence-table/SilenceTableOptionsEditor.js +0 -63
- package/lib/cjs/plugins/silence-table/SilenceTablePanel.js +0 -345
- package/lib/cjs/plugins/silence-table/silence-table-model.js +0 -116
- package/lib/cjs/plugins/silence-table/silence-table-sorting.js +0 -68
- package/lib/cjs/plugins/types.js +0 -16
- package/lib/cjs/setup-tests.js +0 -18
- /package/__mf/css/async/{430.85c2cbf6.css → 5759.85c2cbf6.css} +0 -0
- /package/__mf/js/async/{7984.163a6ddb.js.LICENSE.txt → 1522.04dc197d.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{2218.7829c9d9.js.LICENSE.txt → 2218.8b7e30c2.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{5038.269393e3.js.LICENSE.txt → 2317.e656eab3.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6390.3f6f279d.js.LICENSE.txt → 3514.e71d5cb9.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.7e11dd69.js.LICENSE.txt → 392.26ae5cc4.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{4121.ec666be2.js.LICENSE.txt → 4121.f9595b70.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6594.b02adfd9.js.LICENSE.txt → 5038.b1e9133a.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6274.8c77cb1a.js.LICENSE.txt → 6274.9f68ee7d.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{7283.8c1cb6ee.js.LICENSE.txt → 6390.0fd40bd8.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{8711.c7dc09b8.js.LICENSE.txt → 6594.b3a19fc1.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{5481.cf6703fd.js.LICENSE.txt → 7862.10a19eef.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{8470.2df0db71.js.LICENSE.txt → 8470.7ebe8e66.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{9040.94717f28.js.LICENSE.txt → 9040.8de751d6.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.d3bc6208.js.LICENSE.txt → 941.36858244.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_AlertManagerAlertsExplorer.47ee46dc.js.LICENSE.txt → __federation_expose_AlertManagerAlertsExplorer.4fbf2fa1.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_AlertManagerDatasource.7ee7440a.js.LICENSE.txt → __federation_expose_AlertManagerDatasource.c2b36e70.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_AlertManagerSilencesExplorer.35860f1b.js.LICENSE.txt → __federation_expose_AlertManagerSilencesExplorer.65e1901a.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_AlertManagerSilencesQuery.52a24c9e.js.LICENSE.txt → __federation_expose_AlertManagerSilencesQuery.f619a448.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{lib-router.19f64904.js.LICENSE.txt → lib-router.20ba053c.js.LICENSE.txt} +0 -0
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { getSeverityWeight, SEVERITY_ORDER } from
|
|
13
|
+
import { getSeverityWeight, SEVERITY_ORDER } from "./label-colors.js";
|
|
14
14
|
export const SORT_COL_STATUS = '__status__';
|
|
15
15
|
export const SORT_COL_ALERTNAME = '__alertname__';
|
|
16
16
|
const STATUS_WEIGHT = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/alert-table/alert-table-sorting.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Alert } from '@perses-dev/spec';\nimport { ColumnSortMode, SortDirection } from './alert-table-model';\nimport { getSeverityWeight, SEVERITY_ORDER } from './label-colors';\n\nexport const SORT_COL_STATUS = '__status__';\nexport const SORT_COL_ALERTNAME = '__alertname__';\n\nexport interface SortState {\n columnName: string;\n direction: SortDirection;\n mode: ColumnSortMode;\n}\n\nconst STATUS_WEIGHT: Record<string, number> = {\n firing: 0,\n pending: 1,\n suppressed: 2,\n inactive: 3,\n resolved: 4,\n};\n\nexport function getEffectiveStatus(alert: Alert): string {\n return alert.suppressed ? 'suppressed' : alert.state;\n}\n\nfunction compareStatus(a: string | undefined, b: string | undefined): number {\n const wa = a !== undefined ? (STATUS_WEIGHT[a] ?? 5) : 5;\n const wb = b !== undefined ? (STATUS_WEIGHT[b] ?? 5) : 5;\n return wa - wb;\n}\n\nfunction directionMultiplier(direction: SortDirection): number {\n return direction === 'asc' ? 1 : -1;\n}\n\nfunction compareAlphabetical(a: string | undefined, b: string | undefined): number {\n if (a === undefined && b === undefined) return 0;\n if (a === undefined) return 1;\n if (b === undefined) return -1;\n return a.localeCompare(b);\n}\n\nfunction compareNumeric(a: string | undefined, b: string | undefined): number {\n const na = a !== undefined ? parseFloat(a) : NaN;\n const nb = b !== undefined ? parseFloat(b) : NaN;\n if (isNaN(na) && isNaN(nb)) return 0;\n if (isNaN(na)) return 1;\n if (isNaN(nb)) return -1;\n return na - nb;\n}\n\nfunction compareSeverity(a: string | undefined, b: string | undefined): number {\n const wa = a !== undefined ? getSeverityWeight(a) : SEVERITY_ORDER.length;\n const wb = b !== undefined ? getSeverityWeight(b) : SEVERITY_ORDER.length;\n return wa - wb;\n}\n\nexport function compareAlertsByColumn(a: Alert, b: Alert, sort: SortState): number {\n if (sort.columnName === SORT_COL_STATUS) {\n return compareStatus(getEffectiveStatus(a), getEffectiveStatus(b)) * directionMultiplier(sort.direction);\n }\n if (sort.columnName === SORT_COL_ALERTNAME) {\n return compareAlphabetical(a.name, b.name) * directionMultiplier(sort.direction);\n }\n\n const va = a.labels[sort.columnName];\n const vb = b.labels[sort.columnName];\n let result: number;\n\n switch (sort.mode) {\n case 'numeric':\n result = compareNumeric(va, vb);\n break;\n case 'severity':\n result = compareSeverity(va, vb);\n break;\n case 'alphabetical':\n default:\n result = compareAlphabetical(va, vb);\n break;\n }\n\n return result * directionMultiplier(sort.direction);\n}\n\nfunction getMostFrequentValue(counts: Record<string, number>): { value: string | undefined; count: number } {\n let maxCount = 0;\n let maxValue: string | undefined;\n for (const [value, count] of Object.entries(counts)) {\n if (count > maxCount) {\n maxCount = count;\n maxValue = value;\n }\n }\n return { value: maxValue, count: maxCount };\n}\n\nfunction getMostCriticalStatus(counts: Record<string, number>): { weight: number; count: number } {\n let minWeight = 5;\n let countAtMin = 0;\n for (const [value, count] of Object.entries(counts)) {\n const weight = STATUS_WEIGHT[value] ?? 5;\n if (weight < minWeight) {\n minWeight = weight;\n countAtMin = count;\n } else if (weight === minWeight) {\n countAtMin += count;\n }\n }\n return { weight: minWeight, count: countAtMin };\n}\n\nfunction getMostCriticalSeverity(counts: Record<string, number>): { weight: number; count: number } {\n let minWeight = SEVERITY_ORDER.length;\n let countAtMin = 0;\n for (const [value, count] of Object.entries(counts)) {\n const weight = getSeverityWeight(value);\n if (weight < minWeight) {\n minWeight = weight;\n countAtMin = count;\n } else if (weight === minWeight) {\n countAtMin += count;\n }\n }\n return { weight: minWeight, count: countAtMin };\n}\n\nexport function compareGroupsByColumn(\n aCounts: Record<string, number> | undefined,\n bCounts: Record<string, number> | undefined,\n sort: SortState\n): number {\n const emptyA = !aCounts || Object.keys(aCounts).length === 0;\n const emptyB = !bCounts || Object.keys(bCounts).length === 0;\n if (emptyA && emptyB) return 0;\n if (emptyA) return 1;\n if (emptyB) return -1;\n\n let result: number;\n\n switch (sort.mode) {\n case 'status': {\n const statusA = getMostCriticalStatus(aCounts);\n const statusB = getMostCriticalStatus(bCounts);\n result = statusA.weight - statusB.weight;\n if (result === 0) {\n result = statusB.count - statusA.count;\n }\n break;\n }\n case 'severity': {\n const sevA = getMostCriticalSeverity(aCounts);\n const sevB = getMostCriticalSeverity(bCounts);\n result = sevA.weight - sevB.weight;\n if (result === 0) {\n result = sevB.count - sevA.count;\n }\n break;\n }\n case 'numeric': {\n const freqA = getMostFrequentValue(aCounts);\n const freqB = getMostFrequentValue(bCounts);\n const numResult = compareNumeric(freqA.value, freqB.value);\n if (numResult !== 0) {\n return numResult * directionMultiplier(sort.direction);\n }\n // Tie-break by count is always descending (larger groups first) regardless of sort direction\n return freqB.count - freqA.count;\n }\n case 'alphabetical':\n default: {\n const freqA = getMostFrequentValue(aCounts);\n const freqB = getMostFrequentValue(bCounts);\n const alphaResult = compareAlphabetical(freqA.value, freqB.value);\n if (alphaResult !== 0) {\n return alphaResult * directionMultiplier(sort.direction);\n }\n // Tie-break by count is always descending (larger groups first) regardless of sort direction\n return freqB.count - freqA.count;\n }\n }\n\n return result * directionMultiplier(sort.direction);\n}\n"],"names":["getSeverityWeight","SEVERITY_ORDER","SORT_COL_STATUS","SORT_COL_ALERTNAME","STATUS_WEIGHT","firing","pending","suppressed","inactive","resolved","getEffectiveStatus","alert","state","compareStatus","a","b","wa","undefined","wb","directionMultiplier","direction","compareAlphabetical","localeCompare","compareNumeric","na","parseFloat","NaN","nb","isNaN","compareSeverity","length","compareAlertsByColumn","sort","columnName","name","va","labels","vb","result","mode","getMostFrequentValue","counts","maxCount","maxValue","value","count","Object","entries","getMostCriticalStatus","minWeight","countAtMin","weight","getMostCriticalSeverity","compareGroupsByColumn","aCounts","bCounts","emptyA","keys","emptyB","statusA","statusB","sevA","sevB","freqA","freqB","numResult","alphaResult"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,iBAAiB;AAEnE,OAAO,MAAMC,kBAAkB,aAAa;AAC5C,OAAO,MAAMC,qBAAqB,gBAAgB;AAQlD,MAAMC,gBAAwC;IAC5CC,QAAQ;IACRC,SAAS;IACTC,YAAY;IACZC,UAAU;IACVC,UAAU;AACZ;AAEA,OAAO,SAASC,mBAAmBC,KAAY;IAC7C,OAAOA,MAAMJ,UAAU,GAAG,eAAeI,MAAMC,KAAK;AACtD;AAEA,SAASC,cAAcC,CAAqB,EAAEC,CAAqB;IACjE,MAAMC,KAAKF,MAAMG,YAAab,aAAa,CAACU,EAAE,IAAI,IAAK;IACvD,MAAMI,KAAKH,MAAME,YAAab,aAAa,CAACW,EAAE,IAAI,IAAK;IACvD,OAAOC,KAAKE;AACd;AAEA,SAASC,oBAAoBC,S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rB,OAAOA,cAAc/C,oBAAoBa,KAAKZ,SAAS;gBACzD;gBACA,6FAA6F;gBAC7F,OAAO4C,MAAMnB,KAAK,GAAGkB,MAAMlB,KAAK;YAClC;IACF;IAEA,OAAOP,SAASnB,oBAAoBa,KAAKZ,SAAS;AACpD"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/alert-table/alert-table-sorting.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { Alert } from '@perses-dev/spec';\n\nimport type { ColumnSortMode, SortDirection } from './alert-table-model';\nimport { getSeverityWeight, SEVERITY_ORDER } from './label-colors';\n\nexport const SORT_COL_STATUS = '__status__';\nexport const SORT_COL_ALERTNAME = '__alertname__';\n\nexport interface SortState {\n columnName: string;\n direction: SortDirection;\n mode: ColumnSortMode;\n}\n\nconst STATUS_WEIGHT: Record<string, number> = {\n firing: 0,\n pending: 1,\n suppressed: 2,\n inactive: 3,\n resolved: 4,\n};\n\nexport function getEffectiveStatus(alert: Alert): string {\n return alert.suppressed ? 'suppressed' : alert.state;\n}\n\nfunction compareStatus(a: string | undefined, b: string | undefined): number {\n const wa = a !== undefined ? (STATUS_WEIGHT[a] ?? 5) : 5;\n const wb = b !== undefined ? (STATUS_WEIGHT[b] ?? 5) : 5;\n return wa - wb;\n}\n\nfunction directionMultiplier(direction: SortDirection): number {\n return direction === 'asc' ? 1 : -1;\n}\n\nfunction compareAlphabetical(a: string | undefined, b: string | undefined): number {\n if (a === undefined && b === undefined) return 0;\n if (a === undefined) return 1;\n if (b === undefined) return -1;\n return a.localeCompare(b);\n}\n\nfunction compareNumeric(a: string | undefined, b: string | undefined): number {\n const na = a !== undefined ? parseFloat(a) : NaN;\n const nb = b !== undefined ? parseFloat(b) : NaN;\n if (isNaN(na) && isNaN(nb)) return 0;\n if (isNaN(na)) return 1;\n if (isNaN(nb)) return -1;\n return na - nb;\n}\n\nfunction compareSeverity(a: string | undefined, b: string | undefined): number {\n const wa = a !== undefined ? getSeverityWeight(a) : SEVERITY_ORDER.length;\n const wb = b !== undefined ? getSeverityWeight(b) : SEVERITY_ORDER.length;\n return wa - wb;\n}\n\nexport function compareAlertsByColumn(a: Alert, b: Alert, sort: SortState): number {\n if (sort.columnName === SORT_COL_STATUS) {\n return compareStatus(getEffectiveStatus(a), getEffectiveStatus(b)) * directionMultiplier(sort.direction);\n }\n if (sort.columnName === SORT_COL_ALERTNAME) {\n return compareAlphabetical(a.name, b.name) * directionMultiplier(sort.direction);\n }\n\n const va = a.labels[sort.columnName];\n const vb = b.labels[sort.columnName];\n let result: number;\n\n switch (sort.mode) {\n case 'numeric':\n result = compareNumeric(va, vb);\n break;\n case 'severity':\n result = compareSeverity(va, vb);\n break;\n case 'alphabetical':\n default:\n result = compareAlphabetical(va, vb);\n break;\n }\n\n return result * directionMultiplier(sort.direction);\n}\n\nfunction getMostFrequentValue(counts: Record<string, number>): { value: string | undefined; count: number } {\n let maxCount = 0;\n let maxValue: string | undefined;\n for (const [value, count] of Object.entries(counts)) {\n if (count > maxCount) {\n maxCount = count;\n maxValue = value;\n }\n }\n return { value: maxValue, count: maxCount };\n}\n\nfunction getMostCriticalStatus(counts: Record<string, number>): { weight: number; count: number } {\n let minWeight = 5;\n let countAtMin = 0;\n for (const [value, count] of Object.entries(counts)) {\n const weight = STATUS_WEIGHT[value] ?? 5;\n if (weight < minWeight) {\n minWeight = weight;\n countAtMin = count;\n } else if (weight === minWeight) {\n countAtMin += count;\n }\n }\n return { weight: minWeight, count: countAtMin };\n}\n\nfunction getMostCriticalSeverity(counts: Record<string, number>): { weight: number; count: number } {\n let minWeight = SEVERITY_ORDER.length;\n let countAtMin = 0;\n for (const [value, count] of Object.entries(counts)) {\n const weight = getSeverityWeight(value);\n if (weight < minWeight) {\n minWeight = weight;\n countAtMin = count;\n } else if (weight === minWeight) {\n countAtMin += count;\n }\n }\n return { weight: minWeight, count: countAtMin };\n}\n\nexport function compareGroupsByColumn(\n aCounts: Record<string, number> | undefined,\n bCounts: Record<string, number> | undefined,\n sort: SortState,\n): number {\n const emptyA = !aCounts || Object.keys(aCounts).length === 0;\n const emptyB = !bCounts || Object.keys(bCounts).length === 0;\n if (emptyA && emptyB) return 0;\n if (emptyA) return 1;\n if (emptyB) return -1;\n\n let result: number;\n\n switch (sort.mode) {\n case 'status': {\n const statusA = getMostCriticalStatus(aCounts);\n const statusB = getMostCriticalStatus(bCounts);\n result = statusA.weight - statusB.weight;\n if (result === 0) {\n result = statusB.count - statusA.count;\n }\n break;\n }\n case 'severity': {\n const sevA = getMostCriticalSeverity(aCounts);\n const sevB = getMostCriticalSeverity(bCounts);\n result = sevA.weight - sevB.weight;\n if (result === 0) {\n result = sevB.count - sevA.count;\n }\n break;\n }\n case 'numeric': {\n const freqA = getMostFrequentValue(aCounts);\n const freqB = getMostFrequentValue(bCounts);\n const numResult = compareNumeric(freqA.value, freqB.value);\n if (numResult !== 0) {\n return numResult * directionMultiplier(sort.direction);\n }\n // Tie-break by count is always descending (larger groups first) regardless of sort direction\n return freqB.count - freqA.count;\n }\n case 'alphabetical':\n default: {\n const freqA = getMostFrequentValue(aCounts);\n const freqB = getMostFrequentValue(bCounts);\n const alphaResult = compareAlphabetical(freqA.value, freqB.value);\n if (alphaResult !== 0) {\n return alphaResult * directionMultiplier(sort.direction);\n }\n // Tie-break by count is always descending (larger groups first) regardless of sort direction\n return freqB.count - freqA.count;\n }\n }\n\n return result * directionMultiplier(sort.direction);\n}\n"],"names":["getSeverityWeight","SEVERITY_ORDER","SORT_COL_STATUS","SORT_COL_ALERTNAME","STATUS_WEIGHT","firing","pending","suppressed","inactive","resolved","getEffectiveStatus","alert","state","compareStatus","a","b","wa","undefined","wb","directionMultiplier","direction","compareAlphabetical","localeCompare","compareNumeric","na","parseFloat","NaN","nb","isNaN","compareSeverity","length","compareAlertsByColumn","sort","columnName","name","va","labels","vb","result","mode","getMostFrequentValue","counts","maxCount","maxValue","value","count","Object","entries","getMostCriticalStatus","minWeight","countAtMin","weight","getMostCriticalSeverity","compareGroupsByColumn","aCounts","bCounts","emptyA","keys","emptyB","statusA","statusB","sevA","sevB","freqA","freqB","numResult","alphaResult"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAKjC,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,oBAAiB;AAEnE,OAAO,MAAMC,kBAAkB,aAAa;AAC5C,OAAO,MAAMC,qBAAqB,gBAAgB;AAQlD,MAAMC,gBAAwC;IAC5CC,QAAQ;IACRC,SAAS;IACTC,YAAY;IACZC,UAAU;IACVC,UAAU;AACZ;AAEA,OAAO,SAASC,mBAAmBC,KAAY;IAC7C,OAAOA,MAAMJ,UAAU,GAAG,eAAeI,MAAMC,KAAK;AACtD;AAEA,SAASC,cAAcC,CAAqB,EAAEC,CAAqB;IACjE,MAAMC,KAAKF,MAAMG,YAAab,aAAa,CAACU,EAAE,IAAI,IAAK;IACvD,MAAMI,KAAKH,MAAME,YAAab,aAAa,CAACW,EAAE,IAAI,IAAK;IACvD,OAAOC,KAAKE;AACd;AAEA,SAASC,oBAAoBC,SAAwB;IACnD,OAAOA,cAAc,QAAQ,IAAI,CAAC;AACpC;AAEA,SAASC,oBAAoBP,CAAqB,EAAEC,CAAqB;IACvE,IAAID,MAAMG,aAAaF,MAAME,WAAW,OAAO;IAC/C,IAAIH,MAAMG,WAAW,OAAO;IAC5B,IAAIF,MAAME,WAAW,OAAO,CAA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
|
|
1
|
-
import { LabelColorMapping } from './alert-table-model';
|
|
1
|
+
import type { LabelColorMapping } from './alert-table-model';
|
|
2
2
|
export declare const SEVERITY_ORDER: string[];
|
|
3
3
|
export declare function getSeverityWeight(value: string): number;
|
|
4
4
|
export declare function hashStringToColor(value: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label-colors.d.ts","sourceRoot":"","sources":["../../../../src/plugins/alert-table/label-colors.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"label-colors.d.ts","sourceRoot":"","sources":["../../../../src/plugins/alert-table/label-colors.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAgC7D,eAAO,MAAM,cAAc,EAAE,MAAM,EAAmF,CAAC;AAEvH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CASvD;AAKD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAWvD;AA0BD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAiB/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/alert-table/label-colors.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { LabelColorMapping } from './alert-table-model';\n\nconst SEVERITY_LEVEL_COLORS: Record<string, string> = {\n critical: '#d32f2f',\n error: '#ef6c00',\n warning: '#f9a825',\n info: '#0288d1',\n debug: '#7b1fa2',\n trace: '#6a1b9a',\n unknown: '#757575',\n other: '#9e9e9e',\n};\n\nconst SEVERITY_ABBREVIATIONS: Record<string, string[]> = {\n critical: ['critical', 'crit', 'fatal', 'emerg', 'alert', 'page'],\n error: ['error', 'err', 'eror', 'high', 'severe'],\n warning: ['warning', 'warn', 'medium'],\n info: ['info', 'inf', 'information', 'informational', 'notice', 'low'],\n debug: ['debug', 'dbug'],\n trace: ['trace'],\n unknown: ['unknown'],\n other: ['other', 'none', 'minor', ''],\n};\n\nconst SEVERITY_COLORS: Record<string, string> = {};\nfor (const [level, abbrevs] of Object.entries(SEVERITY_ABBREVIATIONS)) {\n const color = SEVERITY_LEVEL_COLORS[level]!;\n for (const abbrev of abbrevs) {\n SEVERITY_COLORS[abbrev] = color;\n }\n}\n\nexport const SEVERITY_ORDER: string[] = ['critical', 'error', 'warning', 'info', 'debug', 'trace', 'unknown', 'other'];\n\nexport function getSeverityWeight(value: string): number {\n const normalized = value.toLowerCase();\n for (const [level, abbrevs] of Object.entries(SEVERITY_ABBREVIATIONS)) {\n if (abbrevs.includes(normalized)) {\n const idx = SEVERITY_ORDER.indexOf(level);\n return idx === -1 ? SEVERITY_ORDER.length : idx;\n }\n }\n return SEVERITY_ORDER.length;\n}\n\nconst MANUAL_FALLBACK = '#9e9e9e';\nconst ERROR_HUE_CUTOFF = 20;\n\nexport function hashStringToColor(value: string): string {\n let hash = 5381;\n for (let i = 0; i < value.length; i++) {\n hash = (hash * 33) ^ value.charCodeAt(i);\n }\n hash = Math.abs(hash);\n\n const hue = ERROR_HUE_CUTOFF + (hash % (360 - ERROR_HUE_CUTOFF));\n const saturation = 55 + (hash % 25);\n const lightness = 45 + (hash % 15);\n return `hsl(${hue}, ${saturation}%, ${lightness}%)`;\n}\n\nconst MAX_REGEX_CACHE_SIZE = 1000;\nconst regexCache = new Map<string, RegExp | null>();\n\nfunction getCompiledRegex(pattern: string): RegExp | null {\n if (regexCache.has(pattern)) return regexCache.get(pattern)!;\n if (regexCache.size >= MAX_REGEX_CACHE_SIZE) regexCache.clear();\n try {\n const re = new RegExp(pattern);\n regexCache.set(pattern, re);\n return re;\n } catch {\n regexCache.set(pattern, null);\n return null;\n }\n}\n\nfunction matchesOverride(labelValue: string, pattern: string, isRegex: boolean): boolean {\n if (isRegex) {\n const re = getCompiledRegex(pattern);\n return re !== null && re.test(labelValue);\n }\n return labelValue === pattern;\n}\n\nexport function getLabelColor(value: string, mapping: LabelColorMapping): string {\n if (mapping.overrides) {\n for (const override of mapping.overrides) {\n if (matchesOverride(value, override.value, override.isRegex)) {\n return override.color;\n }\n }\n }\n\n switch (mapping.mode) {\n case 'severity':\n return SEVERITY_COLORS[value.toLowerCase()] ?? hashStringToColor(value);\n case 'auto':\n return hashStringToColor(value);\n case 'manual':\n return MANUAL_FALLBACK;\n }\n}\n"],"names":["SEVERITY_LEVEL_COLORS","critical","error","warning","info","debug","trace","unknown","other","SEVERITY_ABBREVIATIONS","SEVERITY_COLORS","level","abbrevs","Object","entries","color","abbrev","SEVERITY_ORDER","getSeverityWeight","value","normalized","toLowerCase","includes","idx","indexOf","length","MANUAL_FALLBACK","ERROR_HUE_CUTOFF","hashStringToColor","hash","i","charCodeAt","Math","abs","hue","saturation","lightness","MAX_REGEX_CACHE_SIZE","regexCache","Map","getCompiledRegex","pattern","has","get","size","clear","re","RegExp","set","matchesOverride","labelValue","isRegex","test","getLabelColor","mapping","overrides","override","mode"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,MAAMA,wBAAgD;IACpDC,UAAU;IACVC,OAAO;IACPC,SAAS;IACTC,MAAM;IACNC,OAAO;IACPC,OAAO;IACPC,SAAS;IACTC,OAAO;AACT;AAE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-colors.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { LabelColorMapping } from './alert-table-model';\n\nconst SEVERITY_LEVEL_COLORS: Record<string, string> = {\n critical: '#d32f2f',\n error: '#ef6c00',\n warning: '#f9a825',\n info: '#0288d1',\n debug: '#7b1fa2',\n trace: '#6a1b9a',\n unknown: '#757575',\n other: '#9e9e9e',\n};\n\nconst SEVERITY_ABBREVIATIONS: Record<string, string[]> = {\n critical: ['critical', 'crit', 'fatal', 'emerg', 'alert', 'page'],\n error: ['error', 'err', 'eror', 'high', 'severe'],\n warning: ['warning', 'warn', 'medium'],\n info: ['info', 'inf', 'information', 'informational', 'notice', 'low'],\n debug: ['debug', 'dbug'],\n trace: ['trace'],\n unknown: ['unknown'],\n other: ['other', 'none', 'minor', ''],\n};\n\nconst SEVERITY_COLORS: Record<string, string> = {};\nfor (const [level, abbrevs] of Object.entries(SEVERITY_ABBREVIATIONS)) {\n const color = SEVERITY_LEVEL_COLORS[level]!;\n for (const abbrev of abbrevs) {\n SEVERITY_COLORS[abbrev] = color;\n }\n}\n\nexport const SEVERITY_ORDER: string[] = ['critical', 'error', 'warning', 'info', 'debug', 'trace', 'unknown', 'other'];\n\nexport function getSeverityWeight(value: string): number {\n const normalized = value.toLowerCase();\n for (const [level, abbrevs] of Object.entries(SEVERITY_ABBREVIATIONS)) {\n if (abbrevs.includes(normalized)) {\n const idx = SEVERITY_ORDER.indexOf(level);\n return idx === -1 ? SEVERITY_ORDER.length : idx;\n }\n }\n return SEVERITY_ORDER.length;\n}\n\nconst MANUAL_FALLBACK = '#9e9e9e';\nconst ERROR_HUE_CUTOFF = 20;\n\nexport function hashStringToColor(value: string): string {\n let hash = 5381;\n for (let i = 0; i < value.length; i++) {\n hash = (hash * 33) ^ value.charCodeAt(i);\n }\n hash = Math.abs(hash);\n\n const hue = ERROR_HUE_CUTOFF + (hash % (360 - ERROR_HUE_CUTOFF));\n const saturation = 55 + (hash % 25);\n const lightness = 45 + (hash % 15);\n return `hsl(${hue}, ${saturation}%, ${lightness}%)`;\n}\n\nconst MAX_REGEX_CACHE_SIZE = 1000;\nconst regexCache = new Map<string, RegExp | null>();\n\nfunction getCompiledRegex(pattern: string): RegExp | null {\n if (regexCache.has(pattern)) return regexCache.get(pattern)!;\n if (regexCache.size >= MAX_REGEX_CACHE_SIZE) regexCache.clear();\n try {\n const re = new RegExp(pattern);\n regexCache.set(pattern, re);\n return re;\n } catch {\n regexCache.set(pattern, null);\n return null;\n }\n}\n\nfunction matchesOverride(labelValue: string, pattern: string, isRegex: boolean): boolean {\n if (isRegex) {\n const re = getCompiledRegex(pattern);\n return re !== null && re.test(labelValue);\n }\n return labelValue === pattern;\n}\n\nexport function getLabelColor(value: string, mapping: LabelColorMapping): string {\n if (mapping.overrides) {\n for (const override of mapping.overrides) {\n if (matchesOverride(value, override.value, override.isRegex)) {\n return override.color;\n }\n }\n }\n\n switch (mapping.mode) {\n case 'severity':\n return SEVERITY_COLORS[value.toLowerCase()] ?? hashStringToColor(value);\n case 'auto':\n return hashStringToColor(value);\n case 'manual':\n return MANUAL_FALLBACK;\n }\n}\n"],"names":["SEVERITY_LEVEL_COLORS","critical","error","warning","info","debug","trace","unknown","other","SEVERITY_ABBREVIATIONS","SEVERITY_COLORS","level","abbrevs","Object","entries","color","abbrev","SEVERITY_ORDER","getSeverityWeight","value","normalized","toLowerCase","includes","idx","indexOf","length","MANUAL_FALLBACK","ERROR_HUE_CUTOFF","hashStringToColor","hash","i","charCodeAt","Math","abs","hue","saturation","lightness","MAX_REGEX_CACHE_SIZE","regexCache","Map","getCompiledRegex","pattern","has","get","size","clear","re","RegExp","set","matchesOverride","labelValue","isRegex","test","getLabelColor","mapping","overrides","override","mode"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,MAAMA,wBAAgD;IACpDC,UAAU;IACVC,OAAO;IACPC,SAAS;IACTC,MAAM;IACNC,OAAO;IACPC,OAAO;IACPC,SAAS;IACTC,OAAO;AACT;AAEA,MAAMC,yBAAmD;IACvDR,UAAU;QAAC;QAAY;QAAQ;QAAS;QAAS;QAAS;KAAO;IACjEC,OAAO;QAAC;QAAS;QAAO;QAAQ;QAAQ;KAAS;IACjDC,SAAS;QAAC;QAAW;QAAQ;KAAS;IACtCC,MAAM;QAAC;QAAQ;QAAO;QAAe;QAAiB;QAAU;KAAM;IACtEC,OAAO;QAAC;QAAS;KAAO;IACxBC,OAAO;QAAC;KAAQ;IAChBC,SAAS;QAAC;KAAU;IACpBC,OAAO;QAAC;QAAS;QAAQ;QAAS;KAAG;AACvC;AAEA,MAAME,kBAA0C,CAAC;AACjD,KAAK,MAAM,CAACC,OAAOC,QAAQ,IAAIC,OAAOC,OAAO,CAACL,wBAAyB;IACrE,MAAMM,QAAQf,qBAAqB,CAACW,MAAM;IAC1C,KAAK,MAAMK,UAAUJ,QAAS;QAC5BF,eAAe,CAACM,OAAO,GAAGD;IAC5B;AACF;AAEA,OAAO,MAAME,iBAA2B;IAAC;IAAY;IAAS;IAAW;IAAQ;IAAS;IAAS;IAAW;CAAQ,CAAC;AAEvH,OAAO,SAASC,kBAAkBC,KAAa;IAC7C,MAAMC,aAAaD,MAAME,WAAW;IACpC,KAAK,MAAM,CAACV,OAAOC,QAAQ,IAAIC,OAAOC,OAAO,CAACL,wBAAyB;QACrE,IAAIG,QAAQU,QAAQ,CAACF,aAAa;YA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AE;QACrB,KAAK,MAAMC,YAAYF,QAAQC,SAAS,CAAE;YACxC,IAAIN,gBAAgB9B,OAAOqC,SAASrC,KAAK,EAAEqC,SAASL,OAAO,GAAG;gBAC5D,OAAOK,SAASzC,KAAK;YACvB;QACF;IACF;IAEA,OAAQuC,QAAQG,IAAI;QAClB,KAAK;YACH,OAAO/C,eAAe,CAACS,MAAME,WAAW,GAAG,IAAIO,kBAAkBT;QACnE,KAAK;YACH,OAAOS,kBAAkBT;QAC3B,KAAK;YACH,OAAOO;IACX;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlertsQueryPlugin } from '@perses-dev/plugin-system';
|
|
2
|
-
import { AlertManagerAlertsQuerySpec } from '../types';
|
|
1
|
+
import type { AlertsQueryPlugin } from '@perses-dev/plugin-system';
|
|
2
|
+
import type { AlertManagerAlertsQuerySpec } from '../types';
|
|
3
3
|
export declare const AlertManagerAlertsQuery: AlertsQueryPlugin<AlertManagerAlertsQuerySpec>;
|
|
4
4
|
//# sourceMappingURL=AlertManagerAlertsQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlertManagerAlertsQuery.d.ts","sourceRoot":"","sources":["../../../../src/plugins/alertmanager-alerts-query/AlertManagerAlertsQuery.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"AlertManagerAlertsQuery.d.ts","sourceRoot":"","sources":["../../../../src/plugins/alertmanager-alerts-query/AlertManagerAlertsQuery.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAGnE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAI5D,eAAO,MAAM,uBAAuB,EAAE,iBAAiB,CAAC,2BAA2B,CAmBlF,CAAC"}
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { isVariableDatasource, parseVariables } from
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
13
|
+
import { isVariableDatasource, parseVariables } from "@perses-dev/plugin-system";
|
|
14
|
+
import { AlertManagerAlertsQueryEditor } from "./AlertManagerAlertsQueryEditor.js";
|
|
15
|
+
import { getAlertsData } from "./get-alerts-data.js";
|
|
16
16
|
export const AlertManagerAlertsQuery = {
|
|
17
17
|
getAlertsData,
|
|
18
18
|
OptionsEditorComponent: AlertManagerAlertsQueryEditor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/alertmanager-alerts-query/AlertManagerAlertsQuery.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { AlertsQueryPlugin
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/alertmanager-alerts-query/AlertManagerAlertsQuery.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { AlertsQueryPlugin } from '@perses-dev/plugin-system';\nimport { isVariableDatasource, parseVariables } from '@perses-dev/plugin-system';\n\nimport type { AlertManagerAlertsQuerySpec } from '../types';\nimport { AlertManagerAlertsQueryEditor } from './AlertManagerAlertsQueryEditor';\nimport { getAlertsData } from './get-alerts-data';\n\nexport const AlertManagerAlertsQuery: AlertsQueryPlugin<AlertManagerAlertsQuerySpec> = {\n getAlertsData,\n OptionsEditorComponent: AlertManagerAlertsQueryEditor,\n createInitialOptions: (): AlertManagerAlertsQuerySpec => ({\n datasource: undefined,\n filters: [],\n active: true,\n silenced: false,\n inhibited: false,\n receiver: undefined,\n }),\n dependsOn: (spec: AlertManagerAlertsQuerySpec) => {\n const datasourceVariables = isVariableDatasource(spec.datasource) ? parseVariables(spec.datasource ?? '') : [];\n const filterVariables = spec.filters?.flatMap((f) => parseVariables(f)) ?? [];\n const receiverVariables = spec.receiver ? parseVariables(spec.receiver) : [];\n return {\n variables: [...new Set([...datasourceVariables, ...filterVariables, ...receiverVariables])],\n };\n },\n};\n"],"names":["isVariableDatasource","parseVariables","AlertManagerAlertsQueryEditor","getAlertsData","AlertManagerAlertsQuery","OptionsEditorComponent","createInitialOptions","datasource","undefined","filters","active","silenced","inhibited","receiver","dependsOn","spec","datasourceVariables","filterVariables","flatMap","f","receiverVariables","variables","Set"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,oBAAoB,EAAEC,cAAc,QAAQ,4BAA4B;AAGjF,SAASC,6BAA6B,QAAQ,qCAAkC;AAChF,SAASC,aAAa,QAAQ,uBAAoB;AAElD,OAAO,MAAMC,0BAA0E;IACrFD;IACAE,wBAAwBH;IACxBI,sBAAsB,IAAoC,CAAA;YACxDC,YAAYC;YACZC,SAAS,EAAE;YACXC,QAAQ;YACRC,UAAU;YACVC,WAAW;YACXC,UAAUL;QACZ,CAAA;IACAM,WAAW,CAACC;QACV,MAAMC,sBAAsBhB,qBAAqBe,KAAKR,UAAU,IAAIN,eAAec,KAAKR,UAAU,IAAI,MAAM,EAAE;QAC9G,MAAMU,kBAAkBF,KAAKN,OAAO,EAAES,QAAQ,CAACC,IAAMlB,eAAekB,OAAO,EAAE;QAC7E,MAAMC,oBAAoBL,KAAKF,QAAQ,GAAGZ,eAAec,KAAKF,QAAQ,IAAI,EAAE;QAC5E,OAAO;YACLQ,WAAW;mBAAI,IAAIC,IAAI;uBAAIN;uBAAwBC;uBAAoBG;iBAAkB;aAAE;QAC7F;IACF;AACF,EAAE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { AlertManagerAlertsQuerySpec } from '../types';
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { AlertManagerAlertsQuerySpec } from '../types';
|
|
3
3
|
interface AlertManagerAlertsQueryEditorProps {
|
|
4
4
|
value: AlertManagerAlertsQuerySpec;
|
|
5
5
|
onChange: (next: AlertManagerAlertsQuerySpec) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlertManagerAlertsQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/plugins/alertmanager-alerts-query/AlertManagerAlertsQueryEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AlertManagerAlertsQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/plugins/alertmanager-alerts-query/AlertManagerAlertsQueryEditor.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAU1C,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAE5D,UAAU,kCAAkC;IAC1C,KAAK,EAAE,2BAA2B,CAAC;IACnC,QAAQ,EAAE,CAAC,IAAI,EAAE,2BAA2B,KAAK,IAAI,CAAC;CACvD;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,kCAAkC,GAAG,YAAY,CAyHrG"}
|
|
@@ -11,13 +11,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { Checkbox, FormControl, FormControlLabel, Stack } from
|
|
15
|
-
import { useId } from
|
|
16
|
-
import { DatasourceSelect } from
|
|
17
|
-
import { produce } from
|
|
18
|
-
import { useCallback } from
|
|
19
|
-
import { LazyTextField } from
|
|
20
|
-
import { ALERTMANAGER_DATASOURCE_KIND, DEFAULT_ALERTMANAGER, isAlertManagerDatasourceSelector, isDefaultAlertManagerSelector } from
|
|
14
|
+
import { Checkbox, FormControl, FormControlLabel, Stack } from "@mui/material";
|
|
15
|
+
import { useId } from "@perses-dev/components";
|
|
16
|
+
import { DatasourceSelect } from "@perses-dev/plugin-system";
|
|
17
|
+
import { produce } from "immer";
|
|
18
|
+
import { useCallback } from "react";
|
|
19
|
+
import { LazyTextField } from "../../components/LazyTextField.js";
|
|
20
|
+
import { ALERTMANAGER_DATASOURCE_KIND, DEFAULT_ALERTMANAGER, isAlertManagerDatasourceSelector, isDefaultAlertManagerSelector } from "../../model/index.js";
|
|
21
21
|
export function AlertManagerAlertsQueryEditor(props) {
|
|
22
22
|
const { onChange, value } = props;
|
|
23
23
|
const datasourceSelectValue = value.datasource ?? DEFAULT_ALERTMANAGER;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/alertmanager-alerts-query/AlertManagerAlertsQueryEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Checkbox, FormControl, FormControlLabel, Stack } from '@mui/material';\nimport { useId } from '@perses-dev/components';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/alertmanager-alerts-query/AlertManagerAlertsQueryEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Checkbox, FormControl, FormControlLabel, Stack } from '@mui/material';\nimport { useId } from '@perses-dev/components';\nimport type { DatasourceSelectProps } from '@perses-dev/plugin-system';\nimport { DatasourceSelect } from '@perses-dev/plugin-system';\nimport { produce } from 'immer';\nimport type { ReactElement } from 'react';\nimport { useCallback } from 'react';\n\nimport { LazyTextField } from '../../components/LazyTextField';\nimport {\n ALERTMANAGER_DATASOURCE_KIND,\n DEFAULT_ALERTMANAGER,\n isAlertManagerDatasourceSelector,\n isDefaultAlertManagerSelector,\n} from '../../model';\nimport type { AlertManagerAlertsQuerySpec } from '../types';\n\ninterface AlertManagerAlertsQueryEditorProps {\n value: AlertManagerAlertsQuerySpec;\n onChange: (next: AlertManagerAlertsQuerySpec) => void;\n}\n\nexport function AlertManagerAlertsQueryEditor(props: AlertManagerAlertsQueryEditorProps): ReactElement {\n const { onChange, value } = props;\n const datasourceSelectValue = value.datasource ?? DEFAULT_ALERTMANAGER;\n const datasourceSelectLabelID = useId('alertmanager-datasource-label');\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (next) => {\n if (isAlertManagerDatasourceSelector(next)) {\n onChange(\n produce(value, (draft) => {\n draft.datasource = isDefaultAlertManagerSelector(next) ? undefined : next;\n }),\n );\n return;\n }\n\n throw new Error('Got unexpected non-AlertManager datasource selector');\n };\n\n const handleFiltersChange = useCallback(\n (filtersText: string): void => {\n onChange(\n produce(value, (draft) => {\n draft.filters = filtersText\n .split('\\n')\n .map((f) => f.trim())\n .filter((f) => f !== '');\n }),\n );\n },\n [onChange, value],\n );\n\n const handleBooleanChange = useCallback(\n (field: 'active' | 'silenced' | 'inhibited' | 'unprocessed', checked: boolean): void => {\n onChange(\n produce(value, (draft) => {\n draft[field] = checked;\n }),\n );\n },\n [onChange, value],\n );\n\n const handleReceiverChange = useCallback(\n (receiver: string): void => {\n onChange(\n produce(value, (draft) => {\n draft.receiver = receiver.trim() === '' ? undefined : receiver.trim();\n }),\n );\n },\n [onChange, value],\n );\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\" fullWidth={false}>\n <DatasourceSelect\n datasourcePluginKind={ALERTMANAGER_DATASOURCE_KIND}\n value={datasourceSelectValue}\n onChange={handleDatasourceChange}\n labelId={datasourceSelectLabelID}\n label=\"Alert Manager Datasource\"\n notched\n />\n </FormControl>\n <Stack direction=\"row\" spacing={2} sx={{ flexWrap: 'wrap', rowGap: 1 }}>\n <FormControlLabel\n control={\n <Checkbox\n checked={value.active ?? true}\n onChange={(e) => handleBooleanChange('active', e.target.checked)}\n />\n }\n label=\"Active\"\n />\n <FormControlLabel\n control={\n <Checkbox\n checked={value.silenced ?? false}\n onChange={(e) => handleBooleanChange('silenced', e.target.checked)}\n />\n }\n label=\"Silenced\"\n />\n <FormControlLabel\n control={\n <Checkbox\n checked={value.inhibited ?? false}\n onChange={(e) => handleBooleanChange('inhibited', e.target.checked)}\n />\n }\n label=\"Inhibited\"\n />\n <FormControlLabel\n control={\n <Checkbox\n checked={value.unprocessed ?? false}\n onChange={(e) => handleBooleanChange('unprocessed', e.target.checked)}\n />\n }\n label=\"Unprocessed\"\n />\n </Stack>\n <LazyTextField\n label=\"Receiver\"\n value={value.receiver}\n onCommit={handleReceiverChange}\n placeholder=\"e.g. team-a\"\n />\n <LazyTextField\n label=\"Filters (one per line)\"\n value={(value.filters ?? []).join('\\n')}\n onCommit={handleFiltersChange}\n placeholder={'alertname=\"HighMemory\"\\nseverity=\"critical\"\\nenvironment=~\"${env:pipe}\"'}\n helperText=\"PromQL-style matchers, one per line.\"\n multiline\n minRows={3}\n />\n </Stack>\n );\n}\n"],"names":["Checkbox","FormControl","FormControlLabel","Stack","useId","DatasourceSelect","produce","useCallback","LazyTextField","ALERTMANAGER_DATASOURCE_KIND","DEFAULT_ALERTMANAGER","isAlertManagerDatasourceSelector","isDefaultAlertManagerSelector","AlertManagerAlertsQueryEditor","props","onChange","value","datasourceSelectValue","datasource","datasourceSelectLabelID","handleDatasourceChange","next","draft","undefined","Error","handleFiltersChange","filtersText","filters","split","map","f","trim","filter","handleBooleanChange","field","checked","handleReceiverChange","receiver","spacing","margin","fullWidth","datasourcePluginKind","labelId","label","notched","direction","sx","flexWrap","rowGap","control","active","e","target","silenced","inhibited","unprocessed","onCommit","placeholder","join","helperText","multiline","minRows"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,QAAQ,EAAEC,WAAW,EAAEC,gBAAgB,EAAEC,KAAK,QAAQ,gBAAgB;AAC/E,SAASC,KAAK,QAAQ,yBAAyB;AAE/C,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,OAAO,QAAQ,QAAQ;AAEhC,SAASC,WAAW,QAAQ,QAAQ;AAEpC,SAASC,aAAa,QAAQ,oCAAiC;AAC/D,SACEC,4BAA4B,EAC5BC,oBAAoB,EACpBC,gCAAgC,EAChCC,6BAA6B,QACxB,uBAAc;AAQrB,OAAO,SAASC,8BAA8BC,KAAyC;IACrF,MAA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C,MAAM,IAAI;4BACzBnC,UAAU,CAACoC,IAAMlB,oBAAoB,UAAUkB,EAAEC,MAAM,CAACjB,OAAO;;wBAGnEQ,OAAM;;kCAER,KAACzC;wBACC+C,uBACE,KAACjD;4BACCmC,SAASnB,MAAMqC,QAAQ,IAAI;4BAC3BtC,UAAU,CAACoC,IAAMlB,oBAAoB,YAAYkB,EAAEC,MAAM,CAACjB,OAAO;;wBAGrEQ,OAAM;;kCAER,KAACzC;wBACC+C,uBACE,KAACjD;4BACCmC,SAASnB,MAAMsC,SAAS,IAAI;4BAC5BvC,UAAU,CAACoC,IAAMlB,oBAAoB,aAAakB,EAAEC,MAAM,CAACjB,OAAO;;wBAGtEQ,OAAM;;kCAER,KAACzC;wBACC+C,uBACE,KAACjD;4BACCmC,SAASnB,MAAMuC,WAAW,IAAI;4BAC9BxC,UAAU,CAACoC,IAAMlB,oBAAoB,eAAekB,EAAEC,MAAM,CAACjB,OAAO;;wBAGxEQ,OAAM;;;;0BAGV,KAACnC;gBACCmC,OAAM;gBACN3B,OAAOA,MAAMqB,QAAQ;gBACrBmB,UAAUpB;gBACVqB,aAAY;;0BAEd,KAACjD;gBACCmC,OAAM;gBACN3B,OAAO,AAACA,CAAAA,MAAMW,OAAO,IAAI,EAAE,AAAD,EAAG+B,IAAI,CAAC;gBAClCF,UAAU/B;gBACVgC,aAAa;gBACbE,YAAW;gBACXC,SAAS;gBACTC,SAAS;;;;AAIjB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AlertsQueryContext } from '@perses-dev/plugin-system';
|
|
2
|
-
import { AlertsData } from '@perses-dev/spec';
|
|
3
|
-
import { AlertManagerAlertsQuerySpec } from '../types';
|
|
1
|
+
import type { AlertsQueryContext } from '@perses-dev/plugin-system';
|
|
2
|
+
import type { AlertsData } from '@perses-dev/spec';
|
|
3
|
+
import type { AlertManagerAlertsQuerySpec } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Get alerts data from Alert Manager, transforming the API response into the plugin-system AlertsData format.
|
|
6
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-alerts-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/alertmanager-alerts-query/get-alerts-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"get-alerts-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/alertmanager-alerts-query/get-alerts-data.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,KAAK,EAAqB,UAAU,EAAmB,MAAM,kBAAkB,CAAC;AAIvF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AA0E5D;;GAEG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,2BAA2B,EACjC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,UAAU,CAAC,CA4BrB"}
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { datasourceSelectValueToSelector, replaceVariables } from
|
|
14
|
-
import { ALERTMANAGER_DATASOURCE_KIND, DEFAULT_ALERTMANAGER } from
|
|
13
|
+
import { datasourceSelectValueToSelector, replaceVariables } from "@perses-dev/plugin-system";
|
|
14
|
+
import { ALERTMANAGER_DATASOURCE_KIND, DEFAULT_ALERTMANAGER } from "../../model/index.js";
|
|
15
15
|
/**
|
|
16
16
|
* Map Alertmanager API alert state to the generic AlertState.
|
|
17
17
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/alertmanager-alerts-query/get-alerts-data.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { AlertsQueryContext
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/alertmanager-alerts-query/get-alerts-data.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { AlertsQueryContext } from '@perses-dev/plugin-system';\nimport { datasourceSelectValueToSelector, replaceVariables } from '@perses-dev/plugin-system';\nimport type { Alert, AlertState, AlertsData, SuppressionRule } from '@perses-dev/spec';\n\nimport type { AlertManagerClient, GettableAlert } from '../../model';\nimport { ALERTMANAGER_DATASOURCE_KIND, DEFAULT_ALERTMANAGER } from '../../model';\nimport type { AlertManagerAlertsQuerySpec } from '../types';\n\n/**\n * Map Alertmanager API alert state to the generic AlertState.\n *\n * AM `active` → generic `firing`\n * AM `suppressed` → generic `firing` (with `suppressed: true`)\n * AM `unprocessed` → generic `pending`\n */\nfunction mapAlertState(amState: 'unprocessed' | 'active' | 'suppressed'): AlertState {\n switch (amState) {\n case 'active':\n case 'suppressed':\n return 'firing';\n case 'unprocessed':\n return 'pending';\n }\n}\n\n/**\n * Build SuppressionRule entries from the Alertmanager status fields.\n */\nfunction buildSuppressionRules(status: GettableAlert['status']): SuppressionRule[] {\n const rules: SuppressionRule[] = [];\n for (const id of status.silencedBy) {\n rules.push({ type: 'silence', id });\n }\n for (const id of status.inhibitedBy) {\n rules.push({ type: 'inhibition', id });\n }\n for (const id of status.mutedBy) {\n rules.push({ type: 'mute', id });\n }\n return rules;\n}\n\n/**\n * Transform a GettableAlert from the Alertmanager API into our normalized Alert format.\n */\nfunction transformAlert(apiAlert: GettableAlert): Alert {\n const isSuppressed = apiAlert.status.state === 'suppressed';\n const suppressionRules = buildSuppressionRules(apiAlert.status);\n\n const alert: Alert = {\n id: apiAlert.fingerprint,\n name: apiAlert.labels['alertname'] ?? '',\n state: mapAlertState(apiAlert.status.state),\n labels: apiAlert.labels,\n annotations: apiAlert.annotations,\n startsAt: apiAlert.startsAt,\n endsAt: apiAlert.endsAt,\n updatedAt: apiAlert.updatedAt,\n receivers: apiAlert.receivers.map((r) => r.name),\n };\n\n if (apiAlert.labels['severity']) {\n alert.severity = apiAlert.labels['severity'];\n }\n\n if (apiAlert.generatorURL) {\n alert.sourceURL = apiAlert.generatorURL;\n }\n\n if (isSuppressed) {\n alert.suppressed = true;\n }\n\n if (suppressionRules.length > 0) {\n alert.suppressedBy = suppressionRules;\n }\n\n return alert;\n}\n\n/**\n * Get alerts data from Alert Manager, transforming the API response into the plugin-system AlertsData format.\n */\nexport async function getAlertsData(\n spec: AlertManagerAlertsQuerySpec,\n context: AlertsQueryContext,\n): Promise<AlertsData> {\n const listDatasourceSelectItems =\n await context.datasourceStore.listDatasourceSelectItems(ALERTMANAGER_DATASOURCE_KIND);\n const datasourceSelector =\n datasourceSelectValueToSelector(spec.datasource, context.variableState, listDatasourceSelectItems) ??\n DEFAULT_ALERTMANAGER;\n const client = await context.datasourceStore.getDatasourceClient<AlertManagerClient>(datasourceSelector);\n\n const interpolatedFilters = spec.filters?.map((f) => replaceVariables(f, context.variableState));\n const interpolatedReceiver = spec.receiver ? replaceVariables(spec.receiver, context.variableState) : undefined;\n\n const apiAlerts = await client.getAlerts({\n filter: interpolatedFilters,\n active: spec.active,\n silenced: spec.silenced,\n inhibited: spec.inhibited,\n unprocessed: spec.unprocessed,\n receiver: interpolatedReceiver,\n });\n\n const alerts = apiAlerts.map(transformAlert);\n\n return {\n alerts,\n metadata: {\n executedQueryString: buildQueryString(spec),\n },\n };\n}\n\nfunction buildQueryString(spec: AlertManagerAlertsQuerySpec): string {\n return JSON.stringify(\n Object.fromEntries(\n Object.entries({\n filters: spec.filters,\n active: spec.active,\n silenced: spec.silenced,\n inhibited: spec.inhibited,\n receiver: spec.receiver,\n }).filter(([, value]) => value !== undefined),\n ),\n );\n}\n"],"names":["datasourceSelectValueToSelector","replaceVariables","ALERTMANAGER_DATASOURCE_KIND","DEFAULT_ALERTMANAGER","mapAlertState","amState","buildSuppressionRules","status","rules","id","silencedBy","push","type","inhibitedBy","mutedBy","transformAlert","apiAlert","isSuppressed","state","suppressionRules","alert","fingerprint","name","labels","annotations","startsAt","endsAt","updatedAt","receivers","map","r","severity","generatorURL","sourceURL","suppressed","length","suppressedBy","getAlertsData","spec","context","listDatasourceSelectItems","datasourceStore","datasourceSelector","datasource","variableState","client","getDatasourceClient","interpolatedFilters","filters","f","interpolatedReceiver","receiver","undefined","apiAlerts","getAlerts","filter","active","silenced","inhibited","unprocessed","alerts","metadata","executedQueryString","buildQueryString","JSON","stringify","Object","fromEntries","entries","value"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,+BAA+B,EAAEC,gBAAgB,QAAQ,4BAA4B;AAI9F,SAASC,4BAA4B,EAAEC,oBAAoB,QAAQ,uBAAc;AAGjF;;;;;;CAMC,GACD,SAASC,cAAcC,OAAgD;IACrE,OAAQA;QACN,KAAK;QACL,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;IACX;AACF;AAEA;;CAEC,GACD,SAASC,sBAAsBC,MAA+B;IAC5D,MAAMC,QAA2B,EAAE;IACnC,KAAK,MAAM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QE,eAAe,CAACD,yBAAyB,CAACtC;IAC1D,MAAMwC,qBACJ1C,gCAAgCsC,KAAKK,UAAU,EAAEJ,QAAQK,aAAa,EAAEJ,8BACxErC;IACF,MAAM0C,SAAS,MAAMN,QAAQE,eAAe,CAACK,mBAAmB,CAAqBJ;IAErF,MAAMK,sBAAsBT,KAAKU,OAAO,EAAEnB,IAAI,CAACoB,IAAMhD,iBAAiBgD,GAAGV,QAAQK,aAAa;IAC9F,MAAMM,uBAAuBZ,KAAKa,QAAQ,GAAGlD,iBAAiBqC,KAAKa,QAAQ,EAAEZ,QAAQK,aAAa,IAAIQ;IAEtG,MAAMC,YAAY,MAAMR,OAAOS,SAAS,CAAC;QACvCC,QAAQR;QACRS,QAAQlB,KAAKkB,MAAM;QACnBC,UAAUnB,KAAKmB,QAAQ;QACvBC,WAAWpB,KAAKoB,SAAS;QACzBC,aAAarB,KAAKqB,WAAW;QAC7BR,UAAUD;IACZ;IAEA,MAAMU,SAASP,UAAUxB,GAAG,CAACd;IAE7B,OAAO;QACL6C;QACAC,UAAU;YACRC,qBAAqBC,iBAAiBzB;QACxC;IACF;AACF;AAEA,SAASyB,iBAAiBzB,IAAiC;IACzD,OAAO0B,KAAKC,SAAS,CACnBC,OAAOC,WAAW,CAChBD,OAAOE,OAAO,CAAC;QACbpB,SAASV,KAAKU,OAAO;QACrBQ,QAAQlB,KAAKkB,MAAM;QACnBC,UAAUnB,KAAKmB,QAAQ;QACvBC,WAAWpB,KAAKoB,SAAS;QACzBP,UAAUb,KAAKa,QAAQ;IACzB,GAAGI,MAAM,CAAC,CAAC,GAAGc,MAAM,GAAKA,UAAUjB;AAGzC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DatasourcePlugin } from '@perses-dev/plugin-system';
|
|
2
|
-
import { AlertManagerClient } from '../model';
|
|
3
|
-
import { AlertManagerDatasourceSpec } from './types';
|
|
1
|
+
import type { DatasourcePlugin } from '@perses-dev/plugin-system';
|
|
2
|
+
import type { AlertManagerClient } from '../model';
|
|
3
|
+
import type { AlertManagerDatasourceSpec } from './types';
|
|
4
4
|
export declare const AlertManagerDatasource: DatasourcePlugin<AlertManagerDatasourceSpec, AlertManagerClient>;
|
|
5
5
|
//# sourceMappingURL=alertmanager-datasource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alertmanager-datasource.d.ts","sourceRoot":"","sources":["../../../src/plugins/alertmanager-datasource.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"alertmanager-datasource.d.ts","sourceRoot":"","sources":["../../../src/plugins/alertmanager-datasource.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AA6B1D,eAAO,MAAM,sBAAsB,EAAE,gBAAgB,CAAC,0BAA0B,EAAE,kBAAkB,CAInG,CAAC"}
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { getAlerts, getSilences, getSilence, createSilence, deleteSilence, getStatus } from
|
|
14
|
-
import { AlertManagerDatasourceEditor } from
|
|
13
|
+
import { getAlerts, getSilences, getSilence, createSilence, deleteSilence, getStatus } from "../model/index.js";
|
|
14
|
+
import { AlertManagerDatasourceEditor } from "./AlertManagerDatasourceEditor.js";
|
|
15
15
|
const createClient = (spec, options)=>{
|
|
16
16
|
const { directUrl, proxy } = spec;
|
|
17
17
|
const { proxyUrl } = options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/alertmanager-datasource.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourcePlugin } from '@perses-dev/plugin-system';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/alertmanager-datasource.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { DatasourcePlugin } from '@perses-dev/plugin-system';\n\nimport type { AlertManagerClient } from '../model';\nimport { getAlerts, getSilences, getSilence, createSilence, deleteSilence, getStatus } from '../model';\nimport { AlertManagerDatasourceEditor } from './AlertManagerDatasourceEditor';\nimport type { AlertManagerDatasourceSpec } from './types';\n\nconst createClient: DatasourcePlugin<AlertManagerDatasourceSpec, AlertManagerClient>['createClient'] = (\n spec,\n options,\n) => {\n const { directUrl, proxy } = spec;\n const { proxyUrl } = options;\n\n const datasourceUrl = directUrl ?? proxyUrl;\n if (datasourceUrl === undefined) {\n throw new Error('No URL specified for Alert Manager client. You can use directUrl in the spec to configure it.');\n }\n\n const specHeaders = proxy?.spec.headers;\n\n return {\n options: {\n datasourceUrl,\n },\n getAlerts: (params, headers) => getAlerts(params, { datasourceUrl, headers: headers ?? specHeaders }),\n getSilences: (params, headers) => getSilences(params, { datasourceUrl, headers: headers ?? specHeaders }),\n getSilence: (id, headers) => getSilence(id, { datasourceUrl, headers: headers ?? specHeaders }),\n createSilence: (silence, headers) => createSilence(silence, { datasourceUrl, headers: headers ?? specHeaders }),\n deleteSilence: (id, headers) => deleteSilence(id, { datasourceUrl, headers: headers ?? specHeaders }),\n getStatus: (headers) => getStatus({ datasourceUrl, headers: headers ?? specHeaders }),\n };\n};\n\nexport const AlertManagerDatasource: DatasourcePlugin<AlertManagerDatasourceSpec, AlertManagerClient> = {\n createClient,\n OptionsEditorComponent: AlertManagerDatasourceEditor,\n createInitialOptions: () => ({ directUrl: '' }),\n};\n"],"names":["getAlerts","getSilences","getSilence","createSilence","deleteSilence","getStatus","AlertManagerDatasourceEditor","createClient","spec","options","directUrl","proxy","proxyUrl","datasourceUrl","undefined","Error","specHeaders","headers","params","id","silence","AlertManagerDatasource","OptionsEditorComponent","createInitialOptions"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAKjC,SAASA,SAAS,EAAEC,WAAW,EAAEC,UAAU,EAAEC,aAAa,EAAEC,aAAa,EAAEC,SAAS,QAAQ,oBAAW;AACvG,SAASC,4BAA4B,QAAQ,oCAAiC;AAG9E,MAAMC,eAAiG,CACrGC,MACAC;IAEA,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGH;IAC7B,MAAM,EAAEI,QAAQ,EAAE,GAAGH;IAErB,MAAMI,gBAAgBH,aAAaE;IACnC,IAAIC,kBAAkBC,WAAW;QAC/B,MAAM,IAAIC,MAAM;IAClB;IAEA,MAAMC,cAAcL,OAAOH,KAAKS;IAEhC,OAAO;QACLR,SAAS;YACPI;QACF;QACAb,WAAW,CAACkB,QAAQD,UAAYjB,UAAUkB,QAAQ;gBAAEL;gBAAeI,SAASA,WAAWD;YAAY;QACnGf,aAAa,CAACiB,QAAQD,UAAYhB,YAAYiB,QAAQ;gBAAEL;gBAAeI,SAASA,WAAWD;YAAY;QACvGd,YAAY,CAACiB,IAAIF,UAAYf,WAAWiB,IAAI;gBAAEN;gBAAeI,SAASA,WAAWD;YAAY;QAC7Fb,eAAe,CAACiB,SAASH,UAAYd,cAAciB,SAAS;gBAAEP;gBAAeI,SAASA,WAAWD;YAAY;QAC7GZ,eAAe,CAACe,IAAIF,UAAYb,cAAce,IAAI;gBAAEN;gBAAeI,SAASA,WAAWD;YAAY;QACnGX,WAAW,CAACY,UAAYZ,UAAU;gBAAEQ;gBAAeI,SAASA,WAAWD;YAAY;IACrF;AACF;AAEA,OAAO,MAAMK,yBAA2F;IACtGd;IACAe,wBAAwBhB;IACxBiB,sBAAsB,IAAO,CAAA;YAAEb,WAAW;QAAG,CAAA;AAC/C,EAAE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SilencesQueryPlugin } from '@perses-dev/plugin-system';
|
|
2
|
-
import { AlertManagerSilencesQuerySpec } from '../types';
|
|
1
|
+
import type { SilencesQueryPlugin } from '@perses-dev/plugin-system';
|
|
2
|
+
import type { AlertManagerSilencesQuerySpec } from '../types';
|
|
3
3
|
export declare const AlertManagerSilencesQuery: SilencesQueryPlugin<AlertManagerSilencesQuerySpec>;
|
|
4
4
|
//# sourceMappingURL=AlertManagerSilencesQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlertManagerSilencesQuery.d.ts","sourceRoot":"","sources":["../../../../src/plugins/alertmanager-silences-query/AlertManagerSilencesQuery.ts"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"AlertManagerSilencesQuery.d.ts","sourceRoot":"","sources":["../../../../src/plugins/alertmanager-silences-query/AlertManagerSilencesQuery.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAGrE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAI9D,eAAO,MAAM,yBAAyB,EAAE,mBAAmB,CAAC,6BAA6B,CAcxF,CAAC"}
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { isVariableDatasource, parseVariables } from
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
13
|
+
import { isVariableDatasource, parseVariables } from "@perses-dev/plugin-system";
|
|
14
|
+
import { AlertManagerSilencesQueryEditor } from "./AlertManagerSilencesQueryEditor.js";
|
|
15
|
+
import { getSilencesData } from "./get-silences-data.js";
|
|
16
16
|
export const AlertManagerSilencesQuery = {
|
|
17
17
|
getSilencesData,
|
|
18
18
|
OptionsEditorComponent: AlertManagerSilencesQueryEditor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/alertmanager-silences-query/AlertManagerSilencesQuery.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { isVariableDatasource, parseVariables
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/alertmanager-silences-query/AlertManagerSilencesQuery.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { SilencesQueryPlugin } from '@perses-dev/plugin-system';\nimport { isVariableDatasource, parseVariables } from '@perses-dev/plugin-system';\n\nimport type { AlertManagerSilencesQuerySpec } from '../types';\nimport { AlertManagerSilencesQueryEditor } from './AlertManagerSilencesQueryEditor';\nimport { getSilencesData } from './get-silences-data';\n\nexport const AlertManagerSilencesQuery: SilencesQueryPlugin<AlertManagerSilencesQuerySpec> = {\n getSilencesData,\n OptionsEditorComponent: AlertManagerSilencesQueryEditor,\n createInitialOptions: (): AlertManagerSilencesQuerySpec => ({\n datasource: undefined,\n filters: [],\n }),\n dependsOn: (spec: AlertManagerSilencesQuerySpec) => {\n const datasourceVariables = isVariableDatasource(spec.datasource) ? parseVariables(spec.datasource ?? '') : [];\n const filterVariables = spec.filters?.flatMap((f) => parseVariables(f)) ?? [];\n return {\n variables: [...new Set([...datasourceVariables, ...filterVariables])],\n };\n },\n};\n"],"names":["isVariableDatasource","parseVariables","AlertManagerSilencesQueryEditor","getSilencesData","AlertManagerSilencesQuery","OptionsEditorComponent","createInitialOptions","datasource","undefined","filters","dependsOn","spec","datasourceVariables","filterVariables","flatMap","f","variables","Set"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,oBAAoB,EAAEC,cAAc,QAAQ,4BAA4B;AAGjF,SAASC,+BAA+B,QAAQ,uCAAoC;AACpF,SAASC,eAAe,QAAQ,yBAAsB;AAEtD,OAAO,MAAMC,4BAAgF;IAC3FD;IACAE,wBAAwBH;IACxBI,sBAAsB,IAAsC,CAAA;YAC1DC,YAAYC;YACZC,SAAS,EAAE;QACb,CAAA;IACAC,WAAW,CAACC;QACV,MAAMC,sBAAsBZ,qBAAqBW,KAAKJ,UAAU,IAAIN,eAAeU,KAAKJ,UAAU,IAAI,MAAM,EAAE;QAC9G,MAAMM,kBAAkBF,KAAKF,OAAO,EAAEK,QAAQ,CAACC,IAAMd,eAAec,OAAO,EAAE;QAC7E,OAAO;YACLC,WAAW;mBAAI,IAAIC,IAAI;uBAAIL;uBAAwBC;iBAAgB;aAAE;QACvE;IACF;AACF,EAAE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { AlertManagerSilencesQuerySpec } from '../types';
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { AlertManagerSilencesQuerySpec } from '../types';
|
|
3
3
|
interface AlertManagerSilencesQueryEditorProps {
|
|
4
4
|
value: AlertManagerSilencesQuerySpec;
|
|
5
5
|
onChange: (next: AlertManagerSilencesQuerySpec) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlertManagerSilencesQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/plugins/alertmanager-silences-query/AlertManagerSilencesQueryEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AlertManagerSilencesQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/plugins/alertmanager-silences-query/AlertManagerSilencesQueryEditor.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAU1C,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAE9D,UAAU,oCAAoC;IAC5C,KAAK,EAAE,6BAA6B,CAAC;IACrC,QAAQ,EAAE,CAAC,IAAI,EAAE,6BAA6B,KAAK,IAAI,CAAC;CACzD;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,oCAAoC,GAAG,YAAY,CAuDzG"}
|
|
@@ -11,13 +11,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { FormControl, Stack } from
|
|
15
|
-
import { useId } from
|
|
16
|
-
import { DatasourceSelect } from
|
|
17
|
-
import { produce } from
|
|
18
|
-
import { useCallback } from
|
|
19
|
-
import { LazyTextField } from
|
|
20
|
-
import { ALERTMANAGER_DATASOURCE_KIND, DEFAULT_ALERTMANAGER, isAlertManagerDatasourceSelector, isDefaultAlertManagerSelector } from
|
|
14
|
+
import { FormControl, Stack } from "@mui/material";
|
|
15
|
+
import { useId } from "@perses-dev/components";
|
|
16
|
+
import { DatasourceSelect } from "@perses-dev/plugin-system";
|
|
17
|
+
import { produce } from "immer";
|
|
18
|
+
import { useCallback } from "react";
|
|
19
|
+
import { LazyTextField } from "../../components/LazyTextField.js";
|
|
20
|
+
import { ALERTMANAGER_DATASOURCE_KIND, DEFAULT_ALERTMANAGER, isAlertManagerDatasourceSelector, isDefaultAlertManagerSelector } from "../../model/index.js";
|
|
21
21
|
export function AlertManagerSilencesQueryEditor(props) {
|
|
22
22
|
const { onChange, value } = props;
|
|
23
23
|
const datasourceSelectValue = value.datasource ?? DEFAULT_ALERTMANAGER;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/alertmanager-silences-query/AlertManagerSilencesQueryEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormControl, Stack } from '@mui/material';\nimport { useId } from '@perses-dev/components';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/alertmanager-silences-query/AlertManagerSilencesQueryEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormControl, Stack } from '@mui/material';\nimport { useId } from '@perses-dev/components';\nimport type { DatasourceSelectProps } from '@perses-dev/plugin-system';\nimport { DatasourceSelect } from '@perses-dev/plugin-system';\nimport { produce } from 'immer';\nimport type { ReactElement } from 'react';\nimport { useCallback } from 'react';\n\nimport { LazyTextField } from '../../components/LazyTextField';\nimport {\n ALERTMANAGER_DATASOURCE_KIND,\n DEFAULT_ALERTMANAGER,\n isAlertManagerDatasourceSelector,\n isDefaultAlertManagerSelector,\n} from '../../model';\nimport type { AlertManagerSilencesQuerySpec } from '../types';\n\ninterface AlertManagerSilencesQueryEditorProps {\n value: AlertManagerSilencesQuerySpec;\n onChange: (next: AlertManagerSilencesQuerySpec) => void;\n}\n\nexport function AlertManagerSilencesQueryEditor(props: AlertManagerSilencesQueryEditorProps): ReactElement {\n const { onChange, value } = props;\n const datasourceSelectValue = value.datasource ?? DEFAULT_ALERTMANAGER;\n const datasourceSelectLabelID = useId('alertmanager-silences-datasource-label');\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (next) => {\n if (isAlertManagerDatasourceSelector(next)) {\n onChange(\n produce(value, (draft) => {\n draft.datasource = isDefaultAlertManagerSelector(next) ? undefined : next;\n }),\n );\n return;\n }\n\n throw new Error('Got unexpected non-AlertManager datasource selector');\n };\n\n const handleFiltersChange = useCallback(\n (filtersText: string): void => {\n onChange(\n produce(value, (draft) => {\n draft.filters = filtersText\n .split('\\n')\n .map((f) => f.trim())\n .filter((f) => f !== '');\n }),\n );\n },\n [onChange, value],\n );\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\" fullWidth={false}>\n <DatasourceSelect\n datasourcePluginKind={ALERTMANAGER_DATASOURCE_KIND}\n value={datasourceSelectValue}\n onChange={handleDatasourceChange}\n labelId={datasourceSelectLabelID}\n label=\"Alert Manager Datasource\"\n notched\n />\n </FormControl>\n <LazyTextField\n label=\"Filters (one per line)\"\n value={(value.filters ?? []).join('\\n')}\n onCommit={handleFiltersChange}\n placeholder={'alertname=\"HighMemory\"\\nseverity=\"critical\"\\nenvironment=~\"${env:pipe}\"'}\n helperText=\"PromQL-style matchers, one per line.\"\n multiline\n minRows={3}\n />\n </Stack>\n );\n}\n"],"names":["FormControl","Stack","useId","DatasourceSelect","produce","useCallback","LazyTextField","ALERTMANAGER_DATASOURCE_KIND","DEFAULT_ALERTMANAGER","isAlertManagerDatasourceSelector","isDefaultAlertManagerSelector","AlertManagerSilencesQueryEditor","props","onChange","value","datasourceSelectValue","datasource","datasourceSelectLabelID","handleDatasourceChange","next","draft","undefined","Error","handleFiltersChange","filtersText","filters","split","map","f","trim","filter","spacing","margin","fullWidth","datasourcePluginKind","labelId","label","notched","join","onCommit","placeholder","helperText","multiline","minRows"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,EAAEC,KAAK,QAAQ,gBAAgB;AACnD,SAASC,KAAK,QAAQ,yBAAyB;AAE/C,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,OAAO,QAAQ,QAAQ;AAEhC,SAASC,WAAW,QAAQ,QAAQ;AAEpC,SAASC,aAAa,QAAQ,oCAAiC;AAC/D,SACEC,4BAA4B,EAC5BC,oBAAoB,EACpBC,gCAAgC,EAChCC,6BAA6B,QACxB,uBAAc;AAQrB,OAAO,SAASC,gCAAgCC,KAA2C;IACzF,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGF;IAC5B,MAAMG,wBAAwBD,MAAME,UAAU,IAAIR;IAClD,MAAMS,0BAA0Bf,MAAM;IAEtC,MAAMgB,yBAA4D,CAACC;QACjE,IAAIV,iCAAiCU,OAAO;YAC1CN,SACET,QAAQU,OAAO,CAACM;gBACdA,MAAMJ,UAAU,GAAGN,8BAA8BS,QAAQE,YAAYF;YACvE;YAEF;QACF;QAEA,MAAM,IAAIG,MAAM;IAClB;IAEA,MAAMC,sBAAsBlB,YAC1B,CAACmB;QACCX,SACET,QAAQU,OAAO,CAACM;YACdA,MAAMK,OAAO,GAAGD,YACbE,KAAK,CAAC,MACNC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,IACjBC,MAAM,CAAC,CAACF,IAAMA,MAAM;QACzB;IAEJ,GACA;QAACf;QAAUC;KAAM;IAGnB,qBACE,MAACb;QAAM8B,SAAS;;0BACd,KAAC/B;gBAAYgC,QAAO;gBAAQC,WAAW;0BACrC,cAAA,KAAC9B;oBACC+B,sBAAsB3B;oBACtBO,OAAOC;oBACPF,UAAUK;oBACViB,SAASlB;oBACTmB,OAAM;oBACNC,OAAO;;;0BAGX,KAAC/B;gBACC8B,OAAM;gBACNtB,OAAO,AAACA,CAAAA,MAAMW,OAAO,IAAI,EAAE,AAAD,EAAGa,IAAI,CAAC;gBAClCC,UAAUhB;gBACViB,aAAa;gBACbC,YAAW;gBACXC,SAAS;gBACTC,SAAS;;;;AAIjB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SilencesQueryContext } from '@perses-dev/plugin-system';
|
|
2
|
-
import { SilencesData } from '@perses-dev/spec';
|
|
3
|
-
import { AlertManagerSilencesQuerySpec } from '../types';
|
|
1
|
+
import type { SilencesQueryContext } from '@perses-dev/plugin-system';
|
|
2
|
+
import type { SilencesData } from '@perses-dev/spec';
|
|
3
|
+
import type { AlertManagerSilencesQuerySpec } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Get silences data from Alert Manager, transforming the API response into the plugin-system SilencesData format.
|
|
6
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-silences-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/alertmanager-silences-query/get-silences-data.ts"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"get-silences-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/alertmanager-silences-query/get-silences-data.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEtE,OAAO,KAAK,EAAW,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAI9D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAsB9D;;GAEG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,6BAA6B,EACnC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,YAAY,CAAC,CAsBvB"}
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { datasourceSelectValueToSelector, replaceVariables } from
|
|
14
|
-
import { ALERTMANAGER_DATASOURCE_KIND, DEFAULT_ALERTMANAGER } from
|
|
13
|
+
import { datasourceSelectValueToSelector, replaceVariables } from "@perses-dev/plugin-system";
|
|
14
|
+
import { ALERTMANAGER_DATASOURCE_KIND, DEFAULT_ALERTMANAGER } from "../../model/index.js";
|
|
15
15
|
/**
|
|
16
16
|
* Transform a GettableSilence from the Alertmanager API into our normalized Silence format.
|
|
17
17
|
*/ function transformSilence(apiSilence) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/alertmanager-silences-query/get-silences-data.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { datasourceSelectValueToSelector, replaceVariables
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/alertmanager-silences-query/get-silences-data.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { SilencesQueryContext } from '@perses-dev/plugin-system';\nimport { datasourceSelectValueToSelector, replaceVariables } from '@perses-dev/plugin-system';\nimport type { Silence, SilencesData } from '@perses-dev/spec';\n\nimport type { AlertManagerClient, GettableSilence } from '../../model';\nimport { ALERTMANAGER_DATASOURCE_KIND, DEFAULT_ALERTMANAGER } from '../../model';\nimport type { AlertManagerSilencesQuerySpec } from '../types';\n/**\n * Transform a GettableSilence from the Alertmanager API into our normalized Silence format.\n */\nfunction transformSilence(apiSilence: GettableSilence): Silence {\n return {\n id: apiSilence.id,\n state: apiSilence.status.state,\n matchers: apiSilence.matchers.map((m) => ({\n name: m.name,\n value: m.value,\n isRegex: m.isRegex,\n isEqual: m.isEqual,\n })),\n startsAt: apiSilence.startsAt,\n endsAt: apiSilence.endsAt,\n createdBy: apiSilence.createdBy,\n comment: apiSilence.comment,\n updatedAt: apiSilence.updatedAt,\n };\n}\n\n/**\n * Get silences data from Alert Manager, transforming the API response into the plugin-system SilencesData format.\n */\nexport async function getSilencesData(\n spec: AlertManagerSilencesQuerySpec,\n context: SilencesQueryContext,\n): Promise<SilencesData> {\n const listDatasourceSelectItems =\n await context.datasourceStore.listDatasourceSelectItems(ALERTMANAGER_DATASOURCE_KIND);\n const datasourceSelector =\n datasourceSelectValueToSelector(spec.datasource, context.variableState, listDatasourceSelectItems) ??\n DEFAULT_ALERTMANAGER;\n const client = await context.datasourceStore.getDatasourceClient<AlertManagerClient>(datasourceSelector);\n\n const interpolatedFilters = spec.filters?.map((f) => replaceVariables(f, context.variableState));\n\n const apiSilences = await client.getSilences({\n filter: interpolatedFilters,\n });\n\n const silences = apiSilences.map(transformSilence);\n\n return {\n silences,\n metadata: {\n executedQueryString: buildQueryString(spec),\n },\n };\n}\n\nfunction buildQueryString(spec: AlertManagerSilencesQuerySpec): string {\n return JSON.stringify(\n Object.fromEntries(\n Object.entries({\n filters: spec.filters,\n }).filter(([, value]) => value !== undefined),\n ),\n );\n}\n"],"names":["datasourceSelectValueToSelector","replaceVariables","ALERTMANAGER_DATASOURCE_KIND","DEFAULT_ALERTMANAGER","transformSilence","apiSilence","id","state","status","matchers","map","m","name","value","isRegex","isEqual","startsAt","endsAt","createdBy","comment","updatedAt","getSilencesData","spec","context","listDatasourceSelectItems","datasourceStore","datasourceSelector","datasource","variableState","client","getDatasourceClient","interpolatedFilters","filters","f","apiSilences","getSilences","filter","silences","metadata","executedQueryString","buildQueryString","JSON","stringify","Object","fromEntries","entries","undefined"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,+BAA+B,EAAEC,gBAAgB,QA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