@perses-dev/prometheus-plugin 0.57.0 → 0.58.0-beta.0
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/css/async/3829.85c2cbf6.css +1 -0
- package/__mf/font/inter-cyrillic-300-normal.432f2b21.woff +0 -0
- package/__mf/font/inter-cyrillic-300-normal.9da91009.woff2 +0 -0
- package/__mf/font/inter-cyrillic-400-normal.372704ff.woff2 +0 -0
- package/__mf/font/inter-cyrillic-400-normal.a6b6ef6f.woff +0 -0
- package/__mf/font/inter-cyrillic-500-normal.7c15bba8.woff2 +0 -0
- package/__mf/font/inter-cyrillic-500-normal.b9f8c929.woff +0 -0
- package/__mf/font/inter-cyrillic-600-normal.2f42892a.woff2 +0 -0
- package/__mf/font/inter-cyrillic-600-normal.c3987adc.woff +0 -0
- package/__mf/font/inter-cyrillic-700-normal.93eba3c3.woff +0 -0
- package/__mf/font/inter-cyrillic-700-normal.e9e5b2dc.woff2 +0 -0
- package/__mf/font/inter-cyrillic-900-normal.f285bd7a.woff2 +0 -0
- package/__mf/font/inter-cyrillic-900-normal.ffbd8a3a.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-300-normal.95bb9038.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-300-normal.cfc143a9.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-400-normal.2a31c04b.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-400-normal.f572b170.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-500-normal.5a6bb1da.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-500-normal.fe0d9b14.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-600-normal.ecbdecad.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-600-normal.f7b3c15b.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-700-normal.4b4022a6.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-700-normal.74b516d2.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-900-normal.9970ddb5.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-900-normal.a0d59adc.woff2 +0 -0
- package/__mf/font/inter-greek-300-normal.0d7be683.woff2 +0 -0
- package/__mf/font/inter-greek-300-normal.8f0b988e.woff +0 -0
- package/__mf/font/inter-greek-400-normal.cc58c11b.woff +0 -0
- package/__mf/font/inter-greek-400-normal.d7020e3c.woff2 +0 -0
- package/__mf/font/inter-greek-500-normal.d9a33207.woff +0 -0
- package/__mf/font/inter-greek-500-normal.f41f43db.woff2 +0 -0
- package/__mf/font/inter-greek-600-normal.4ec0c1c1.woff +0 -0
- package/__mf/font/inter-greek-600-normal.cc532937.woff2 +0 -0
- package/__mf/font/inter-greek-700-normal.5ec6c758.woff +0 -0
- package/__mf/font/inter-greek-700-normal.97f0eeeb.woff2 +0 -0
- package/__mf/font/inter-greek-900-normal.46b66369.woff2 +0 -0
- package/__mf/font/inter-greek-900-normal.9ae3a3c5.woff +0 -0
- package/__mf/font/inter-greek-ext-300-normal.10247a66.woff2 +0 -0
- package/__mf/font/inter-greek-ext-300-normal.4668e5cb.woff +0 -0
- package/__mf/font/inter-greek-ext-400-normal.4ce1df5d.woff2 +0 -0
- package/__mf/font/inter-greek-ext-400-normal.88ede1ea.woff +0 -0
- package/__mf/font/inter-greek-ext-500-normal.7a4aa726.woff +0 -0
- package/__mf/font/inter-greek-ext-500-normal.cbd51e2d.woff2 +0 -0
- package/__mf/font/inter-greek-ext-600-normal.089a95ee.woff +0 -0
- package/__mf/font/inter-greek-ext-600-normal.1f33d317.woff2 +0 -0
- package/__mf/font/inter-greek-ext-700-normal.31f1075d.woff +0 -0
- package/__mf/font/inter-greek-ext-700-normal.827cd618.woff2 +0 -0
- package/__mf/font/inter-greek-ext-900-normal.531bcee7.woff +0 -0
- package/__mf/font/inter-greek-ext-900-normal.8a9b36b9.woff2 +0 -0
- package/__mf/font/inter-latin-300-normal.15fb600d.woff2 +0 -0
- package/__mf/font/inter-latin-300-normal.6f95f590.woff +0 -0
- package/__mf/font/inter-latin-400-normal.2c7a775c.woff +0 -0
- package/__mf/font/inter-latin-400-normal.ef6d3f52.woff2 +0 -0
- package/__mf/font/inter-latin-500-normal.b7b43ace.woff2 +0 -0
- package/__mf/font/inter-latin-500-normal.cb4c8ceb.woff +0 -0
- package/__mf/font/inter-latin-600-normal.8fb1a964.woff2 +0 -0
- package/__mf/font/inter-latin-600-normal.ce0f5f43.woff +0 -0
- package/__mf/font/inter-latin-700-normal.953b7aa5.woff2 +0 -0
- package/__mf/font/inter-latin-700-normal.9c21d4dc.woff +0 -0
- package/__mf/font/inter-latin-900-normal.2a8028ec.woff2 +0 -0
- package/__mf/font/inter-latin-900-normal.fa252135.woff +0 -0
- package/__mf/font/inter-latin-ext-300-normal.167cc8c9.woff2 +0 -0
- package/__mf/font/inter-latin-ext-300-normal.f695be66.woff +0 -0
- package/__mf/font/inter-latin-ext-400-normal.32a25442.woff2 +0 -0
- package/__mf/font/inter-latin-ext-400-normal.4edcaace.woff +0 -0
- package/__mf/font/inter-latin-ext-500-normal.a19a84a6.woff +0 -0
- package/__mf/font/inter-latin-ext-500-normal.d9b491de.woff2 +0 -0
- package/__mf/font/inter-latin-ext-600-normal.38b075d8.woff2 +0 -0
- package/__mf/font/inter-latin-ext-600-normal.49faa47a.woff +0 -0
- package/__mf/font/inter-latin-ext-700-normal.93534b50.woff +0 -0
- package/__mf/font/inter-latin-ext-700-normal.b63daa1a.woff2 +0 -0
- package/__mf/font/inter-latin-ext-900-normal.0efdb307.woff +0 -0
- package/__mf/font/inter-latin-ext-900-normal.9c0fc2c7.woff2 +0 -0
- package/__mf/font/inter-vietnamese-300-normal.aad496d8.woff +0 -0
- package/__mf/font/inter-vietnamese-300-normal.ad9ef503.woff2 +0 -0
- package/__mf/font/inter-vietnamese-400-normal.a9dd2faf.woff +0 -0
- package/__mf/font/inter-vietnamese-400-normal.de4fc44f.woff2 +0 -0
- package/__mf/font/inter-vietnamese-500-normal.7c0a695f.woff2 +0 -0
- package/__mf/font/inter-vietnamese-500-normal.a3a73b95.woff +0 -0
- package/__mf/font/inter-vietnamese-600-normal.9d518599.woff2 +0 -0
- package/__mf/font/inter-vietnamese-600-normal.c5ce3fcb.woff +0 -0
- package/__mf/font/inter-vietnamese-700-normal.bc68b199.woff +0 -0
- package/__mf/font/inter-vietnamese-700-normal.faf12809.woff2 +0 -0
- package/__mf/font/inter-vietnamese-900-normal.2b782045.woff +0 -0
- package/__mf/font/inter-vietnamese-900-normal.e639b65a.woff2 +0 -0
- package/__mf/js/Prometheus.c5cd832d.js +7 -0
- package/__mf/js/async/1432.0bb0ef6b.js +1 -0
- package/__mf/js/async/1605.7c7a0998.js +110 -0
- package/__mf/js/async/{1605.dc180cb8.js.LICENSE.txt → 1605.7c7a0998.js.LICENSE.txt} +1 -1
- package/__mf/js/async/1616.ed429c53.js +1 -0
- package/__mf/js/async/1728.310a7d33.js +1 -0
- package/__mf/js/async/1969.a1e1979e.js +1 -0
- package/__mf/js/async/2043.c2948add.js +2 -0
- package/__mf/js/async/{2186.e58838a5.js → 2186.9a98bd8f.js} +2 -2
- package/__mf/js/async/2292.27a5ec4d.js +4 -0
- package/__mf/js/async/{9010.ca50fa9e.js.LICENSE.txt → 2292.27a5ec4d.js.LICENSE.txt} +1 -1
- package/__mf/js/async/2506.baf20a10.js +1 -0
- package/__mf/js/async/2814.fbf52858.js +1 -0
- package/__mf/js/async/3499.19c4bfa6.js +1 -0
- package/__mf/js/async/3829.f250b55a.js +7 -0
- package/__mf/js/async/{3652.6b591718.js.LICENSE.txt → 3829.f250b55a.js.LICENSE.txt} +19 -1
- package/__mf/js/async/392.233c0945.js +2 -0
- package/__mf/js/async/3963.81c8be7e.js +1 -0
- package/__mf/js/async/4121.9ed83f2a.js +2 -0
- package/__mf/js/async/4402.99ae853d.js +1 -0
- package/__mf/js/async/4626.e7ed0d7d.js +1 -0
- package/__mf/js/async/4800.cc42977e.js +22 -0
- package/__mf/js/async/4887.8af3673d.js +1 -0
- package/__mf/js/async/4987.f7360bdf.js +1 -0
- package/__mf/js/async/5002.bd952313.js +1 -0
- package/__mf/js/async/5071.5fcfd9a8.js +1 -0
- package/__mf/js/async/5440.52ec91ad.js +2 -0
- package/__mf/js/async/5587.e4d331db.js +1 -0
- package/__mf/js/async/5697.e17ba256.js +1 -0
- package/__mf/js/async/5763.ccf403b7.js +1 -0
- package/__mf/js/async/5922.ba33c996.js +1 -0
- package/__mf/js/async/6274.f04c9ecd.js +2 -0
- package/__mf/js/async/6438.b86a2aba.js +1 -0
- package/__mf/js/async/6507.71182781.js +1 -0
- package/__mf/js/async/7177.0ab860e0.js +1 -0
- package/__mf/js/async/7192.bbf62500.js +1 -0
- package/__mf/js/async/7462.e9a1c8bc.js +2 -0
- package/__mf/js/async/7647.82297501.js +1 -0
- package/__mf/js/async/7862.e13fbb9d.js +2 -0
- package/__mf/js/async/7894.9fe90396.js +1 -0
- package/__mf/js/async/7968.253f5f1d.js +1 -0
- package/__mf/js/async/7978.be30c741.js +1 -0
- package/__mf/js/async/8292.11dc2ca3.js +1 -0
- package/__mf/js/async/8356.e845a073.js +1 -0
- package/__mf/js/async/8470.84935087.js +2 -0
- package/__mf/js/async/{3996.69a9c1dc.js → 8634.e3cfb057.js} +1 -1
- package/__mf/js/async/873.6aafbb7b.js +1 -0
- package/__mf/js/async/8888.3a188176.js +1 -0
- package/__mf/js/async/9184.e6de21be.js +1 -0
- package/__mf/js/async/9235.85fb6b63.js +1 -0
- package/__mf/js/async/941.075ed563.js +2 -0
- package/__mf/js/async/9588.dfdaeff2.js +1 -0
- package/__mf/js/async/9745.0a6c90a2.js +1 -0
- package/__mf/js/async/9836.888f4ed2.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusDatasource.d4892cae.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusExplorer.681841d8.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.86c44577.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.ff683936.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.bac03b61.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.9a495e56.js +1 -0
- package/__mf/js/main.afe2fc64.js +7 -0
- package/lib/cjs/model/prometheus-client.js +22 -17
- package/lib/cjs/plugins/PrometheusDatasourceEditor.js +10 -48
- package/lib/cjs/plugins/PrometheusLabelNamesVariable.js +3 -2
- package/lib/cjs/plugins/PrometheusLabelValuesVariable.js +3 -2
- package/lib/cjs/plugins/PrometheusPromQLVariable.js +3 -2
- package/lib/cjs/plugins/interpolation.js +54 -0
- package/lib/cjs/plugins/prometheus-datasource.js +15 -42
- package/lib/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +10 -2
- package/lib/model/api-types.d.ts +1 -1
- package/lib/model/api-types.d.ts.map +1 -1
- package/lib/model/api-types.js.map +1 -1
- package/lib/model/prometheus-client.d.ts +16 -13
- package/lib/model/prometheus-client.d.ts.map +1 -1
- package/lib/model/prometheus-client.js +19 -16
- package/lib/model/prometheus-client.js.map +1 -1
- package/lib/plugins/PrometheusDatasourceEditor.d.ts.map +1 -1
- package/lib/plugins/PrometheusDatasourceEditor.js +11 -8
- package/lib/plugins/PrometheusDatasourceEditor.js.map +1 -1
- package/lib/plugins/PrometheusLabelNamesVariable.d.ts.map +1 -1
- package/lib/plugins/PrometheusLabelNamesVariable.js +3 -2
- package/lib/plugins/PrometheusLabelNamesVariable.js.map +1 -1
- package/lib/plugins/PrometheusLabelValuesVariable.d.ts.map +1 -1
- package/lib/plugins/PrometheusLabelValuesVariable.js +3 -2
- package/lib/plugins/PrometheusLabelValuesVariable.js.map +1 -1
- package/lib/plugins/PrometheusPromQLVariable.d.ts.map +1 -1
- package/lib/plugins/PrometheusPromQLVariable.js +3 -2
- package/lib/plugins/PrometheusPromQLVariable.js.map +1 -1
- package/lib/plugins/interpolation.d.ts +12 -0
- package/lib/plugins/interpolation.d.ts.map +1 -0
- package/lib/plugins/interpolation.js +38 -0
- package/lib/plugins/interpolation.js.map +1 -0
- package/lib/plugins/prometheus-datasource.d.ts.map +1 -1
- package/lib/plugins/prometheus-datasource.js +16 -43
- package/lib/plugins/prometheus-datasource.js.map +1 -1
- package/lib/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -1
- package/lib/plugins/prometheus-time-series-query/get-time-series-data.js +10 -2
- package/lib/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
- package/lib/plugins/types.d.ts +2 -1
- package/lib/plugins/types.d.ts.map +1 -1
- package/lib/plugins/types.js.map +1 -1
- package/mf-manifest.json +305 -293
- package/mf-stats.json +321 -293
- package/package.json +6 -6
- package/__mf/css/async/1233.d3010b86.css +0 -1
- package/__mf/css/async/1324.d3010b86.css +0 -1
- package/__mf/css/async/9518.d3010b86.css +0 -1
- package/__mf/font/lato-all-300-normal.322bdf14.woff +0 -0
- package/__mf/font/lato-all-400-normal.63513b00.woff +0 -0
- package/__mf/font/lato-all-700-normal.bb27db94.woff +0 -0
- package/__mf/font/lato-all-900-normal.a27049a3.woff +0 -0
- package/__mf/font/lato-latin-300-normal.c5195215.woff2 +0 -0
- package/__mf/font/lato-latin-400-normal.b7ffde23.woff2 +0 -0
- package/__mf/font/lato-latin-700-normal.d5eb20bc.woff2 +0 -0
- package/__mf/font/lato-latin-900-normal.d884a71c.woff2 +0 -0
- package/__mf/font/lato-latin-ext-300-normal.abcc64a9.woff2 +0 -0
- package/__mf/font/lato-latin-ext-400-normal.6ebed106.woff2 +0 -0
- package/__mf/font/lato-latin-ext-700-normal.8697d1d5.woff2 +0 -0
- package/__mf/font/lato-latin-ext-900-normal.20a2b415.woff2 +0 -0
- package/__mf/js/Prometheus.9877d89e.js +0 -6
- package/__mf/js/async/1233.0ab88b51.js +0 -1
- package/__mf/js/async/1324.ce01eced.js +0 -1
- package/__mf/js/async/1432.0c3e4ed0.js +0 -1
- package/__mf/js/async/1605.dc180cb8.js +0 -110
- package/__mf/js/async/1616.7587ce79.js +0 -1
- package/__mf/js/async/1728.531c96f9.js +0 -1
- package/__mf/js/async/1969.372d36b8.js +0 -1
- package/__mf/js/async/2043.d0fbb886.js +0 -2
- package/__mf/js/async/2506.1e336b3b.js +0 -1
- package/__mf/js/async/3184.6b4ad42e.js +0 -1
- package/__mf/js/async/3499.bef2e2e5.js +0 -1
- package/__mf/js/async/3652.6b591718.js +0 -7
- package/__mf/js/async/392.f1b4a590.js +0 -2
- package/__mf/js/async/3963.5fef6ffb.js +0 -1
- package/__mf/js/async/4121.828d661d.js +0 -2
- package/__mf/js/async/425.1ec8867f.js +0 -1
- package/__mf/js/async/4626.173e602a.js +0 -1
- package/__mf/js/async/4657.f0c3ccd6.js +0 -2
- package/__mf/js/async/4987.c12b89cb.js +0 -1
- package/__mf/js/async/5002.e4f54e8e.js +0 -1
- package/__mf/js/async/5071.e1c33fa7.js +0 -1
- package/__mf/js/async/529.2303b01b.js +0 -1
- package/__mf/js/async/54.e6002704.js +0 -22
- package/__mf/js/async/5440.8ced5513.js +0 -2
- package/__mf/js/async/5587.4d72fc35.js +0 -1
- package/__mf/js/async/5763.4ba478ff.js +0 -1
- package/__mf/js/async/5922.d1619ac1.js +0 -1
- package/__mf/js/async/6274.478a68f8.js +0 -2
- package/__mf/js/async/6283.181cb622.js +0 -2
- package/__mf/js/async/6969.b959b6f8.js +0 -1
- package/__mf/js/async/7177.205c9aaf.js +0 -1
- package/__mf/js/async/7192.d835931b.js +0 -1
- package/__mf/js/async/7894.9c5245d7.js +0 -1
- package/__mf/js/async/7968.6ac0ce96.js +0 -1
- package/__mf/js/async/7978.9532d5b8.js +0 -1
- package/__mf/js/async/8356.789e1dfb.js +0 -1
- package/__mf/js/async/8470.9b14a625.js +0 -2
- package/__mf/js/async/873.448eab23.js +0 -1
- package/__mf/js/async/8888.59eb50a2.js +0 -1
- package/__mf/js/async/9010.ca50fa9e.js +0 -2
- package/__mf/js/async/9020.ebc1cad3.js +0 -1
- package/__mf/js/async/9184.43a8d927.js +0 -1
- package/__mf/js/async/9235.36c3cd8c.js +0 -1
- package/__mf/js/async/9351.715f25c3.js +0 -1
- package/__mf/js/async/941.53b13124.js +0 -2
- package/__mf/js/async/9518.38e38a33.js +0 -1
- package/__mf/js/async/9588.9081c7de.js +0 -1
- package/__mf/js/async/9605.a92ec9c1.js +0 -1
- package/__mf/js/async/9836.00da6086.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusDatasource.b97f9012.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusExplorer.eba3b416.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.bd38a89c.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.eb12e168.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.7ccb0601.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.08f11ea9.js +0 -1
- package/__mf/js/main.78fc6444.js +0 -6
- /package/__mf/js/async/{2043.d0fbb886.js.LICENSE.txt → 2043.c2948add.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.f1b4a590.js.LICENSE.txt → 392.233c0945.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{4121.828d661d.js.LICENSE.txt → 4121.9ed83f2a.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{54.e6002704.js.LICENSE.txt → 4800.cc42977e.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{5440.8ced5513.js.LICENSE.txt → 5440.52ec91ad.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6274.478a68f8.js.LICENSE.txt → 6274.f04c9ecd.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{4657.f0c3ccd6.js.LICENSE.txt → 7462.e9a1c8bc.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6283.181cb622.js.LICENSE.txt → 7862.e13fbb9d.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{8470.9b14a625.js.LICENSE.txt → 8470.84935087.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.53b13124.js.LICENSE.txt → 941.075ed563.js.LICENSE.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/PrometheusLabelValuesVariable.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 {\n VariablePlugin,\n GetVariableOptionsContext,\n replaceVariables,\n parseVariables,\n datasourceSelectValueToSelector,\n isVariableDatasource,\n} from '@perses-dev/plugin-system';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/PrometheusLabelValuesVariable.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 {\n VariablePlugin,\n GetVariableOptionsContext,\n replaceVariables,\n parseVariables,\n datasourceSelectValueToSelector,\n isVariableDatasource,\n} from '@perses-dev/plugin-system';\nimport { DEFAULT_PROM, getPrometheusTimeRange, PROM_DATASOURCE_KIND } from '../model';\nimport { stringArrayToVariableOptions, PrometheusLabelValuesVariableEditor } from './prometheus-variables';\nimport { resolvePrometheusDatasource } from './interpolation';\nimport { PrometheusLabelValuesVariableOptions } from './types';\n\nexport const PrometheusLabelValuesVariable: VariablePlugin<PrometheusLabelValuesVariableOptions> = {\n getVariableOptions: async (spec: PrometheusLabelValuesVariableOptions, ctx: GetVariableOptionsContext) => {\n const pluginDef = spec;\n const datasourceSelector =\n datasourceSelectValueToSelector(\n spec.datasource ?? DEFAULT_PROM,\n ctx.variables,\n await ctx.datasourceStore.listDatasourceSelectItems(PROM_DATASOURCE_KIND)\n ) ?? DEFAULT_PROM;\n const { client, requestOptions } = await resolvePrometheusDatasource(\n ctx.datasourceStore,\n datasourceSelector,\n ctx.variables\n );\n const match = pluginDef.matchers ? pluginDef.matchers.map((m) => replaceVariables(m, ctx.variables)) : undefined;\n\n const timeRange = getPrometheusTimeRange(ctx.timeRange);\n\n const { data: options } = await client.labelValues(\n {\n labelName: replaceVariables(pluginDef.labelName, ctx.variables),\n 'match[]': match,\n ...timeRange,\n },\n requestOptions\n );\n return {\n data: stringArrayToVariableOptions(options),\n };\n },\n dependsOn: (spec: PrometheusLabelValuesVariableOptions) => {\n const matcherVariables = spec.matchers?.map((m) => parseVariables(m)).flat() || [];\n const labelVariables = parseVariables(spec.labelName);\n const datasourceVariables =\n spec.datasource && isVariableDatasource(spec.datasource) ? parseVariables(spec.datasource) : [];\n return {\n variables: [...matcherVariables, ...labelVariables, ...datasourceVariables],\n };\n },\n OptionsEditorComponent: PrometheusLabelValuesVariableEditor,\n createInitialOptions: () => ({ labelName: '' }),\n};\n"],"names":["replaceVariables","parseVariables","datasourceSelectValueToSelector","isVariableDatasource","DEFAULT_PROM","getPrometheusTimeRange","PROM_DATASOURCE_KIND","stringArrayToVariableOptions","PrometheusLabelValuesVariableEditor","resolvePrometheusDatasource","PrometheusLabelValuesVariable","getVariableOptions","spec","ctx","pluginDef","datasourceSelector","datasource","variables","datasourceStore","listDatasourceSelectItems","client","requestOptions","match","matchers","map","m","undefined","timeRange","data","options","labelValues","labelName","dependsOn","matcherVariables","flat","labelVariables","datasourceVariables","OptionsEditorComponent","createInitialOptions"],"mappings":"AAAA,+BAA+B;AAC/B,oEAA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B,SAAS;QACpD,MAAMK,sBACJxB,KAAKI,UAAU,IAAIb,qBAAqBS,KAAKI,UAAU,IAAIf,eAAeW,KAAKI,UAAU,IAAI,EAAE;QACjG,OAAO;YACLC,WAAW;mBAAIgB;mBAAqBE;mBAAmBC;aAAoB;QAC7E;IACF;IACAC,wBAAwB7B;IACxB8B,sBAAsB,IAAO,CAAA;YAAEP,WAAW;QAAG,CAAA;AAC/C,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrometheusPromQLVariable.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusPromQLVariable.tsx"],"names":[],"mappings":"AAaA,OAAO,EACL,cAAc,EAMf,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"PrometheusPromQLVariable.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusPromQLVariable.tsx"],"names":[],"mappings":"AAaA,OAAO,EACL,cAAc,EAMf,MAAM,2BAA2B,CAAC;AASnC,OAAO,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAE1D,eAAO,MAAM,wBAAwB,EAAE,cAAc,CAAC,+BAA+B,CAuCpF,CAAC"}
|
|
@@ -13,14 +13,15 @@
|
|
|
13
13
|
import { replaceVariables, parseVariables, datasourceSelectValueToSelector, isVariableDatasource } from '@perses-dev/plugin-system';
|
|
14
14
|
import { DEFAULT_PROM, PROM_DATASOURCE_KIND } from '../model';
|
|
15
15
|
import { capturingMatrix, capturingVector, stringArrayToVariableOptions, PrometheusPromQLVariableEditor } from './prometheus-variables';
|
|
16
|
+
import { resolvePrometheusDatasource } from './interpolation';
|
|
16
17
|
export const PrometheusPromQLVariable = {
|
|
17
18
|
getVariableOptions: async (spec, ctx)=>{
|
|
18
19
|
const datasourceSelector = datasourceSelectValueToSelector(spec.datasource ?? DEFAULT_PROM, ctx.variables, await ctx.datasourceStore.listDatasourceSelectItems(PROM_DATASOURCE_KIND)) ?? DEFAULT_PROM;
|
|
19
|
-
const client = await ctx.datasourceStore.
|
|
20
|
+
const { client, requestOptions } = await resolvePrometheusDatasource(ctx.datasourceStore, datasourceSelector, ctx.variables);
|
|
20
21
|
// TODO we may want to manage a range query as well.
|
|
21
22
|
const { data: options } = await client.instantQuery({
|
|
22
23
|
query: replaceVariables(spec.expr, ctx.variables)
|
|
23
|
-
});
|
|
24
|
+
}, requestOptions);
|
|
24
25
|
const labelName = replaceVariables(spec.labelName, ctx.variables);
|
|
25
26
|
let values = [];
|
|
26
27
|
if (options?.resultType === 'matrix') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/PrometheusPromQLVariable.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 {\n VariablePlugin,\n GetVariableOptionsContext,\n replaceVariables,\n parseVariables,\n datasourceSelectValueToSelector,\n isVariableDatasource,\n} from '@perses-dev/plugin-system';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/PrometheusPromQLVariable.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 {\n VariablePlugin,\n GetVariableOptionsContext,\n replaceVariables,\n parseVariables,\n datasourceSelectValueToSelector,\n isVariableDatasource,\n} from '@perses-dev/plugin-system';\nimport { DEFAULT_PROM, PROM_DATASOURCE_KIND } from '../model';\nimport {\n capturingMatrix,\n capturingVector,\n stringArrayToVariableOptions,\n PrometheusPromQLVariableEditor,\n} from './prometheus-variables';\nimport { resolvePrometheusDatasource } from './interpolation';\nimport { PrometheusPromQLVariableOptions } from './types';\n\nexport const PrometheusPromQLVariable: VariablePlugin<PrometheusPromQLVariableOptions> = {\n getVariableOptions: async (spec: PrometheusPromQLVariableOptions, ctx: GetVariableOptionsContext) => {\n const datasourceSelector =\n datasourceSelectValueToSelector(\n spec.datasource ?? DEFAULT_PROM,\n ctx.variables,\n await ctx.datasourceStore.listDatasourceSelectItems(PROM_DATASOURCE_KIND)\n ) ?? DEFAULT_PROM;\n const { client, requestOptions } = await resolvePrometheusDatasource(\n ctx.datasourceStore,\n datasourceSelector,\n ctx.variables\n );\n // TODO we may want to manage a range query as well.\n const { data: options } = await client.instantQuery(\n { query: replaceVariables(spec.expr, ctx.variables) },\n requestOptions\n );\n const labelName = replaceVariables(spec.labelName, ctx.variables);\n let values: string[] = [];\n if (options?.resultType === 'matrix') {\n values = capturingMatrix(options, labelName);\n } else if (options?.resultType === 'vector') {\n values = capturingVector(options, labelName);\n }\n\n return {\n data: stringArrayToVariableOptions(values),\n };\n },\n dependsOn: (spec: PrometheusPromQLVariableOptions) => {\n const exprVariables = parseVariables(spec.expr);\n const labelVariables = parseVariables(spec.labelName);\n const datasourceVariables =\n spec.datasource && isVariableDatasource(spec.datasource) ? parseVariables(spec.datasource) : [];\n return { variables: [...exprVariables, ...labelVariables, ...datasourceVariables] };\n },\n OptionsEditorComponent: PrometheusPromQLVariableEditor,\n createInitialOptions: () => ({ expr: '', labelName: '' }),\n};\n"],"names":["replaceVariables","parseVariables","datasourceSelectValueToSelector","isVariableDatasource","DEFAULT_PROM","PROM_DATASOURCE_KIND","capturingMatrix","capturingVector","stringArrayToVariableOptions","PrometheusPromQLVariableEditor","resolvePrometheusDatasource","PrometheusPromQLVariable","getVariableOptions","spec","ctx","datasourceSelector","datasource","variables","datasourceStore","listDatasourceSelectItems","client","requestOptions","data","options","instantQuery","query","expr","labelName","values","resultType","dependsOn","exprVariables","labelVariables","datasourceVariables","OptionsEditorComponent","createInitialOptions"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAGEA,gBAAgB,EAChBC,cAAc,EACdC,+BAA+B,EAC/BC,oBAAoB,QACf,4BAA4B;AACnC,SAASC,YAAY,EAAEC,oBAAoB,QAAQ,WAAW;AAC9D,SACEC,eAAe,EACfC,eAAe,EACfC,4BAA4B,EAC5BC,8BAA8B,QACzB,yBAAyB;AAChC,SAASC,2BAA2B,QAAQ,kBAAkB;AAG9D,OAAO,MAAMC,2BAA4E;IACvFC,oBAAoB,OAAOC,MAAuCC;QAChE,MAAMC,qBACJb,gCACEW,KAAKG,UAAU,IAAIZ,cACnBU,IAAIG,SAAS,EACb,MAAMH,IAAII,eAAe,CAACC,yBAAyB,CAACd,0BACjDD;QACP,MAAM,EAAEgB,MAAM,EAAEC,cAAc,EAAE,GAAG,MAAMX,4BACvCI,IAAII,eAAe,EACnBH,oBACAD,IAAIG,SAAS;QAEf,oDAAoD;QACpD,MAAM,EAAEK,MAAMC,OAAO,EAAE,GAAG,MAAMH,OAAOI,YAAY,CACjD;YAAEC,OAAOzB,iBAAiBa,KAAKa,IAAI,EAAEZ,IAAIG,SAAS;QAAE,GACpDI;QAEF,MAAMM,YAAY3B,iBAAiBa,KAAKc,SAAS,EAAEb,IAAIG,SAAS;QAChE,IAAIW,SAAmB,EAAE;QACzB,IAAIL,SAASM,eAAe,UAAU;YACpCD,SAAStB,gBAAgBiB,SAASI;QACpC,OAAO,IAAIJ,SAASM,eAAe,UAAU;YAC3CD,SAASrB,gBAAgBgB,SAASI;QACpC;QAEA,OAAO;YACLL,MAAMd,6BAA6BoB;QACrC;IACF;IACAE,WAAW,CAACjB;QACV,MAAMkB,gBAAgB9B,eAAeY,KAAKa,IAAI;QAC9C,MAAMM,iBAAiB/B,eAAeY,KAAKc,SAAS;QACpD,MAAMM,sBACJpB,KAAKG,UAAU,IAAIb,qBAAqBU,KAAKG,UAAU,IAAIf,eAAeY,KAAKG,UAAU,IAAI,EAAE;QACjG,OAAO;YAAEC,WAAW;mBAAIc;mBAAkBC;mBAAmBC;aAAoB;QAAC;IACpF;IACAC,wBAAwBzB;IACxB0B,sBAAsB,IAAO,CAAA;YAAET,MAAM;YAAIC,WAAW;QAAG,CAAA;AACzD,EAAE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DatasourceSelector, DatasourceSpec } from '@perses-dev/core';
|
|
2
|
+
import { VariableStateMap } from '@perses-dev/components';
|
|
3
|
+
import { DatasourceStore } from '@perses-dev/plugin-system';
|
|
4
|
+
import { ClientRequestOptions, PrometheusClient } from '../model';
|
|
5
|
+
import { PrometheusDatasourceSpec } from './types';
|
|
6
|
+
export interface ResolvedPrometheusDatasource {
|
|
7
|
+
client: PrometheusClient;
|
|
8
|
+
requestOptions: ClientRequestOptions;
|
|
9
|
+
}
|
|
10
|
+
export declare function resolvePrometheusDatasource(datasourceStore: DatasourceStore, selector: DatasourceSelector, variableState: VariableStateMap): Promise<ResolvedPrometheusDatasource>;
|
|
11
|
+
export declare function interpolateDatasourceProxyParams(datasource: DatasourceSpec<PrometheusDatasourceSpec>, variableState: VariableStateMap): ClientRequestOptions;
|
|
12
|
+
//# sourceMappingURL=interpolation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolation.d.ts","sourceRoot":"","sources":["../../../src/plugins/interpolation.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAA8C,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACtG,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,gBAAgB,CAAC;IACzB,cAAc,EAAE,oBAAoB,CAAC;CACtC;AAED,wBAAsB,2BAA2B,CAC/C,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,kBAAkB,EAC5B,aAAa,EAAE,gBAAgB,GAC9B,OAAO,CAAC,4BAA4B,CAAC,CAOvC;AAED,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,cAAc,CAAC,wBAAwB,CAAC,EACpD,aAAa,EAAE,gBAAgB,GAC9B,oBAAoB,CAStB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { interpolateHeaders, interpolateQueryParams } from '@perses-dev/components';
|
|
14
|
+
export async function resolvePrometheusDatasource(datasourceStore, selector, variableState) {
|
|
15
|
+
const [client, datasource] = await Promise.all([
|
|
16
|
+
datasourceStore.getDatasourceClient(selector),
|
|
17
|
+
datasourceStore.getDatasource(selector)
|
|
18
|
+
]);
|
|
19
|
+
const { headers, queryParams } = interpolateDatasourceProxyParams(datasource, variableState);
|
|
20
|
+
return {
|
|
21
|
+
client,
|
|
22
|
+
requestOptions: {
|
|
23
|
+
headers,
|
|
24
|
+
queryParams
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function interpolateDatasourceProxyParams(datasource, variableState) {
|
|
29
|
+
const spec = datasource.plugin.spec;
|
|
30
|
+
const rawHeaders = spec.proxy?.spec?.headers;
|
|
31
|
+
const rawQueryParams = spec.queryParams;
|
|
32
|
+
return {
|
|
33
|
+
headers: rawHeaders ? interpolateHeaders(rawHeaders, variableState) : undefined,
|
|
34
|
+
queryParams: rawQueryParams ? interpolateQueryParams(rawQueryParams, variableState) : undefined
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=interpolation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/interpolation.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 { DatasourceSelector, DatasourceSpec } from '@perses-dev/core';\nimport { interpolateHeaders, interpolateQueryParams, VariableStateMap } from '@perses-dev/components';\nimport { DatasourceStore } from '@perses-dev/plugin-system';\nimport { ClientRequestOptions, PrometheusClient } from '../model';\nimport { PrometheusDatasourceSpec } from './types';\n\nexport interface ResolvedPrometheusDatasource {\n client: PrometheusClient;\n requestOptions: ClientRequestOptions;\n}\n\nexport async function resolvePrometheusDatasource(\n datasourceStore: DatasourceStore,\n selector: DatasourceSelector,\n variableState: VariableStateMap\n): Promise<ResolvedPrometheusDatasource> {\n const [client, datasource] = await Promise.all([\n datasourceStore.getDatasourceClient<PrometheusClient>(selector),\n datasourceStore.getDatasource(selector) as Promise<DatasourceSpec<PrometheusDatasourceSpec>>,\n ]);\n const { headers, queryParams } = interpolateDatasourceProxyParams(datasource, variableState);\n return { client, requestOptions: { headers, queryParams } };\n}\n\nexport function interpolateDatasourceProxyParams(\n datasource: DatasourceSpec<PrometheusDatasourceSpec>,\n variableState: VariableStateMap\n): ClientRequestOptions {\n const spec = datasource.plugin.spec;\n const rawHeaders = spec.proxy?.spec?.headers;\n const rawQueryParams = spec.queryParams;\n\n return {\n headers: rawHeaders ? interpolateHeaders(rawHeaders, variableState) : undefined,\n queryParams: rawQueryParams ? interpolateQueryParams(rawQueryParams, variableState) : undefined,\n };\n}\n"],"names":["interpolateHeaders","interpolateQueryParams","resolvePrometheusDatasource","datasourceStore","selector","variableState","client","datasource","Promise","all","getDatasourceClient","getDatasource","headers","queryParams","interpolateDatasourceProxyParams","requestOptions","spec","plugin","rawHeaders","proxy","rawQueryParams","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,kBAAkB,EAAEC,sBAAsB,QAA0B,yBAAyB;AAUtG,OAAO,eAAeC,4BACpBC,eAAgC,EAChCC,QAA4B,EAC5BC,aAA+B;IAE/B,MAAM,CAACC,QAAQC,WAAW,GAAG,MAAMC,QAAQC,GAAG,CAAC;QAC7CN,gBAAgBO,mBAAmB,CAAmBN;QACtDD,gBAAgBQ,aAAa,CAACP;KAC/B;IACD,MAAM,EAAEQ,OAAO,EAAEC,WAAW,EAAE,GAAGC,iCAAiCP,YAAYF;IAC9E,OAAO;QAAEC;QAAQS,gBAAgB;YAAEH;YAASC;QAAY;IAAE;AAC5D;AAEA,OAAO,SAASC,iCACdP,UAAoD,EACpDF,aAA+B;IAE/B,MAAMW,OAAOT,WAAWU,MAAM,CAACD,IAAI;IACnC,MAAME,aAAaF,KAAKG,KAAK,EAAEH,MAAMJ;IACrC,MAAMQ,iBAAiBJ,KAAKH,WAAW;IAEvC,OAAO;QACLD,SAASM,aAAalB,mBAAmBkB,YAAYb,iBAAiBgB;QACtER,aAAaO,iBAAiBnB,uBAAuBmB,gBAAgBf,iBAAiBgB;IACxF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prometheus-datasource.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-datasource.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prometheus-datasource.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-datasource.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EASL,gBAAgB,EAIjB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AA8FnD,eAAO,MAAM,oBAAoB,EAAE,gBAAgB,CAAC,wBAAwB,EAAE,gBAAgB,CAK7F,CAAC"}
|
|
@@ -10,8 +10,16 @@
|
|
|
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 { healthCheck, instantQuery,
|
|
13
|
+
import { healthCheck, instantQuery, labelNames, labelValues, mergeQueryParams, metricMetadata, parseQuery, rangeQuery, series } from '../model';
|
|
14
14
|
import { PrometheusDatasourceEditor } from './PrometheusDatasourceEditor';
|
|
15
|
+
function wrapClientMethod(fn, datasourceUrl, specHeaders, specQueryParams) {
|
|
16
|
+
return (params, options)=>fn(params, {
|
|
17
|
+
datasourceUrl,
|
|
18
|
+
headers: options?.headers ?? specHeaders,
|
|
19
|
+
signal: options?.signal,
|
|
20
|
+
queryParams: mergeQueryParams(specQueryParams, options?.queryParams)
|
|
21
|
+
});
|
|
22
|
+
}
|
|
15
23
|
/**
|
|
16
24
|
* Creates a PrometheusClient for a specific datasource spec.
|
|
17
25
|
*/ const createClient = (spec, options)=>{
|
|
@@ -33,48 +41,13 @@ import { PrometheusDatasourceEditor } from './PrometheusDatasourceEditor';
|
|
|
33
41
|
headers: specHeaders,
|
|
34
42
|
queryParams
|
|
35
43
|
}),
|
|
36
|
-
instantQuery: (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
datasourceUrl,
|
|
44
|
-
headers: headers ?? specHeaders,
|
|
45
|
-
abortSignal,
|
|
46
|
-
queryParams
|
|
47
|
-
}),
|
|
48
|
-
labelNames: (params, headers, abortSignal)=>labelNames(params, {
|
|
49
|
-
datasourceUrl,
|
|
50
|
-
headers: headers ?? specHeaders,
|
|
51
|
-
abortSignal,
|
|
52
|
-
queryParams
|
|
53
|
-
}),
|
|
54
|
-
labelValues: (params, headers, abortSignal)=>labelValues(params, {
|
|
55
|
-
datasourceUrl,
|
|
56
|
-
headers: headers ?? specHeaders,
|
|
57
|
-
abortSignal,
|
|
58
|
-
queryParams
|
|
59
|
-
}),
|
|
60
|
-
metricMetadata: (params, headers, abortSignal)=>metricMetadata(params, {
|
|
61
|
-
datasourceUrl,
|
|
62
|
-
headers: headers ?? specHeaders,
|
|
63
|
-
abortSignal,
|
|
64
|
-
queryParams
|
|
65
|
-
}),
|
|
66
|
-
series: (params, headers, abortSignal)=>series(params, {
|
|
67
|
-
datasourceUrl,
|
|
68
|
-
headers: headers ?? specHeaders,
|
|
69
|
-
abortSignal,
|
|
70
|
-
queryParams
|
|
71
|
-
}),
|
|
72
|
-
parseQuery: (params, headers, abortSignal)=>parseQuery(params, {
|
|
73
|
-
datasourceUrl,
|
|
74
|
-
headers: headers ?? specHeaders,
|
|
75
|
-
abortSignal,
|
|
76
|
-
queryParams
|
|
77
|
-
})
|
|
44
|
+
instantQuery: wrapClientMethod(instantQuery, datasourceUrl, specHeaders, queryParams),
|
|
45
|
+
rangeQuery: wrapClientMethod(rangeQuery, datasourceUrl, specHeaders, queryParams),
|
|
46
|
+
labelNames: wrapClientMethod(labelNames, datasourceUrl, specHeaders, queryParams),
|
|
47
|
+
labelValues: wrapClientMethod(labelValues, datasourceUrl, specHeaders, queryParams),
|
|
48
|
+
metricMetadata: wrapClientMethod(metricMetadata, datasourceUrl, specHeaders, queryParams),
|
|
49
|
+
series: wrapClientMethod(series, datasourceUrl, specHeaders, queryParams),
|
|
50
|
+
parseQuery: wrapClientMethod(parseQuery, datasourceUrl, specHeaders, queryParams)
|
|
78
51
|
};
|
|
79
52
|
};
|
|
80
53
|
const getBuiltinVariableDefinitions = ()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/prometheus-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 { BuiltinVariableDefinition } from '@perses-dev/core';\nimport { DatasourcePlugin } from '@perses-dev/plugin-system';\nimport {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/prometheus-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 { QueryParamValues } from '@perses-dev/components';\nimport { BuiltinVariableDefinition, RequestHeaders } from '@perses-dev/core';\nimport { DatasourcePlugin } from '@perses-dev/plugin-system';\nimport {\n ClientRequestOptions,\n healthCheck,\n instantQuery,\n labelNames,\n labelValues,\n mergeQueryParams,\n metricMetadata,\n parseQuery,\n PrometheusClient,\n QueryOptions,\n rangeQuery,\n series,\n} from '../model';\nimport { PrometheusDatasourceEditor } from './PrometheusDatasourceEditor';\nimport { PrometheusDatasourceSpec } from './types';\n\nfunction wrapClientMethod<P, R>(\n fn: (params: P, opts: QueryOptions) => Promise<R>,\n datasourceUrl: string,\n specHeaders?: RequestHeaders,\n specQueryParams?: QueryParamValues\n): (params: P, options?: ClientRequestOptions) => Promise<R> {\n return (params: P, options?: ClientRequestOptions) =>\n fn(params, {\n datasourceUrl,\n headers: options?.headers ?? specHeaders,\n signal: options?.signal,\n queryParams: mergeQueryParams(specQueryParams, options?.queryParams),\n });\n}\n\n/**\n * Creates a PrometheusClient for a specific datasource spec.\n */\nconst createClient: DatasourcePlugin<PrometheusDatasourceSpec, PrometheusClient>['createClient'] = (spec, options) => {\n const { directUrl, proxy, queryParams } = spec;\n const { proxyUrl } = options;\n\n // Use the direct URL if specified, but fallback to the proxyUrl by default if not specified\n const datasourceUrl = directUrl ?? proxyUrl;\n if (datasourceUrl === undefined) {\n throw new Error('No URL specified for Prometheus client. You can use directUrl in the spec to configure it.');\n }\n\n const specHeaders = proxy?.spec.headers;\n\n // Could think about this becoming a class, although it definitely doesn't have to be\n return {\n options: {\n datasourceUrl,\n },\n healthCheck: healthCheck({ datasourceUrl, headers: specHeaders, queryParams }),\n instantQuery: wrapClientMethod(instantQuery, datasourceUrl, specHeaders, queryParams),\n rangeQuery: wrapClientMethod(rangeQuery, datasourceUrl, specHeaders, queryParams),\n labelNames: wrapClientMethod(labelNames, datasourceUrl, specHeaders, queryParams),\n labelValues: wrapClientMethod(labelValues, datasourceUrl, specHeaders, queryParams),\n metricMetadata: wrapClientMethod(metricMetadata, datasourceUrl, specHeaders, queryParams),\n series: wrapClientMethod(series, datasourceUrl, specHeaders, queryParams),\n parseQuery: wrapClientMethod(parseQuery, datasourceUrl, specHeaders, queryParams),\n };\n};\n\nconst getBuiltinVariableDefinitions: () => BuiltinVariableDefinition[] = () => {\n return [\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__interval',\n value: () => '$__interval', // will be overriden when time series query is called\n source: 'Prometheus',\n display: {\n name: '__interval',\n description:\n 'For dynamic queries that adapt across different time ranges, use $__interval instead of hardcoded intervals. It represents the actual spacing between data points: it’s calculated based on the current time range and the panel pixel width (taking the \"Min step\" as a lower bound).',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__interval_ms',\n value: () => '$__interval_ms', // will be overriden when time series query is called\n source: 'Prometheus',\n display: {\n name: '__interval_ms',\n description: 'Same as $__interval but in milliseconds.',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__rate_interval',\n value: () => '$__rate_interval', // will be overriden when time series query is called\n source: 'Prometheus',\n display: {\n name: '__rate_interval',\n description:\n 'Use this one rather than $__interval as the range parameter of functions like rate, increase, etc. With such function it is advised to choose a range that is at least 4x the scrape interval (this is to allow for various races, and to be resilient to a failed scrape). $__rate_interval provides that, as it is defined as `max($__interval + Min Step, 4 * Min Step)`, where Min Step value should represent the scrape interval of the metrics.',\n hidden: true,\n },\n },\n },\n ] as BuiltinVariableDefinition[];\n};\n\nexport const PrometheusDatasource: DatasourcePlugin<PrometheusDatasourceSpec, PrometheusClient> = {\n createClient,\n getBuiltinVariableDefinitions,\n OptionsEditorComponent: PrometheusDatasourceEditor,\n createInitialOptions: () => ({ directUrl: '' }),\n};\n"],"names":["healthCheck","instantQuery","labelNames","labelValues","mergeQueryParams","metricMetadata","parseQuery","rangeQuery","series","PrometheusDatasourceEditor","wrapClientMethod","fn","datasourceUrl","specHeaders","specQueryParams","params","options","headers","signal","queryParams","createClient","spec","directUrl","proxy","proxyUrl","undefined","Error","getBuiltinVariableDefinitions","kind","name","value","source","display","description","hidden","PrometheusDatasource","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,SAEEA,WAAW,EACXC,YAAY,EACZC,UAAU,EACVC,WAAW,EACXC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,EAGVC,UAAU,EACVC,MAAM,QACD,WAAW;AAClB,SAASC,0BAA0B,QAAQ,+BAA+B;AAG1E,SAASC,iBACPC,EAAiD,EACjDC,aAAqB,EACrBC,WAA4B,EAC5BC,eAAkC;IAElC,OAAO,CAACC,QAAWC,UACjBL,GAAGI,QAAQ;YACTH;YACAK,SAASD,SAASC,WAAWJ;YAC7BK,QAAQF,SAASE;YACjBC,aAAaf,iBAAiBU,iBAAiBE,SAASG;QAC1D;AACJ;AAEA;;CAEC,GACD,MAAMC,eAA6F,CAACC,MAAML;IACxG,MAAM,EAAEM,SAAS,EAAEC,KAAK,EAAEJ,WAAW,EAAE,GAAGE;IAC1C,MAAM,EAAEG,QAAQ,EAAE,GAAGR;IAErB,4FAA4F;IAC5F,MAAMJ,gBAAgBU,aAAaE;IACnC,IAAIZ,kBAAkBa,WAAW;QAC/B,MAAM,IAAIC,MAAM;IAClB;IAEA,MAAMb,cAAcU,OAAOF,KAAKJ;IAEhC,qFAAqF;IACrF,OAAO;QACLD,SAAS;YACPJ;QACF;QACAZ,aAAaA,YAAY;YAAEY;YAAeK,SAASJ;YAAaM;QAAY;QAC5ElB,cAAcS,iBAAiBT,cAAcW,eAAeC,aAAaM;QACzEZ,YAAYG,iBAAiBH,YAAYK,eAAeC,aAAaM;QACrEjB,YAAYQ,iBAAiBR,YAAYU,eAAeC,aAAaM;QACrEhB,aAAaO,iBAAiBP,aAAaS,eAAeC,aAAaM;QACvEd,gBAAgBK,iBAAiBL,gBAAgBO,eAAeC,aAAaM;QAC7EX,QAAQE,iBAAiBF,QAAQI,eAAeC,aAAaM;QAC7Db,YAAYI,iBAAiBJ,YAAYM,eAAeC,aAAaM;IACvE;AACF;AAEA,MAAMQ,gCAAmE;IACvE,OAAO;QACL;YACEC,MAAM;YACNP,MAAM;gBACJQ,MAAM;gBACNC,OAAO,IAAM;gBACbC,QAAQ;gBACRC,SAAS;oBACPH,MAAM;oBACNI,aACE;oBACFC,QAAQ;gBACV;YACF;QACF;QACA;YACEN,MAAM;YACNP,MAAM;gBACJQ,MAAM;gBACNC,OAAO,IAAM;gBACbC,QAAQ;gBACRC,SAAS;oBACPH,MAAM;oBACNI,aAAa;oBACbC,QAAQ;gBACV;YACF;QACF;QACA;YACEN,MAAM;YACNP,MAAM;gBACJQ,MAAM;gBACNC,OAAO,IAAM;gBACbC,QAAQ;gBACRC,SAAS;oBACPH,MAAM;oBACNI,aACE;oBACFC,QAAQ;gBACV;YACF;QACF;KACD;AACH;AAEA,OAAO,MAAMC,uBAAqF;IAChGf;IACAO;IACAS,wBAAwB3B;IACxB4B,sBAAsB,IAAO,CAAA;YAAEf,WAAW;QAAG,CAAA;AAC/C,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-time-series-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/prometheus-time-series-query/get-time-series-data.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,qBAAqB,EAAqD,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"get-time-series-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/prometheus-time-series-query/get-time-series-data.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,qBAAqB,EAAqD,MAAM,2BAA2B,CAAC;AAkBrH,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAG1E,eAAO,MAAM,iBAAiB,EAAE,qBAAqB,CAAC,6BAA6B,CAAC,CAAC,mBAAmB,CAuHvG,CAAC"}
|
|
@@ -15,6 +15,7 @@ import { datasourceSelectValueToSelector, replaceVariables } from '@perses-dev/p
|
|
|
15
15
|
import { fromUnixTime, milliseconds } from 'date-fns';
|
|
16
16
|
import { parseValueTuple, getDurationStringSeconds, getPrometheusTimeRange, getRangeStep, DEFAULT_PROM, PROM_DATASOURCE_KIND } from '../../model';
|
|
17
17
|
import { getFormattedPrometheusSeriesName } from '../../utils';
|
|
18
|
+
import { interpolateDatasourceProxyParams } from '../interpolation';
|
|
18
19
|
import { DEFAULT_SCRAPE_INTERVAL } from '../types';
|
|
19
20
|
import { replacePromBuiltinVariables } from './replace-prom-builtin-variables';
|
|
20
21
|
export const getTimeSeriesData = async (spec, context, abortSignal)=>{
|
|
@@ -27,6 +28,7 @@ export const getTimeSeriesData = async (spec, context, abortSignal)=>{
|
|
|
27
28
|
const listDatasourceSelectItems = await context.datasourceStore.listDatasourceSelectItems(PROM_DATASOURCE_KIND);
|
|
28
29
|
const selectedDatasource = datasourceSelectValueToSelector(spec.datasource ?? DEFAULT_PROM, context.variableState, listDatasourceSelectItems) ?? DEFAULT_PROM;
|
|
29
30
|
const datasource = await context.datasourceStore.getDatasource(selectedDatasource);
|
|
31
|
+
const interpolatedOptions = interpolateDatasourceProxyParams(datasource, context.variableState);
|
|
30
32
|
const datasourceScrapeInterval = Math.trunc(milliseconds(parseDurationString(datasource.plugin.spec.scrapeInterval ?? DEFAULT_SCRAPE_INTERVAL)) / 1000);
|
|
31
33
|
// Min step is the lower bound of the interval between data points
|
|
32
34
|
// If no value is provided for it, it should default to the scrape interval of the datasource
|
|
@@ -69,7 +71,10 @@ export const getTimeSeriesData = async (spec, context, abortSignal)=>{
|
|
|
69
71
|
response = await client.instantQuery({
|
|
70
72
|
query,
|
|
71
73
|
time: end
|
|
72
|
-
},
|
|
74
|
+
}, {
|
|
75
|
+
...interpolatedOptions,
|
|
76
|
+
signal: abortSignal
|
|
77
|
+
});
|
|
73
78
|
break;
|
|
74
79
|
case 'range':
|
|
75
80
|
default:
|
|
@@ -78,7 +83,10 @@ export const getTimeSeriesData = async (spec, context, abortSignal)=>{
|
|
|
78
83
|
start,
|
|
79
84
|
end,
|
|
80
85
|
step
|
|
81
|
-
},
|
|
86
|
+
}, {
|
|
87
|
+
...interpolatedOptions,
|
|
88
|
+
signal: abortSignal
|
|
89
|
+
});
|
|
82
90
|
break;
|
|
83
91
|
}
|
|
84
92
|
// TODO: What about error responses from Prom that have a response body?
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/prometheus-time-series-query/get-time-series-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 {\n DatasourceSpec,\n DurationString,\n Notice,\n parseDurationString,\n TimeSeries,\n TimeSeriesData,\n} from '@perses-dev/core';\nimport { TimeSeriesQueryPlugin, datasourceSelectValueToSelector, replaceVariables } from '@perses-dev/plugin-system';\nimport { fromUnixTime, milliseconds } from 'date-fns';\nimport {\n parseValueTuple,\n PrometheusClient,\n getDurationStringSeconds,\n getPrometheusTimeRange,\n getRangeStep,\n DEFAULT_PROM,\n MatrixData,\n VectorData,\n ScalarData,\n InstantQueryResultType,\n PROM_DATASOURCE_KIND,\n} from '../../model';\nimport { getFormattedPrometheusSeriesName } from '../../utils';\nimport { DEFAULT_SCRAPE_INTERVAL, PrometheusDatasourceSpec } from '../types';\nimport { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';\nimport { replacePromBuiltinVariables } from './replace-prom-builtin-variables';\n\nexport const getTimeSeriesData: TimeSeriesQueryPlugin<PrometheusTimeSeriesQuerySpec>['getTimeSeriesData'] = async (\n spec,\n context,\n abortSignal\n) => {\n if (spec.query === undefined || spec.query === null || spec.query === '') {\n // Do not make a request to the backend, instead return an empty TimeSeriesData\n return { series: [] };\n }\n\n const listDatasourceSelectItems = await context.datasourceStore.listDatasourceSelectItems(PROM_DATASOURCE_KIND);\n\n const selectedDatasource =\n datasourceSelectValueToSelector(\n spec.datasource ?? DEFAULT_PROM,\n context.variableState,\n listDatasourceSelectItems\n ) ?? DEFAULT_PROM;\n\n const datasource = (await context.datasourceStore.getDatasource(\n selectedDatasource\n )) as DatasourceSpec<PrometheusDatasourceSpec>;\n const datasourceScrapeInterval = Math.trunc(\n milliseconds(parseDurationString(datasource.plugin.spec.scrapeInterval ?? DEFAULT_SCRAPE_INTERVAL)) / 1000\n );\n\n // Min step is the lower bound of the interval between data points\n // If no value is provided for it, it should default to the scrape interval of the datasource\n const minStep =\n getDurationStringSeconds(\n // resolve any variable that may have been provided\n // TODO add a validation check to make sure the variable is a DurationString, to avoid the back & forth cast here\n replaceVariables(spec.minStep as string, context.variableState) as DurationString\n ) ?? datasourceScrapeInterval;\n\n const timeRange = getPrometheusTimeRange(context.timeRange);\n const step = getRangeStep(timeRange, minStep, undefined, context.suggestedStepMs); // TODO: resolution\n\n // Align the time range so that it's a multiple of the step\n let { start, end } = timeRange;\n\n const utcOffsetSec = new Date().getTimezoneOffset() * 60;\n\n const alignedEnd = Math.floor((end + utcOffsetSec) / step) * step - utcOffsetSec;\n const alignedStart = Math.floor((start + utcOffsetSec) / step) * step - utcOffsetSec;\n start = alignedStart;\n end = alignedEnd;\n\n /* Ensure end is always greater than start:\n If the step is greater than equal to the diff of end and start,\n both start, and end will eventually be rounded to the same value,\n Consequently, the time range will be zero, which does not return any valid value\n */\n if (end === start) {\n end = start + step;\n console.warn(`Step (${step}) was larger than the time range! end of time range was set accordingly.`);\n }\n\n // Replace variable placeholders in PromQL query\n const intervalMs = step * 1000;\n const minStepMs = minStep * 1000;\n\n let query = replacePromBuiltinVariables(spec.query, minStepMs, intervalMs);\n query = replaceVariables(query, context.variableState);\n\n let seriesNameFormat = spec.seriesNameFormat;\n // if series name format is defined, replace variable placeholders in series name format\n if (seriesNameFormat) {\n seriesNameFormat = replaceVariables(seriesNameFormat, context.variableState);\n }\n\n // Get the datasource, using the default Prom Datasource if one isn't specified in the query\n const client: PrometheusClient = await context.datasourceStore.getDatasourceClient(selectedDatasource);\n\n // Make the request to Prom\n\n let response;\n switch (context.mode) {\n case 'instant':\n response = await client.instantQuery(\n {\n query,\n time: end,\n },\n undefined,\n abortSignal\n );\n break;\n case 'range':\n default:\n response = await client.rangeQuery(\n {\n query,\n start,\n end,\n step,\n },\n undefined,\n abortSignal\n );\n break;\n }\n\n // TODO: What about error responses from Prom that have a response body?\n const result = response.data;\n\n // Custom display for response header warnings, configurable error responses display coming next\n const notices: Notice[] = [];\n if (response.status === 'success') {\n const warnings = response.warnings ?? [];\n const warningMessage = warnings[0] ?? '';\n if (warningMessage !== '') {\n notices.push({\n type: 'warning',\n message: warningMessage,\n });\n }\n }\n\n // Transform response\n const chartData: TimeSeriesData = {\n // Return the time range and step we actually used for the query\n timeRange: { start: fromUnixTime(start), end: fromUnixTime(end) },\n stepMs: step * 1000,\n\n series: buildTimeSeries(query, result, seriesNameFormat),\n metadata: {\n notices,\n executedQueryString: query,\n },\n };\n\n return chartData;\n};\n\nfunction buildVectorData(query: string, data: VectorData, seriesNameFormat: string | undefined): TimeSeries[] {\n return data.result.map((res) => {\n const { metric, value, histogram } = res;\n\n // Account for seriesNameFormat from query editor when determining name to show in legend, tooltip, etc.\n const { name, formattedName } = getFormattedPrometheusSeriesName(query, metric, seriesNameFormat);\n\n if (histogram) {\n return {\n name,\n formattedName,\n labels: metric,\n values: [parseValueTuple([histogram[0], histogram[1].sum])],\n histograms: [histogram],\n };\n }\n\n return {\n name,\n formattedName,\n labels: metric,\n values: [parseValueTuple(value)],\n };\n });\n}\n\nfunction buildMatrixData(query: string, data: MatrixData, seriesNameFormat: string | undefined): TimeSeries[] {\n return data.result.map((res) => {\n const { metric, values, histograms } = res;\n\n // Account for seriesNameFormat from query editor when determining name to show in legend, tooltip, etc.\n const { name, formattedName } = getFormattedPrometheusSeriesName(query, metric, seriesNameFormat);\n\n if (histograms) {\n return {\n name,\n formattedName,\n labels: metric,\n values: histograms.map((histogram) => parseValueTuple([histogram[0], histogram[1].sum])),\n histograms: histograms.map((histogram) => histogram),\n };\n }\n\n return {\n name,\n formattedName,\n labels: metric,\n values: values.map(parseValueTuple),\n };\n });\n}\n\nfunction buildScalarData(query: string, data: ScalarData, seriesNameFormat: string | undefined): TimeSeries[] {\n const { name, formattedName } = getFormattedPrometheusSeriesName(query, {}, seriesNameFormat);\n return [\n {\n name,\n values: [parseValueTuple(data.result)],\n formattedName,\n },\n ];\n}\n\nfunction buildTimeSeries(query: string, data?: InstantQueryResultType, seriesNameFormat?: string): TimeSeries[] {\n if (!data) {\n return [];\n }\n\n const resultType = data.resultType;\n switch (resultType) {\n case 'vector':\n return buildVectorData(query, data, seriesNameFormat);\n case 'matrix':\n return buildMatrixData(query, data, seriesNameFormat);\n case 'scalar':\n return buildScalarData(query, data, seriesNameFormat);\n default:\n console.warn('Unknown result type', resultType, data);\n return [];\n }\n}\n"],"names":["parseDurationString","datasourceSelectValueToSelector","replaceVariables","fromUnixTime","milliseconds","parseValueTuple","getDurationStringSeconds","getPrometheusTimeRange","getRangeStep","DEFAULT_PROM","PROM_DATASOURCE_KIND","getFormattedPrometheusSeriesName","DEFAULT_SCRAPE_INTERVAL","replacePromBuiltinVariables","getTimeSeriesData","spec","context","abortSignal","query","undefined","series","listDatasourceSelectItems","datasourceStore","selectedDatasource","datasource","variableState","getDatasource","datasourceScrapeInterval","Math","trunc","plugin","scrapeInterval","minStep","timeRange","step","suggestedStepMs","start","end","utcOffsetSec","Date","getTimezoneOffset","alignedEnd","floor","alignedStart","console","warn","intervalMs","minStepMs","seriesNameFormat","client","getDatasourceClient","response","mode","instantQuery","time","rangeQuery","result","data","notices","status","warnings","warningMessage","push","type","message","chartData","stepMs","buildTimeSeries","metadata","executedQueryString","buildVectorData","map","res","metric","value","histogram","name","formattedName","labels","values","sum","histograms","buildMatrixData","buildScalarData","resultType"],"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,SAIEA,mBAAmB,QAGd,mBAAmB;AAC1B,SAAgCC,+BAA+B,EAAEC,gBAAgB,QAAQ,4BAA4B;AACrH,SAASC,YAAY,EAAEC,YAAY,QAAQ,WAAW;AACtD,SACEC,eAAe,EAEfC,wBAAwB,EACxBC,sBAAsB,EACtBC,YAAY,EACZC,YAAY,EAKZC,oBAAoB,QACf,cAAc;AACrB,SAASC,gCAAgC,QAAQ,cAAc;AAC/D,SAASC,uBAAuB,QAAkC,WAAW;AAE7E,SAASC,2BAA2B,QAAQ,mCAAmC;AAE/E,OAAO,MAAMC,oBAA+F,OAC1GC,MACAC,SACAC;IAEA,IAAIF,KAAKG,KAAK,KAAKC,aAAaJ,KAAKG,KAAK,KAAK,QAAQH,KAAKG,KAAK,KAAK,IAAI;QACxE,+EAA+E;QAC/E,OAAO;YAAEE,QAAQ,EAAE;QAAC;IACtB;IAEA,MAAMC,4BAA4B,MAAML,QAAQM,eAAe,CAACD,yBAAyB,CAACX;IAE1F,MAAMa,qBACJtB,gCACEc,KAAKS,UAAU,IAAIf,cACnBO,QAAQS,aAAa,EACrBJ,8BACGZ;IAEP,MAAMe,aAAc,MAAMR,QAAQM,eAAe,CAACI,aAAa,CAC7DH;IAEF,MAAMI,2BAA2BC,KAAKC,KAAK,CACzCzB,aAAaJ,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OAAOkC,gBAAgBhE,OAAOuC,MAAMT;QACtC,KAAK;YACH,OAAOmC,gBAAgBjE,OAAOuC,MAAMT;QACtC;YACEJ,QAAQC,IAAI,CAAC,uBAAuBuC,YAAY3B;YAChD,OAAO,EAAE;IACb;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/prometheus-time-series-query/get-time-series-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 {\n DatasourceSpec,\n DurationString,\n Notice,\n parseDurationString,\n TimeSeries,\n TimeSeriesData,\n} from '@perses-dev/core';\nimport { TimeSeriesQueryPlugin, datasourceSelectValueToSelector, replaceVariables } from '@perses-dev/plugin-system';\nimport { fromUnixTime, milliseconds } from 'date-fns';\nimport {\n parseValueTuple,\n PrometheusClient,\n getDurationStringSeconds,\n getPrometheusTimeRange,\n getRangeStep,\n DEFAULT_PROM,\n MatrixData,\n VectorData,\n ScalarData,\n InstantQueryResultType,\n PROM_DATASOURCE_KIND,\n} from '../../model';\nimport { getFormattedPrometheusSeriesName } from '../../utils';\nimport { interpolateDatasourceProxyParams } from '../interpolation';\nimport { DEFAULT_SCRAPE_INTERVAL, PrometheusDatasourceSpec } from '../types';\nimport { PrometheusTimeSeriesQuerySpec } from './time-series-query-model';\nimport { replacePromBuiltinVariables } from './replace-prom-builtin-variables';\n\nexport const getTimeSeriesData: TimeSeriesQueryPlugin<PrometheusTimeSeriesQuerySpec>['getTimeSeriesData'] = async (\n spec,\n context,\n abortSignal\n) => {\n if (spec.query === undefined || spec.query === null || spec.query === '') {\n // Do not make a request to the backend, instead return an empty TimeSeriesData\n return { series: [] };\n }\n\n const listDatasourceSelectItems = await context.datasourceStore.listDatasourceSelectItems(PROM_DATASOURCE_KIND);\n\n const selectedDatasource =\n datasourceSelectValueToSelector(\n spec.datasource ?? DEFAULT_PROM,\n context.variableState,\n listDatasourceSelectItems\n ) ?? DEFAULT_PROM;\n\n const datasource = (await context.datasourceStore.getDatasource(\n selectedDatasource\n )) as DatasourceSpec<PrometheusDatasourceSpec>;\n const interpolatedOptions = interpolateDatasourceProxyParams(datasource, context.variableState);\n\n const datasourceScrapeInterval = Math.trunc(\n milliseconds(parseDurationString(datasource.plugin.spec.scrapeInterval ?? DEFAULT_SCRAPE_INTERVAL)) / 1000\n );\n\n // Min step is the lower bound of the interval between data points\n // If no value is provided for it, it should default to the scrape interval of the datasource\n const minStep =\n getDurationStringSeconds(\n // resolve any variable that may have been provided\n // TODO add a validation check to make sure the variable is a DurationString, to avoid the back & forth cast here\n replaceVariables(spec.minStep as string, context.variableState) as DurationString\n ) ?? datasourceScrapeInterval;\n\n const timeRange = getPrometheusTimeRange(context.timeRange);\n const step = getRangeStep(timeRange, minStep, undefined, context.suggestedStepMs); // TODO: resolution\n\n // Align the time range so that it's a multiple of the step\n let { start, end } = timeRange;\n\n const utcOffsetSec = new Date().getTimezoneOffset() * 60;\n\n const alignedEnd = Math.floor((end + utcOffsetSec) / step) * step - utcOffsetSec;\n const alignedStart = Math.floor((start + utcOffsetSec) / step) * step - utcOffsetSec;\n start = alignedStart;\n end = alignedEnd;\n\n /* Ensure end is always greater than start:\n If the step is greater than equal to the diff of end and start,\n both start, and end will eventually be rounded to the same value,\n Consequently, the time range will be zero, which does not return any valid value\n */\n if (end === start) {\n end = start + step;\n console.warn(`Step (${step}) was larger than the time range! end of time range was set accordingly.`);\n }\n\n // Replace variable placeholders in PromQL query\n const intervalMs = step * 1000;\n const minStepMs = minStep * 1000;\n\n let query = replacePromBuiltinVariables(spec.query, minStepMs, intervalMs);\n query = replaceVariables(query, context.variableState);\n\n let seriesNameFormat = spec.seriesNameFormat;\n // if series name format is defined, replace variable placeholders in series name format\n if (seriesNameFormat) {\n seriesNameFormat = replaceVariables(seriesNameFormat, context.variableState);\n }\n\n // Get the datasource, using the default Prom Datasource if one isn't specified in the query\n const client: PrometheusClient = await context.datasourceStore.getDatasourceClient(selectedDatasource);\n\n // Make the request to Prom\n\n let response;\n switch (context.mode) {\n case 'instant':\n response = await client.instantQuery({ query, time: end }, { ...interpolatedOptions, signal: abortSignal });\n break;\n case 'range':\n default:\n response = await client.rangeQuery({ query, start, end, step }, { ...interpolatedOptions, signal: abortSignal });\n break;\n }\n\n // TODO: What about error responses from Prom that have a response body?\n const result = response.data;\n\n // Custom display for response header warnings, configurable error responses display coming next\n const notices: Notice[] = [];\n if (response.status === 'success') {\n const warnings = response.warnings ?? [];\n const warningMessage = warnings[0] ?? '';\n if (warningMessage !== '') {\n notices.push({\n type: 'warning',\n message: warningMessage,\n });\n }\n }\n\n // Transform response\n const chartData: TimeSeriesData = {\n // Return the time range and step we actually used for the query\n timeRange: { start: fromUnixTime(start), end: fromUnixTime(end) },\n stepMs: step * 1000,\n\n series: buildTimeSeries(query, result, seriesNameFormat),\n metadata: {\n notices,\n executedQueryString: query,\n },\n };\n\n return chartData;\n};\n\nfunction buildVectorData(query: string, data: VectorData, seriesNameFormat: string | undefined): TimeSeries[] {\n return data.result.map((res) => {\n const { metric, value, histogram } = res;\n\n // Account for seriesNameFormat from query editor when determining name to show in legend, tooltip, etc.\n const { name, formattedName } = getFormattedPrometheusSeriesName(query, metric, seriesNameFormat);\n\n if (histogram) {\n return {\n name,\n formattedName,\n labels: metric,\n values: [parseValueTuple([histogram[0], histogram[1].sum])],\n histograms: [histogram],\n };\n }\n\n return {\n name,\n formattedName,\n labels: metric,\n values: [parseValueTuple(value)],\n };\n });\n}\n\nfunction buildMatrixData(query: string, data: MatrixData, seriesNameFormat: string | undefined): TimeSeries[] {\n return data.result.map((res) => {\n const { metric, values, histograms } = res;\n\n // Account for seriesNameFormat from query editor when determining name to show in legend, tooltip, etc.\n const { name, formattedName } = getFormattedPrometheusSeriesName(query, metric, seriesNameFormat);\n\n if (histograms) {\n return {\n name,\n formattedName,\n labels: metric,\n values: histograms.map((histogram) => parseValueTuple([histogram[0], histogram[1].sum])),\n histograms: histograms.map((histogram) => histogram),\n };\n }\n\n return {\n name,\n formattedName,\n labels: metric,\n values: values.map(parseValueTuple),\n };\n });\n}\n\nfunction buildScalarData(query: string, data: ScalarData, seriesNameFormat: string | undefined): TimeSeries[] {\n const { name, formattedName } = getFormattedPrometheusSeriesName(query, {}, seriesNameFormat);\n return [\n {\n name,\n values: [parseValueTuple(data.result)],\n formattedName,\n },\n ];\n}\n\nfunction buildTimeSeries(query: string, data?: InstantQueryResultType, seriesNameFormat?: string): TimeSeries[] {\n if (!data) {\n return [];\n }\n\n const resultType = data.resultType;\n switch (resultType) {\n case 'vector':\n return buildVectorData(query, data, seriesNameFormat);\n case 'matrix':\n return buildMatrixData(query, data, seriesNameFormat);\n case 'scalar':\n return buildScalarData(query, data, seriesNameFormat);\n default:\n console.warn('Unknown result type', resultType, data);\n return [];\n }\n}\n"],"names":["parseDurationString","datasourceSelectValueToSelector","replaceVariables","fromUnixTime","milliseconds","parseValueTuple","getDurationStringSeconds","getPrometheusTimeRange","getRangeStep","DEFAULT_PROM","PROM_DATASOURCE_KIND","getFormattedPrometheusSeriesName","interpolateDatasourceProxyParams","DEFAULT_SCRAPE_INTERVAL","replacePromBuiltinVariables","getTimeSeriesData","spec","context","abortSignal","query","undefined","series","listDatasourceSelectItems","datasourceStore","selectedDatasource","datasource","variableState","getDatasource","interpolatedOptions","datasourceScrapeInterval","Math","trunc","plugin","scrapeInterval","minStep","timeRange","step","suggestedStepMs","start","end","utcOffsetSec","Date","getTimezoneOffset","alignedEnd","floor","alignedStart","console","warn","intervalMs","minStepMs","seriesNameFormat","client","getDatasourceClient","response","mode","instantQuery","time","signal","rangeQuery","result","data","notices","status","warnings","warningMessage","push","type","message","chartData","stepMs","buildTimeSeries","metadata","executedQueryString","buildVectorData","map","res","metric","value","histogram","name","formattedName","labels","values","sum","histograms","buildMatrixData","buildScalarData","resultType"],"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,SAIEA,mBAAmB,QAGd,mBAAmB;AAC1B,SAAgCC,+BAA+B,EAAEC,gBAAgB,QAAQ,4BAA4B;AACrH,SAASC,YAAY,EAAEC,YAAY,QAAQ,WAAW;AACtD,SACEC,eAAe,EAEfC,wBAAwB,EACxBC,sBAAsB,EACtBC,YAAY,EACZC,YAAY,EAKZC,oBAAoB,QACf,cAAc;AACrB,SAASC,gCAAgC,QAAQ,cAAc;AAC/D,SAASC,gCAAgC,QAAQ,mBAAmB;AACpE,SAASC,uBAAuB,QAAkC,WAAW;AAE7E,SAASC,2BAA2B,QAAQ,mCAAmC;AAE/E,OAAO,MAAMC,oBAA+F,OAC1GC,MACAC,SACAC;IAEA,IAAIF,KAAKG,KAAK,KAAKC,aAAaJ,KAAKG,KAAK,KAAK,QAAQH,KAAKG,KAAK,KAAK,IAAI;QACxE,+EAA+E;QAC/E,OAAO;YAAEE,QAAQ,EAAE;QAAC;IACtB;IAEA,MAAMC,4BAA4B,MAAML,QAAQM,eAAe,CAACD,yBAAyB,CAACZ;IAE1F,MAAMc,qBACJvB,gCACEe,KAAKS,UAAU,IAAIhB,cACnBQ,QAAQS,aAAa,EACrBJ,8BACGb;IAEP,MAAMgB,aAAc,MAAMR,QAAQM,eAAe,CAACI,aAAa,CAC7DH;IAEF,MAAMI,sBAAsBhB,iCAAiCa,YAAYR,QAAQS,aAAa;IAE9F,MAAMG,2BAA2BC,KAAKC,KAAK,CACzC3B,aAAaJ,oBAAoByB,WAAWO,MAAM,CAAChB,IAAI,CAACiB,cAAc,IAAIpB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Od,gBAAgBtD,OAAOyC,MAAMV;QACtC,KAAK;YACH,OAAOmC,gBAAgBlE,OAAOyC,MAAMV;QACtC,KAAK;YACH,OAAOoC,gBAAgBnE,OAAOyC,MAAMV;QACtC;YACEJ,QAAQC,IAAI,CAAC,uBAAuBwC,YAAY3B;YAChD,OAAO,EAAE;IACb;AACF"}
|
package/lib/plugins/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { QueryParamValues } from '@perses-dev/components';
|
|
1
2
|
import { DurationString, HTTPProxy } from '@perses-dev/core';
|
|
2
3
|
import { DatasourceSelectValue } from '@perses-dev/plugin-system';
|
|
3
4
|
import { PrometheusDatasourceSelector } from '../model';
|
|
@@ -6,7 +7,7 @@ export interface PrometheusDatasourceSpec {
|
|
|
6
7
|
directUrl?: string;
|
|
7
8
|
proxy?: HTTPProxy;
|
|
8
9
|
scrapeInterval?: DurationString;
|
|
9
|
-
queryParams?:
|
|
10
|
+
queryParams?: QueryParamValues;
|
|
10
11
|
}
|
|
11
12
|
export interface PrometheusVariableOptionsBase {
|
|
12
13
|
datasource?: DatasourceSelectValue<PrometheusDatasourceSelector>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/types.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAExD,eAAO,MAAM,uBAAuB,EAAE,cAAqB,CAAC;AAE5D,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,WAAW,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/types.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAExD,eAAO,MAAM,uBAAuB,EAAE,cAAqB,CAAC;AAE5D,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAED,MAAM,WAAW,6BAA6B;IAC5C,UAAU,CAAC,EAAE,qBAAqB,CAAC,4BAA4B,CAAC,CAAC;CAClE;AAED,MAAM,MAAM,mCAAmC,GAAG,6BAA6B,GAAG;IAChF,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG,6BAA6B,GAAG;IACjF,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG,6BAA6B,GAAG;IAE5E,IAAI,EAAE,MAAM,CAAC;IAGb,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
package/lib/plugins/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/types.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 { DurationString, HTTPProxy } from '@perses-dev/core';\nimport { DatasourceSelectValue } from '@perses-dev/plugin-system';\nimport { PrometheusDatasourceSelector } from '../model';\n\nexport const DEFAULT_SCRAPE_INTERVAL: DurationString = '1m';\n\nexport interface PrometheusDatasourceSpec {\n directUrl?: string;\n proxy?: HTTPProxy;\n scrapeInterval?: DurationString; // default to 1m\n queryParams?:
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/types.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 { QueryParamValues } from '@perses-dev/components';\nimport { DurationString, HTTPProxy } from '@perses-dev/core';\nimport { DatasourceSelectValue } from '@perses-dev/plugin-system';\nimport { PrometheusDatasourceSelector } from '../model';\n\nexport const DEFAULT_SCRAPE_INTERVAL: DurationString = '1m';\n\nexport interface PrometheusDatasourceSpec {\n directUrl?: string;\n proxy?: HTTPProxy;\n scrapeInterval?: DurationString; // default to 1m\n queryParams?: QueryParamValues;\n}\n\nexport interface PrometheusVariableOptionsBase {\n datasource?: DatasourceSelectValue<PrometheusDatasourceSelector>;\n}\n\nexport type PrometheusLabelNamesVariableOptions = PrometheusVariableOptionsBase & {\n matchers?: string[];\n};\n\nexport type PrometheusLabelValuesVariableOptions = PrometheusVariableOptionsBase & {\n labelName: string;\n matchers?: string[];\n};\n\nexport type PrometheusPromQLVariableOptions = PrometheusVariableOptionsBase & {\n // expr is the PromQL expression.\n expr: string;\n // labelName is the name of the label that will be used after the PromQL query is performed to select the label value.\n // Note: This field is not part of the Prometheus API.\n labelName: string;\n};\n"],"names":["DEFAULT_SCRAPE_INTERVAL"],"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;AAOjC,OAAO,MAAMA,0BAA0C,KAAK"}
|