@perses-dev/prometheus-plugin 0.53.0 → 0.53.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.
Files changed (34) hide show
  1. package/__mf/js/{Prometheus.712b445d.js → Prometheus.7d2f1afa.js} +3 -3
  2. package/__mf/js/async/{8706.9a6f6579.js → 8706.a36614fb.js} +1 -1
  3. package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.86bf76a6.js +1 -0
  4. package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.e5e35f24.js +1 -0
  5. package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.b2270799.js +1 -0
  6. package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.82b19cf2.js +1 -0
  7. package/__mf/js/{main.61a2057a.js → main.b9fe0e65.js} +2 -2
  8. package/lib/cjs/components/PromQLEditor.js +3 -1
  9. package/lib/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +17 -6
  10. package/lib/cjs/plugins/prometheus-variables.js +108 -46
  11. package/lib/components/PromQLEditor.d.ts +2 -1
  12. package/lib/components/PromQLEditor.d.ts.map +1 -1
  13. package/lib/components/PromQLEditor.js +3 -1
  14. package/lib/components/PromQLEditor.js.map +1 -1
  15. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
  16. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +17 -6
  17. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
  18. package/lib/plugins/prometheus-variables.d.ts.map +1 -1
  19. package/lib/plugins/prometheus-variables.js +115 -47
  20. package/lib/plugins/prometheus-variables.js.map +1 -1
  21. package/lib/plugins/test/setup-tests.d.ts.map +1 -0
  22. package/lib/plugins/test/setup-tests.js.map +1 -0
  23. package/mf-manifest.json +24 -24
  24. package/mf-stats.json +29 -29
  25. package/package.json +3 -3
  26. package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.e7eaadbd.js +0 -1
  27. package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.24d74e40.js +0 -1
  28. package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.ea97322b.js +0 -1
  29. package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.90b49f7e.js +0 -1
  30. package/lib/test/setup-tests.d.ts.map +0 -1
  31. package/lib/test/setup-tests.js.map +0 -1
  32. /package/lib/cjs/{test → plugins/test}/setup-tests.js +0 -0
  33. /package/lib/{test → plugins/test}/setup-tests.d.ts +0 -0
  34. /package/lib/{test → plugins/test}/setup-tests.js +0 -0
@@ -1 +0,0 @@
1
- "use strict";(self.chunk_Prometheus=self.chunk_Prometheus||[]).push([["9606"],{44301:function(e,t,a){a.r(t),a.d(t,{PrometheusTimeSeriesQuery:()=>y});var r=a(8887),s=a(29085),l=a(20461),n=a(99176);function u(e,t){let a=[];return Object.keys(e).sort().forEach(r=>{let s=e[r];void 0!==s&&(t?a.push(`"${r}":"${s}"`):a.push(`${r}="${s}"`))}),`{${a.join(",")}}`}function i(e,t,a){let r=function(e){let{removeExprWrap:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a="__name__";if(Object.prototype.hasOwnProperty.call(e,a)){let r=u({...e,[a]:void 0},t);return t?`${r}`:`${e[a]}${r}`}return u(e,t)}(t),s=a?a.replace(/\{\{\s*(.+?)\s*\}\}/g,(e,a)=>t[a]??""):r;return{name:r,formattedName:s}}var o=a(16146),c=a(17197);let d=async(e,t)=>{let a;if(void 0===e.query||null===e.query||""===e.query)return{series:[]};let u=await t.datasourceStore.listDatasourceSelectItems(n.nY),d=(0,r.datasourceSelectValueToSelector)(e.datasource??n.Mm,t.variableState,u)??n.Mm,m=await t.datasourceStore.getDatasource(d),p=Math.trunc((0,l.milliseconds)((0,s.Ib)(m.plugin.spec.scrapeInterval??o.v))/1e3),h=(0,n.k7)((0,r.replaceVariables)(e.minStep,t.variableState))??p,v=(0,n.Bf)(t.timeRange),g=(0,n.wd)(v,h,void 0,t.suggestedStepMs),{start:S,end:b}=v,f=60*new Date().getTimezoneOffset(),y=Math.floor((b+f)/g)*g-f;S=Math.floor((S+f)/g)*g-f,(b=y)===S&&(b=S+g,console.warn(`Step (${g}) was larger than the time range! end of time range was set accordingly.`));let w=(0,c.d)(e.query,1e3*h,1e3*g);w=(0,r.replaceVariables)(w,t.variableState);let x=e.seriesNameFormat;x&&(x=(0,r.replaceVariables)(x,t.variableState));let q=await t.datasourceStore.getDatasourceClient(d),C=(a="instant"===t.mode?await q.instantQuery({query:w,time:b}):await q.rangeQuery({query:w,start:S,end:b,step:g})).data,O=[];if("success"===a.status){let e=(a.warnings??[])[0]??"";""!==e&&O.push({type:"warning",message:e})}return{timeRange:{start:(0,l.fromUnixTime)(S),end:(0,l.fromUnixTime)(b)},stepMs:1e3*g,series:function(e,t,a){if(!t)return[];let r=t.resultType;switch(r){case"vector":return t.result.map(t=>{let{metric:r,value:s,histogram:l}=t,{name:u,formattedName:o}=i(e,r,a);return l?{name:u,formattedName:o,labels:r,values:[(0,n.qJ)([l[0],l[1].sum])],histograms:[l]}:{name:u,formattedName:o,labels:r,values:[(0,n.qJ)(s)]}});case"matrix":return t.result.map(t=>{let{metric:r,values:s,histograms:l}=t,{name:u,formattedName:o}=i(e,r,a);return l?{name:u,formattedName:o,labels:r,values:l.map(e=>(0,n.qJ)([e[0],e[1].sum])),histograms:l.map(e=>e)}:{name:u,formattedName:o,labels:r,values:s.map(n.qJ)}});case"scalar":let{name:s,formattedName:l}=i(e,{},a);return[{name:s,values:[(0,n.qJ)(t.result)],formattedName:l}];default:return console.warn("Unknown result type",r,t),[]}}(w,C,x),metadata:{notices:O,executedQueryString:w}}};var m=a(24246),p=a(75586),h=a(95700),v=a(25283),g=a(90192),S=a(8695),b=a(54538),f=a(64001);let y={getTimeSeriesData:d,OptionsEditorComponent:function(e){let{onChange:t,value:a,value:{query:s,datasource:l},queryHandlerSettings:u}=e,i=l??n.Mm,c=(0,h.useId)("prom-datasource-label"),d=(0,r.useDatasourceSelectValueToSelector)(i,n.nY),{data:y}=(0,r.useDatasourceClient)(d),w=null==y?void 0:y.options.datasourceUrl,{data:x}=(0,r.useDatasource)(d),{handleQueryChange:q,handleQueryBlur:C}=function(e){let{onChange:t,value:a}=e,[r,s]=(0,b.useState)(a.query),[l,n]=(0,b.useState)(a.query);return a.query!==l&&(s(a.query),n(a.query)),{query:r,handleQueryChange:e=>{s(e)},handleQueryBlur:()=>{n(r),t((0,p.Uy)(a,e=>{e.query=r}))}}}(e),{format:O,handleFormatChange:D,handleFormatBlur:F}=function(e){let{onChange:t,value:a}=e,[r,s]=(0,b.useState)(a.seriesNameFormat),[l,n]=(0,b.useState)(a.seriesNameFormat);return a.seriesNameFormat!==l&&(s(a.seriesNameFormat),n(a.seriesNameFormat)),{format:r,handleFormatChange:e=>{s(e)},handleFormatBlur:()=>{n(r),t((0,p.Uy)(a,e=>{e.seriesNameFormat=r}))}}}(e),{minStep:M,handleMinStepChange:T,handleMinStepBlur:j}=function(e){let{onChange:t,value:a}=e,[r,s]=(0,b.useState)(a.minStep),[l,n]=(0,b.useState)(a.minStep);return a.minStep!==l&&(s(a.minStep),n(a.minStep)),{minStep:r,handleMinStepChange:e=>{s(e)},handleMinStepBlur:()=>{n(r),t((0,p.Uy)(a,e=>{e.minStep=r}))}}}(e),B=M??(x&&(null==x?void 0:x.plugin.spec).scrapeInterval)??o.v,k=(0,b.useCallback)(e=>{q(e),(null==u?void 0:u.watchQueryChanges)&&(null==u||u.watchQueryChanges(e))},[u,q]),N=(0,b.useCallback)(e=>{D(e.target.value),(null==u?void 0:u.setWatchOtherSpecs)&&u.setWatchOtherSpecs({...a,seriesNameFormat:e.target.value})},[u,D,a]),U=(0,b.useCallback)(e=>{T(e.target.value?e.target.value:void 0),(null==u?void 0:u.setWatchOtherSpecs)&&u.setWatchOtherSpecs({...a,minStep:e.target.value})},[u,T,a]);return(0,m.jsxs)(v.Z,{spacing:2,children:[(0,m.jsx)(g.Z,{margin:"dense",fullWidth:!1,children:(0,m.jsx)(r.DatasourceSelect,{datasourcePluginKind:n.nY,value:i,onChange:e=>{if((0,n.sv)(e))return void t((0,p.Uy)(a,t=>{t.datasource=(0,n.Rv)(e)?void 0:e}));throw Error("Got unexpected non-Prometheus datasource selector")},labelId:c,label:"Prometheus Datasource",notched:!0})}),(0,m.jsx)(f.P,{completeConfig:{remote:{url:w}},value:s,datasource:d,onChange:k,onBlur:(null==u?void 0:u.runWithOnBlur)?C:void 0}),(0,m.jsxs)(v.Z,{direction:"row",spacing:2,children:[(0,m.jsx)(S.Z,{fullWidth:!0,label:"Legend",placeholder:"Example: '{{instance}}' will generate series names like 'webserver-123', 'webserver-456'...",helperText:"Text to be displayed in the legend and the tooltip. Use {{label_name}} to interpolate label values.",value:O??"",onChange:N,onBlur:(null==u?void 0:u.runWithOnBlur)?F:void 0}),(0,m.jsx)(S.Z,{label:"Min Step",placeholder:B,helperText:"Lower bound for the step. If not provided, the scrape interval of the datasource is used.",value:M??"",onChange:U,onBlur:(null==u?void 0:u.runWithOnBlur)?j:void 0,sx:{width:"250px"}})]})]})},createInitialOptions:()=>({query:"",datasource:void 0}),dependsOn:e=>{let t=(0,r.parseVariables)(e.query);return{variables:[...new Set([...t,...(0,r.parseVariables)(e.seriesNameFormat||""),...(0,r.isVariableDatasource)(e.datasource)?(0,r.parseVariables)(e.datasource??""):[]])]}}}},16146:function(e,t,a){a.d(t,{v:()=>r});let r="1m"}}]);
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../../src/test/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,yCAAyC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/test/setup-tests.ts"],"sourcesContent":["// Copyright 2023 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 '@testing-library/jest-dom/extend-expect';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,0CAA0C"}
File without changes
File without changes
File without changes