(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7004],{51316:(e,t,a)=>{"use strict";a.r(t),a.d(t,{plugin:()=>Za});var n,s=a(43215),r=a(68404),i=a(45916);const l=[{title:"Request Rate",expression:"rate(http_request_total[5m])",label:"Given an HTTP request counter, this query calculates the per-second average request rate over the last 5 minutes."},{title:"95th Percentile of Request Latencies",expression:"histogram_quantile(0.95, sum(rate(prometheus_http_request_duration_seconds_bucket[5m])) by (le))",label:"Calculates the 95th percentile of HTTP request rate over 5 minute windows."},{title:"Alerts Firing",expression:'sort_desc(sum(sum_over_time(ALERTS{alertstate="firing"}[24h])) by (alertname))',label:"Sums up the alerts that have been firing over the last 24 hours."},{title:"Step",label:"Defines the graph resolution using a duration format (15s, 1m, 3h, ...). Small steps create high-resolution graphs but can be slow over larger time ranges. Using a longer step lowers the resolution and smooths the graph by producing fewer datapoints. If no step is given the resolution is calculated automatically."}],o=e=>(0,i.jsxs)("div",{children:[n||(n=(0,i.jsx)("h2",{children:"PromQL Cheat Sheet"})),l.map(((t,a)=>(0,i.jsxs)("div",{className:"cheat-sheet-item",children:[(0,i.jsx)("div",{className:"cheat-sheet-item__title",children:t.title}),t.expression?(0,i.jsx)("div",{className:"cheat-sheet-item__example",onClick:a=>e.onClickExample({refId:"A",expr:t.expression}),children:(0,i.jsx)("code",{children:t.expression})}):null,(0,i.jsx)("div",{className:"cheat-sheet-item__label",children:t.label})]},a)))]});var c,u=a(90923),d=a(90747),h=a(69783),m=a(11277),p=a(53373),g=a(36636);function v(e){let{feedbackUrl:t}=e;const a=(0,h.useStyles2)(f);return u.config.feedbackLinksEnabled?(0,i.jsx)(d.Stack,{gap:1,children:(0,i.jsxs)("a",{href:t,className:a.link,title:"This query builder is new, please let us know how we can improve it",target:"_blank",rel:"noreferrer noopener",children:[c||(c=(0,i.jsx)(h.Icon,{name:"comment-alt-message"}))," Give feedback"]})}):null}function f(e){return{link:(0,g.css)({color:e.colors.text.secondary,fontSize:e.typography.bodySmall.fontSize,":hover":{color:e.colors.text.link}})}}var b=a(50966),x=a(82631),y=a(7524),j=a(17421);let T,_;function S(e){return"values"in e}!function(e){e.timeSeriesQuery="timeSeriesQuery"}(T||(T={})),function(e){e.Auto="__auto",e.Verbose="__verbose",e.Custom="__custom"}(_||(_={}));const C="PrometheusQueryEditorModeDefault";function w(e,t,a){""===e.expr&&j.Z.set(C,t),a(Object.assign({},e,{editorMode:t}))}function I(e){if(null!=e&&""!==e)return y.c.Code;const t=j.Z.get(C);switch(t){case y.c.Builder:case y.c.Code:case y.c.Explain:return t;default:return y.c.Builder}}const E="PrometheusQueryEditorRawQueryDefault";function D(){const[e,t]=(0,r.useState)(function(){const e=j.Z.get(E);return void 0===e||Boolean(parseInt(e,10))}());return[e,(0,r.useCallback)((e=>{!function(e){j.Z.set(E,e?"1":"0")}(e),t(e)}),[])]}var q=a(53772),R=a(65161),O=a(50818),F=a(13177),N=a(77441),A=a(9575),k=a.n(A);function P(e){let{query:t,onChange:a,onGetMetrics:n}=e;const l=(0,h.useStyles2)(L),[o,c]=(0,r.useState)({}),u=(0,r.useCallback)(((e,t)=>{var a;const n=null!==(a=e.label)&&void 0!==a?a:e.value;if(!n)return!1;if(!n.toLowerCase)return!0;return t.split(" ").reduce(((e,t)=>e&&n.toLowerCase().includes(t.toLowerCase())),!0)}),[]),m=(0,r.useCallback)(((e,t)=>{var a;return e.__isNew__?e.label:(0,i.jsx)(k(),{searchWords:t.inputValue.split(" "),textToHighlight:null!==(a=e.label)&&void 0!==a?a:"",highlightClassName:l.highlight})}),[l.highlight]);return(0,i.jsx)(d.EditorFieldGroup,{children:(0,i.jsx)(d.EditorField,{label:"Metric",children:(0,i.jsx)(h.Select,{inputId:"prometheus-metric-select",className:l.select,value:t.metric?(0,s.toOption)(t.metric):void 0,placeholder:"Select metric",allowCustomValue:!0,formatOptionLabel:m,filterOption:u,onOpenMenu:async()=>{c({isLoading:!0});const e=await n();c({metrics:e,isLoading:void 0})},isLoading:o.isLoading,options:o.metrics,onChange:e=>{let{value:n}=e;n&&a(Object.assign({},t,{metric:n}))}})})})}const L=e=>({select:g.css`
    min-width: 125px;
  `,highlight:g.css`
    label: select__match-highlight;
    background: inherit;
    padding: inherit;
    color: ${e.colors.warning.contrastText};
    background-color: ${e.colors.warning.main};
  `});var Q,V=a(8254),M=a(64722);const $=r.memo((e=>{let{nestedQuery:t,index:a,datasource:n,onChange:r,onRemove:l,onRunQuery:o}=e;const c=(0,h.useStyles2)(X);return(0,i.jsxs)("div",{className:c.card,children:[(0,i.jsxs)("div",{className:c.header,children:[(0,i.jsx)("div",{className:c.name,children:"Operator"}),(0,i.jsx)(h.Select,{width:"auto",options:U,value:(0,s.toOption)(t.operator),onChange:e=>{r(a,Object.assign({},t,{operator:e.value}))}}),(0,i.jsx)("div",{className:c.name,children:"Vector matches"}),(0,i.jsxs)("div",{className:c.vectorMatchWrapper,children:[(0,i.jsx)(h.Select,{width:"auto",value:t.vectorMatchesType||"on",allowCustomValue:!0,options:[{value:"on",label:"on"},{value:"ignoring",label:"ignoring"}],onChange:e=>{r(a,Object.assign({},t,{vectorMatchesType:e.value}))}}),(0,i.jsx)(M.H,{className:c.vectorMatchInput,minWidth:20,defaultValue:t.vectorMatches,onCommitChange:e=>{r(a,Object.assign({},t,{vectorMatches:e.currentTarget.value,vectorMatchesType:t.vectorMatchesType||"on"}))}})]}),Q||(Q=(0,i.jsx)(d.FlexItem,{grow:1})),(0,i.jsx)(h.IconButton,{name:"times",size:"sm",onClick:()=>l(a)})]}),(0,i.jsx)("div",{className:c.body,children:(0,i.jsx)(d.EditorRows,{children:(0,i.jsx)(K,{query:t.query,datasource:n,nested:!0,onRunQuery:o,onChange:e=>{r(a,Object.assign({},t,{query:e}))}})})})]})})),U=V.iQ.map((e=>({label:e.sign,value:e.sign})));$.displayName="NestedQuery";const X=e=>({card:(0,g.css)({label:"card",display:"flex",flexDirection:"column",gap:e.spacing(.5)}),header:(0,g.css)({label:"header",padding:e.spacing(.5,.5,.5,1),gap:e.spacing(1),display:"flex",alignItems:"center"}),name:(0,g.css)({label:"name",whiteSpace:"nowrap"}),body:(0,g.css)({label:"body",paddingLeft:e.spacing(2)}),vectorMatchInput:(0,g.css)({label:"vectorMatchInput",marginLeft:-1}),vectorMatchWrapper:(0,g.css)({label:"vectorMatchWrapper",display:"flex"})});function B(e){var t;let{query:a,datasource:n,onChange:s,onRunQuery:r}=e;const l=null!==(t=a.binaryQueries)&&void 0!==t?t:[],o=(e,t)=>{const n=[...l];n.splice(e,1,t),s(Object.assign({},a,{binaryQueries:n}))},c=e=>{const t=[...l.slice(0,e),...l.slice(e+1)];s(Object.assign({},a,{binaryQueries:t}))};return(0,i.jsx)(d.Stack,{direction:"column",gap:1,children:l.map(((e,t)=>(0,i.jsx)($,{nestedQuery:e,index:t,onChange:o,datasource:n,onRemove:c,onRunQuery:r},t.toString())))})}const z=r.memo((e=>{let{datasource:t,query:a,onChange:n,data:s}=e;const[l,o]=(0,r.useState)([]),c=(0,h.useStyles2)(W);return(0,r.useEffect)((()=>{const e={expr:m.Z.renderQuery(a),refId:""},n=t.getQueryHints(e,(null==s?void 0:s.series)||[]).filter((e=>{var t;return null===(t=e.fix)||void 0===t?void 0:t.action}));o(n)}),[t,a,n,s,c.hint]),(0,i.jsx)(i.Fragment,{children:l.length>0&&(0,i.jsx)("div",{className:c.container,children:l.map((e=>{var s,r,l;return(0,i.jsx)(h.Tooltip,{content:`${e.label} ${null===(s=e.fix)||void 0===s?void 0:s.label}`,children:(0,i.jsx)(h.Button,{onClick:()=>{const s={expr:m.Z.renderQuery(a),refId:""},r=t.modifyQuery(s,e.fix.action),i=(0,p._)(r.expr);return n(i.query)},fill:"outline",size:"sm",className:c.hint,children:"hint: "+(null===(r=e.fix)||void 0===r||null===(l=r.action)||void 0===l?void 0:l.type.toLowerCase().replace("_"," "))+"()"})},e.type)}))})})}));z.displayName="PromQueryBuilderHints";const W=e=>({container:g.css`
      display: flex;
      margin-bottom: ${e.spacing(1)};
      align-items: center;
    `,hint:g.css`
      margin-right: ${e.spacing(1)};
    `}),K=r.memo((e=>{let{datasource:t,query:a,onChange:n,onRunQuery:s,data:l}=e;const o=(0,r.useCallback)((async e=>{const a=t.getVariables(),n=await e;return[...a.map((e=>({label:e,value:e}))),...n.map((e=>({label:e.value,value:e.value,title:e.description})))]}),[t]),c=(0,r.useCallback)((()=>o(async function(e,t){e.languageProvider.metricsMetadata||await e.languageProvider.loadMetricsMetadata();let a;if(t.labels.length>0){var n;const s=m.Z.renderLabels(t.labels);a=null!==(n=(await e.languageProvider.getSeries(s,!0)).__name__)&&void 0!==n?n:[]}else{var s;a=null!==(s=await e.languageProvider.getLabelValues("__name__"))&&void 0!==s?s:[]}return a.map((t=>({value:t,description:(0,R.UQ)(t,e.languageProvider.metricsMetadata)})))}(t,a))),[t,a,o]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(d.EditorRow,{children:[(0,i.jsx)(P,{query:a,onChange:n,onGetMetrics:c}),(0,i.jsx)(O.P,{labelsFilters:a.labels,onChange:e=>{n(Object.assign({},a,{labels:e}))},onGetLabelNames:e=>o((async e=>{if(!a.metric)return await t.languageProvider.fetchLabels(),t.languageProvider.getLabelKeys().map((e=>({value:e})));const n=a.labels.filter((t=>t!==e));n.push({label:"__name__",op:"=",value:a.metric});const s=m.Z.renderLabels(n),r=await t.languageProvider.fetchSeriesLabels(s);return Object.keys(r).filter((e=>!n.find((t=>t.label===e)))).map((e=>({value:e})))})(e)),onGetLabelValues:e=>o((async e=>{var n;if(!e.label)return[];if(!a.metric)return(await t.languageProvider.getLabelValues(e.label)).map((e=>({value:e})));const s=a.labels.filter((t=>t!==e));s.push({label:"__name__",op:"=",value:a.metric});const r=m.Z.renderLabels(s);return null!==(n=(await t.languageProvider.fetchSeriesLabels(r))[t.interpolateString(e.label)].map((e=>({value:e}))))&&void 0!==n?n:[]})(e))})]}),(0,i.jsxs)(N.B,{children:[(0,i.jsx)(F.P,{queryModeller:m.Z,datasource:t,query:a,onChange:n,onRunQuery:s}),(0,i.jsx)(z,{datasource:t,query:a,onChange:n,data:l})]}),a.binaryQueries&&a.binaryQueries.length>0&&(0,i.jsx)(B,{query:a,datasource:t,onChange:n,onRunQuery:s})]})}));K.displayName="PromQueryBuilder";var G=a(53454),J=a(3690);function H(e){let{query:t}=e;return(0,i.jsx)(d.EditorRow,{children:(0,i.jsx)(d.EditorFieldGroup,{children:(0,i.jsx)(d.EditorField,{label:"Raw query",children:(0,i.jsx)(J.U,{query:t,lang:{grammar:G.ZP,name:"promql"}})})})})}function Z(e){const{query:t,onChange:a,onRunQuery:n,datasource:s,data:l,showRawQuery:o}=e,[c,u]=(0,r.useReducer)(Y.reducer,{expr:t.expr});(0,r.useEffect)((()=>{u(te(t.expr))}),[t.expr]);return c.visQuery?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(K,{query:c.visQuery,datasource:s,onChange:t=>{const n=m.Z.renderQuery(t);u(ee({visQuery:t,expr:n})),a(Object.assign({},e.query,{expr:n}))},onRunQuery:n,data:l}),o&&(0,i.jsx)(H,{query:t.expr})]}):null}const Y=(0,q.oM)({name:"prom-builder-container",initialState:{expr:""},reducers:{visualQueryChange:(e,t)=>{e.expr=t.payload.expr,e.visQuery=t.payload.visQuery},exprChanged:(e,t)=>{if(!e.visQuery||e.expr!==t.payload){e.expr=t.payload;const a=(0,p._)(t.payload);e.visQuery=a.query}}}}),{visualQueryChange:ee,exprChanged:te}=Y.actions;var ae=a(2926),ne=a(74929);const se=r.memo((e=>{let{query:t}=e;const a=(0,p._)(t||"").query,n={grammar:G.ZP,name:"promql"};return(0,i.jsxs)(d.Stack,{gap:.5,direction:"column",children:[(0,i.jsx)(ae.B,{children:(0,i.jsx)(J.U,{query:t,lang:n})}),(0,i.jsx)(ae.B,{stepNumber:1,title:(0,i.jsx)(J.U,{query:`${a.metric} ${m.Z.renderLabels(a.labels)}`,lang:n}),children:"Fetch all series matching metric name and label filters."}),(0,i.jsx)(ne.V,{stepNumber:2,queryModeller:m.Z,query:a,lang:n})]})}));se.displayName="PromQueryBuilderExplained";var re=a(82897),ie=a(20002);const le=["datasource","onChange","query"];function oe(e){let{datasource:t,onChange:a,query:n}=e,s=function(e,t){if(null==e)return{};var a,n,s={},r=Object.keys(e);for(n=0;n<r.length;n++)a=r[n],t.indexOf(a)>=0||(s[a]=e[a]);return s}(e,le);const[l,o]=(0,r.useState)(null),c=(0,h.useStyles2)(ce),u=(0,ie.Z)(l);(0,r.useEffect)((()=>{t.exemplarsAvailable?n.instant&&!n.range?(o("Exemplars are not available for instant queries"),a(!1)):(o(null),u&&!l&&a(!0)):(o("Exemplars for this query are not available"),a(!1))}),[t.exemplarsAvailable,n.instant,n.range,a,u,l]);const d=(0,g.cx)({[c.activeIcon]:!!n.exemplar},c.eyeIcon);return(0,i.jsx)(h.InlineLabel,{width:"auto","data-testid":s["data-testid"],children:(0,i.jsx)(h.Tooltip,{content:null!=l?l:"",children:(0,i.jsxs)("div",{className:c.iconWrapper,children:["Exemplars",(0,i.jsx)(h.IconButton,{name:"eye",tooltip:n.exemplar?"Disable query with exemplars":"Enable query with exemplars",disabled:!!l,className:d,onClick:()=>{a(!n.exemplar)}})]})})})}function ce(e){return{eyeIcon:g.css`
      margin-left: ${e.spacing(2)};
    `,activeIcon:g.css`
      color: ${e.colors.primary.main};
    `,iconWrapper:g.css`
      display: flex;
      align-items: center;
    `}}var ue,de;const he=(0,r.memo)((e=>{var t;let{query:a,datasource:n,onChange:s,onRunQuery:l}=e;const o=me(!0),c=(0,ie.Z)(a),u=(0,r.useCallback)((e=>{(0,re.isEqual)(a,c)&&e===a.exemplar||s(Object.assign({},a,{exemplar:e}))}),[c,a,s]);const d=pe(a,s);return(0,i.jsxs)("div",{"aria-label":"Prometheus extra field",className:"gf-form-inline","data-testid":ge.extraFieldEditor,children:[(0,i.jsxs)("div",{"data-testid":ge.queryTypeField,className:(0,g.cx)("gf-form explore-input-margin",g.css`
              flex-wrap: nowrap;
            `),"aria-label":"Query type field",children:[ue||(ue=(0,i.jsx)(h.InlineFormLabel,{width:"auto",children:"Query type"})),(0,i.jsx)(h.RadioButtonGroup,{options:o,value:a.range&&a.instant?"both":a.instant?"instant":"range",onChange:d})]}),(0,i.jsxs)("div",{"data-testid":ge.stepField,className:(0,g.cx)("gf-form",g.css`
              flex-wrap: nowrap;
            `),"aria-label":"Step field",children:[de||(de=(0,i.jsx)(h.InlineFormLabel,{width:6,tooltip:"Time units and built-in variables can be used here, for example: $__interval, $__rate_interval, 5s, 1m, 3h, 1d, 1y (Default if no unit is specified: s)",children:"Min step"})),(0,i.jsx)("input",{type:"text",className:"gf-form-input width-4",placeholder:"auto",onChange:function(e){var t;e.currentTarget.value!==a.interval&&(t=e.currentTarget.value,s(Object.assign({},a,{interval:t})))},onKeyDown:function(e){"Enter"===e.key&&e.shiftKey&&l()},value:null!==(t=a.interval)&&void 0!==t?t:""})]}),(0,i.jsx)(oe,{onChange:u,datasource:n,query:a})]})}));function me(e){const t=[{value:"range",label:"Range",description:"Run query over a range of time"},{value:"instant",label:"Instant",description:'Run query against a single point in time. For this query, the "To" time is used'}];return e&&t.push({value:"both",label:"Both",description:"Run an Instant query and a Range query"}),t}function pe(e,t){return a=>{t("instant"===a?Object.assign({},e,{instant:!0,range:!1,exemplar:!1}):"range"===a?Object.assign({},e,{instant:!1,range:!0}):Object.assign({},e,{instant:!0,range:!0}))}}he.displayName="PromExploreExtraField";const ge={extraFieldEditor:"prom-editor-extra-field",stepField:"prom-editor-extra-field-step",queryTypeField:"prom-editor-extra-field-query-type"},ve=e=>{let{panelData:t,query:a,datasource:n}=e;const[l,o]=(0,r.useState)("");return(0,r.useEffect)((()=>{if(t){o((()=>{if(!t.request)return"";const{request:{range:e,interval:r,scopedVars:i}}=t,l=n.getPrometheusTime(e.from,!1),o=n.getPrometheusTime(e.to,!0),c=Math.ceil(o-l),u=e.to.utc().format("YYYY-MM-DD HH:mm"),d={interval:r,scopedVars:Object.assign({},i,n.getRateIntervalScopedVariable(s.rangeUtil.intervalToSeconds(r),s.rangeUtil.intervalToSeconds(n.interval)))},h={};if(n.customQueryParameters)for(const[e,t]of n.customQueryParameters)h[e]=t;const m=n.createQuery(a,d,l,o),p=Object.assign({},h,{"g0.expr":m.expr,"g0.range_input":c+"s","g0.end_input":u,"g0.step_input":m.step,"g0.tab":0}),g=(0,re.map)(p,((e,t)=>t+"="+encodeURIComponent(e))).join("&");return`${n.directUrl}/graph?${g}`})())}}),[n,t,a]),(0,i.jsx)("a",{href:s.textUtil.sanitizeUrl(l),target:"_blank",rel:"noopener noreferrer",children:"Prometheus"})},fe=(0,r.memo)(ve);var be=a(50539),xe=a(56082);var ye,je,Te,_e,Se,Ce=a(82777),we=a(62859);function Ie(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const Ee="{}",De="__name__";function qe(e){let t="";const a=[];for(const n of e)if((n.name===De||n.selected)&&n.values&&n.values.length>0){const e=n.values.filter((e=>e.selected)).map((e=>e.name));e.length>1?a.push(`${n.name}=~"${e.map(Ce.tU).join("|")}"`):1===e.length&&(n.name===De?t=e[0]:a.push(`${n.name}="${(0,Ce.U9)(e[0])}"`))}return[t,"{",a.join(","),"}"].join("")}const Re=(0,h.stylesFactory)((e=>({wrapper:g.css`
    background-color: ${e.colors.bg2};
    padding: ${e.spacing.sm};
    width: 100%;
  `,list:g.css`
    margin-top: ${e.spacing.sm};
    display: flex;
    flex-wrap: wrap;
    max-height: 200px;
    overflow: auto;
    align-content: flex-start;
  `,section:g.css`
    & + & {
      margin: ${e.spacing.md} 0;
    }
    position: relative;
  `,selector:g.css`
    font-family: ${e.typography.fontFamily.monospace};
    margin-bottom: ${e.spacing.sm};
  `,status:g.css`
    padding: ${e.spacing.xs};
    color: ${e.colors.textSemiWeak};
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* using absolute positioning because flex interferes with ellipsis */
    position: absolute;
    width: 50%;
    right: 0;
    text-align: right;
    transition: opacity 100ms linear;
    opacity: 0;
  `,statusShowing:g.css`
    opacity: 1;
  `,error:g.css`
    color: ${e.palette.brandDanger};
  `,valueList:g.css`
    margin-right: ${e.spacing.sm};
  `,valueListWrapper:g.css`
    border-left: 1px solid ${e.colors.border2};
    margin: ${e.spacing.sm} 0;
    padding: ${e.spacing.sm} 0 ${e.spacing.sm} ${e.spacing.sm};
  `,valueListArea:g.css`
    display: flex;
    flex-wrap: wrap;
    margin-top: ${e.spacing.sm};
  `,valueTitle:g.css`
    margin-left: -${e.spacing.xs};
    margin-bottom: ${e.spacing.sm};
  `,validationStatus:g.css`
    padding: ${e.spacing.xs};
    margin-bottom: ${e.spacing.sm};
    color: ${e.colors.textStrong};
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  `})));class Oe extends r.Component{constructor(){super(...arguments),Ie(this,"valueListsRef",r.createRef()),Ie(this,"state",{labels:[],labelSearchTerm:"",metricSearchTerm:"",status:"Ready",error:"",validationStatus:"",valueSearchTerm:""}),Ie(this,"onChangeLabelSearch",(e=>{this.setState({labelSearchTerm:e.target.value})})),Ie(this,"onChangeMetricSearch",(e=>{this.setState({metricSearchTerm:e.target.value})})),Ie(this,"onChangeValueSearch",(e=>{this.setState({valueSearchTerm:e.target.value})})),Ie(this,"onClickRunQuery",(()=>{const e=qe(this.state.labels);this.props.onChange(e)})),Ie(this,"onClickRunRateQuery",(()=>{const e=`rate(${qe(this.state.labels)}[$__interval])`;this.props.onChange(e)})),Ie(this,"onClickClear",(()=>{this.setState((e=>({labels:e.labels.map((e=>Object.assign({},e,{values:void 0,selected:!1,loading:!1,hidden:!1,facets:void 0}))),labelSearchTerm:"",metricSearchTerm:"",status:"",error:"",validationStatus:"",valueSearchTerm:""}))),this.props.deleteLastUsedLabels(),this.fetchValues(De,Ee)})),Ie(this,"onClickLabel",((e,t,a)=>{const n=this.state.labels.find((t=>t.name===e));if(!n)return;const s=!n.selected;let r={selected:s};if(n.values&&!s){const e=n.values.map((e=>Object.assign({},e,{selected:!1})));r=Object.assign({},r,{facets:0,values:e})}this.setState({labelSearchTerm:""}),this.updateLabelState(e,r,"",(()=>this.doFacettingForLabel(e)))})),Ie(this,"onClickValue",((e,t,a)=>{const n=this.state.labels.find((t=>t.name===e));if(!n||!n.values)return;this.setState({labelSearchTerm:""});const s=n.values.map((e=>Object.assign({},e,{selected:e.name===t?!e.selected:e.selected})));this.updateLabelState(e,{values:s},"",(()=>this.doFacetting(e)))})),Ie(this,"onClickMetric",((e,t,a)=>{const n=this.state.labels.find((t=>t.name===e));if(!n||!n.values)return;this.setState({metricSearchTerm:""});const s=n.values.map((e=>Object.assign({},e,{selected:e.name===t||e.selected?!e.selected:e.selected}))),r=s.some((e=>e.selected));this.updateLabelState(e,{selected:r,values:s},"",(()=>this.doFacetting(e)))})),Ie(this,"onClickValidate",(()=>{const e=qe(this.state.labels);this.validateSelector(e)})),Ie(this,"doFacetting",(e=>{const t=qe(this.state.labels);if(t===Ee){const e=this.state.labels.map((e=>Object.assign({},e,{facets:0,values:void 0,hidden:!1})));this.setState({labels:e},(()=>{this.state.labels.forEach((e=>(e.selected||e.name===De)&&this.fetchValues(e.name,t)))}))}else this.fetchSeries(t,e)}))}updateLabelState(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=arguments.length>3?arguments[3]:void 0;this.setState((n=>{const s=n.labels.map((a=>a.name===e?Object.assign({},a,t):a)),r=a?"":n.error;return{labels:s,status:a,error:r,validationStatus:""}}),n)}componentDidMount(){const{languageProvider:e,lastUsedLabels:t}=this.props;if(e){const a=t;e.start().then((()=>{let t=e.getLabelKeys();this.fetchValues(De,Ee);const n=t.map(((e,t,n)=>({name:e,selected:a.includes(e),loading:!1})));this.setState({labels:n},(()=>{this.state.labels.forEach((e=>{e.selected&&this.fetchValues(e.name,Ee)}))}))}))}}doFacettingForLabel(e){const t=this.state.labels.find((t=>t.name===e));if(!t)return;const a=this.state.labels.filter((e=>e.selected)).map((e=>e.name));this.props.storeLastUsedLabels(a),t.selected?t.values||this.fetchValues(e,qe(this.state.labels)):this.doFacetting()}async fetchValues(e,t){const{languageProvider:a}=this.props;this.updateLabelState(e,{loading:!0},`Fetching values for ${e}`);try{let n=await a.getLabelValues(e);if(t!==qe(this.state.labels))return void this.updateLabelState(e,{loading:!1});const s=[],{metricsMetadata:r}=a;for(const t of n){const a={name:t};if(e===De&&r){const e=r[t];e&&(a.details=`(${e.type}) ${e.help}`)}s.push(a)}this.updateLabelState(e,{values:s,loading:!1})}catch(e){console.error(e)}}async fetchSeries(e,t){const{languageProvider:a}=this.props;t&&this.updateLabelState(t,{loading:!0},`Facetting labels for ${e}`);try{const n=await a.fetchSeriesLabels(e,!0);if(e!==qe(this.state.labels))return void(t&&this.updateLabelState(t,{loading:!1}));if(0===Object.keys(n).length)return void this.setState({error:`Empty results, no matching label for ${e}`});const s=function(e,t,a){return e.map((e=>{const n=t[e.name];if(n){let t;if(e.name===a&&e.values)t=e.values;else{var s;const a=new Set((null===(s=e.values)||void 0===s?void 0:s.filter((e=>e.selected)).map((e=>e.name)))||[]);t=n.map((e=>({name:e,selected:a.has(e)})))}return Object.assign({},e,{loading:!1,values:t,hidden:!n,facets:t.length})}return Object.assign({},e,{loading:!1,hidden:!n,values:void 0,facets:0})}))}(this.state.labels,n,t);this.setState({labels:s,error:""}),t&&this.updateLabelState(t,{loading:!1})}catch(e){console.error(e)}}async validateSelector(e){const{languageProvider:t}=this.props;this.setState({validationStatus:`Validating selector ${e}`,error:""});const a=await t.fetchSeries(e);this.setState({validationStatus:`Selector is valid (${a.length} series found)`})}render(){var e,t;const{theme:a}=this.props,{labels:n,labelSearchTerm:s,metricSearchTerm:r,status:l,error:o,validationStatus:c,valueSearchTerm:u}=this.state,d=Re(a);if(0===n.length)return(0,i.jsx)("div",{className:d.wrapper,children:ye||(ye=(0,i.jsx)(h.LoadingPlaceholder,{text:"Loading labels..."}))});let m=n.find((e=>e.name===De));var p;m&&r&&(m=Object.assign({},m,{values:null===(p=m.values)||void 0===p?void 0:p.filter((e=>e.selected||e.name.includes(r)))}));let v=n.filter((e=>!e.hidden&&e.name!==De));s&&(v=v.filter((e=>e.selected||e.name.includes(s))));let f=v.filter((e=>e.selected&&e.values));u&&(f=f.map((e=>{var t;return Object.assign({},e,{values:null===(t=e.values)||void 0===t?void 0:t.filter((e=>e.selected||e.name.includes(u)))})})));const b=qe(this.state.labels),x=b===Ee,y=(null===(e=m)||void 0===e||null===(t=e.values)||void 0===t?void 0:t.length)||0;return(0,i.jsxs)("div",{className:d.wrapper,children:[(0,i.jsxs)(h.HorizontalGroup,{align:"flex-start",spacing:"lg",children:[(0,i.jsx)("div",{children:(0,i.jsxs)("div",{className:d.section,children:[je||(je=(0,i.jsx)(h.Label,{description:"Once a metric is selected only possible labels are shown.",children:"1. Select a metric"})),(0,i.jsx)("div",{children:(0,i.jsx)(h.Input,{onChange:this.onChangeMetricSearch,"aria-label":"Filter expression for metric",value:r})}),(0,i.jsx)("div",{role:"list",className:d.valueListWrapper,children:(0,i.jsx)(we.t7,{height:Math.min(450,25*y),itemCount:y,itemSize:25,itemKey:e=>m.values[e].name,width:300,className:d.valueList,children:e=>{var t,a;let{index:n,style:s}=e;const l=null===(t=m)||void 0===t||null===(a=t.values)||void 0===a?void 0:a[n];return l?(0,i.jsx)("div",{style:s,children:(0,i.jsx)(h.BrowserLabel,{name:m.name,value:null==l?void 0:l.name,title:l.details,active:null==l?void 0:l.selected,onClick:this.onClickMetric,searchTerm:r})}):null}})})]})}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:d.section,children:[Te||(Te=(0,i.jsx)(h.Label,{description:"Once label values are selected, only possible label combinations are shown.",children:"2. Select labels to search in"})),(0,i.jsx)("div",{children:(0,i.jsx)(h.Input,{onChange:this.onChangeLabelSearch,"aria-label":"Filter expression for label",value:s})}),(0,i.jsx)("div",{className:d.list,style:{height:120},children:v.map((e=>(0,i.jsx)(h.BrowserLabel,{name:e.name,loading:e.loading,active:e.selected,hidden:e.hidden,facets:e.facets,onClick:this.onClickLabel,searchTerm:s},e.name)))})]}),(0,i.jsxs)("div",{className:d.section,children:[_e||(_e=(0,i.jsx)(h.Label,{description:"Use the search field to find values across selected labels.",children:"3. Select (multiple) values for your labels"})),(0,i.jsx)("div",{children:(0,i.jsx)(h.Input,{onChange:this.onChangeValueSearch,"aria-label":"Filter expression for label values",value:u})}),(0,i.jsx)("div",{className:d.valueListArea,ref:this.valueListsRef,children:f.map((e=>{var t,a,n;return(0,i.jsxs)("div",{role:"list","aria-label":`Values for ${e.name}`,className:d.valueListWrapper,children:[(0,i.jsx)("div",{className:d.valueTitle,children:(0,i.jsx)(h.BrowserLabel,{name:e.name,loading:e.loading,active:e.selected,hidden:e.hidden,facets:e.facets||(null===(t=e.values)||void 0===t?void 0:t.length),onClick:this.onClickLabel})}),(0,i.jsx)(we.t7,{height:Math.min(200,25*((null===(a=e.values)||void 0===a?void 0:a.length)||0)),itemCount:(null===(n=e.values)||void 0===n?void 0:n.length)||0,itemSize:28,itemKey:t=>e.values[t].name,width:200,className:d.valueList,children:t=>{var a;let{index:n,style:s}=t;const r=null===(a=e.values)||void 0===a?void 0:a[n];return r?(0,i.jsx)("div",{style:s,children:(0,i.jsx)(h.BrowserLabel,{name:e.name,value:null==r?void 0:r.name,active:null==r?void 0:r.selected,onClick:this.onClickValue,searchTerm:u})}):null}})]},e.name)}))})]})]})]}),(0,i.jsxs)("div",{className:d.section,children:[Se||(Se=(0,i.jsx)(h.Label,{children:"4. Resulting selector"})),(0,i.jsx)("div",{"aria-label":"selector",className:d.selector,children:b}),c&&(0,i.jsx)("div",{className:d.validationStatus,children:c}),(0,i.jsxs)(h.HorizontalGroup,{children:[(0,i.jsx)(h.Button,{"aria-label":"Use selector for query button",disabled:x,onClick:this.onClickRunQuery,children:"Use query"}),(0,i.jsx)(h.Button,{"aria-label":"Use selector as metrics button",variant:"secondary",disabled:x,onClick:this.onClickRunRateQuery,children:"Use as rate query"}),(0,i.jsx)(h.Button,{"aria-label":"Validate submit button",variant:"secondary",disabled:x,onClick:this.onClickValidate,children:"Validate selector"}),(0,i.jsx)(h.Button,{"aria-label":"Selector clear button",variant:"secondary",onClick:this.onClickClear,children:"Clear"}),(0,i.jsx)("div",{className:(0,g.cx)(d.status,(l||o)&&d.statusShowing),children:(0,i.jsx)("span",{className:o?d.error:"",children:o||l})})]})]})]})}}const Fe=(0,h.withTheme)(Oe),Ne=r.lazy((()=>a.e(6031).then(a.bind(a,97019)))),Ae=e=>(0,i.jsx)(r.Suspense,{fallback:null,children:(0,i.jsx)(Ne,Object.assign({},e))}),ke=["runQueryOnBlur","onRunQuery","onChange"];const Pe=e=>{const t=(0,r.useRef)(null),{runQueryOnBlur:a,onRunQuery:n,onChange:s}=e,l=function(e,t){if(null==e)return{};var a,n,s={},r=Object.keys(e);for(n=0;n<r.length;n++)a=r[n],t.indexOf(a)>=0||(s[a]=e[a]);return s}(e,ke),o=e=>{t.current=e,s(e),n()};return(0,i.jsx)(Ae,Object.assign({onRunQuery:o,onBlur:e=>{a?e!==t.current&&o(e):s(e)}},l))};function Le(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class Qe extends r.PureComponent{constructor(e,t){super(e,t),Le(this,"plugins",void 0),Le(this,"refreshHint",(()=>{const{datasource:e,query:t,data:a}=this.props,n=e.getInitHints(),r=n.length>0?n[0]:null;if(!a||0===a.series.length)return void this.setState({hint:r});const i=(0,s.isDataFrame)(a.series[0])?a.series.map(s.toLegacyResponseData):a.series,l=e.getQueryHints(t,i);let o=l.length>0?l[0]:null;this.setState({hint:null!=o?o:r})})),Le(this,"refreshMetrics",(async()=>{const{datasource:{languageProvider:e}}=this.props;this.languageProviderInitializationPromise=(e=>{let t=!1;return{promise:new Promise(((a,n)=>{e.then((e=>t?n({isCanceled:!0}):a(e))),e.catch((e=>n(t?{isCanceled:!0}:e)))})),cancel(){t=!0}}})(e.start());try{const e=await this.languageProviderInitializationPromise.promise;await Promise.all(e),this.onUpdateLanguage()}catch(e){if(!e.isCanceled)throw e}})),Le(this,"onChangeLabelBrowser",(e=>{this.onChangeQuery(e,!0),this.setState({labelBrowserVisible:!1})})),Le(this,"onChangeQuery",((e,t)=>{const{query:a,onChange:n,onRunQuery:s}=this.props;if(n){n(Object.assign({},a,{expr:e})),t&&s&&s()}})),Le(this,"onClickChooserButton",(()=>{this.setState((e=>({labelBrowserVisible:!e.labelBrowserVisible})))})),Le(this,"onClickHintFix",(()=>{const{datasource:e,query:t,onChange:a,onRunQuery:n}=this.props,{hint:s}=this.state;a(e.modifyQuery(t,s.fix.action)),n()})),Le(this,"onUpdateLanguage",(()=>{const{datasource:{languageProvider:e}}=this.props,{metrics:t}=e;t&&this.setState({syntaxLoaded:!0})})),Le(this,"onTypeahead",(async e=>{const{datasource:{languageProvider:t}}=this.props;if(!t)return{suggestions:[]};const{history:a}=this.props,{prefix:n,text:s,value:r,wrapperClasses:i,labelKey:l}=e;return await t.provideCompletionItems({text:s,value:r,prefix:n,wrapperClasses:i,labelKey:l},{history:a})})),this.plugins=[(0,h.BracesPlugin)(),(0,h.SlatePrism)({onlyIn:e=>"code_block"===e.type,getSyntax:e=>"promql"},Object.assign({},be.languages,{promql:this.props.datasource.languageProvider.syntax}))],this.state={labelBrowserVisible:!1,syntaxLoaded:!1,hint:null}}componentDidMount(){this.props.datasource.languageProvider&&this.refreshMetrics(),this.refreshHint()}componentWillUnmount(){this.languageProviderInitializationPromise&&this.languageProviderInitializationPromise.cancel()}componentDidUpdate(e){const{data:t,datasource:{languageProvider:a},range:n}=this.props;a!==e.datasource.languageProvider&&this.setState({syntaxLoaded:!1});const s=this.rangeChangedToRefresh(n,e.range);(a!==e.datasource.languageProvider||s)&&this.refreshMetrics(),t&&e.data&&e.data.series!==t.series&&this.refreshHint()}rangeChangedToRefresh(e,t){if(e&&t){const a=(0,Ce.o8)(e.from.valueOf())===(0,Ce.o8)(t.from.valueOf()),n=(0,Ce.o8)(e.to.valueOf())===(0,Ce.o8)(t.to.valueOf());return!(a&&n)}return!1}render(){const{datasource:e,datasource:{languageProvider:t},query:a,ExtraFieldElement:n,history:r=[]}=this.props,{labelBrowserVisible:l,syntaxLoaded:o,hint:c}=this.state,u=t.metrics.length>0,d=function(e,t,a){return e?"(Disabled)":t?a?"Metrics browser":"(No metrics found)":"Loading metrics..."}(e.lookupsDisabled,o,u),m=!(o&&u);return(0,i.jsx)(xe.G,{storageKey:"grafana.datasources.prometheus.browser.labels",defaultValue:[],children:(e,o,u)=>{var p;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"gf-form-inline gf-form-inline--xs-view-flex-column flex-grow-1","data-testid":this.props["data-testid"],children:[(0,i.jsxs)("button",{className:"gf-form-label query-keyword pointer",onClick:this.onClickChooserButton,disabled:m,children:[d,(0,i.jsx)(h.Icon,{name:l?"angle-down":"angle-right"})]}),(0,i.jsx)("div",{className:"gf-form gf-form--grow flex-shrink-1 min-width-15",children:(0,i.jsx)(Pe,{runQueryOnBlur:this.props.app!==s.CoreApp.Explore,languageProvider:t,history:r,onChange:this.onChangeQuery,onRunQuery:this.props.onRunQuery,initialValue:null!==(p=a.expr)&&void 0!==p?p:""})})]}),l&&(0,i.jsx)("div",{className:"gf-form",children:(0,i.jsx)(Fe,{languageProvider:t,onChange:this.onChangeLabelBrowser,lastUsedLabels:e||[],storeLastUsedLabels:o,deleteLastUsedLabels:u})}),n,c?(0,i.jsx)("div",{className:"query-row-break",children:(0,i.jsxs)("div",{className:"prom-query-field-info text-warning",children:[c.label," ",c.fix?(0,i.jsx)("a",{className:"text-link muted",onClick:this.onClickHintFix,children:c.fix.label}):null]})}):null]})}})}}const Ve=Qe;var Me,$e,Ue,Xe;function Be(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const{Switch:ze}=h.LegacyForms,We=[{label:"Time series",value:"time_series"},{label:"Table",value:"table"},{label:"Heatmap",value:"heatmap"}],Ke=(0,re.map)([1,2,3,4,5,10],(e=>({value:e,label:"1/"+e})));class Ge extends r.PureComponent{constructor(e){super(e),Be(this,"query",void 0),Be(this,"onFieldChange",((e,t)=>{this.query.expr=e.expr})),Be(this,"onFormatChange",(e=>{this.query.format=e.value,this.setState({formatOption:e},this.onRunQuery)})),Be(this,"onInstantChange",(e=>{const t=e.target.checked;this.query.instant=t,this.setState({instant:t},this.onRunQuery)})),Be(this,"onIntervalChange",(e=>{const t=e.currentTarget.value;this.query.interval=t,this.setState({interval:t})})),Be(this,"onIntervalFactorChange",(e=>{this.query.intervalFactor=e.value,this.setState({intervalFactorOption:e},this.onRunQuery)})),Be(this,"onLegendChange",(e=>{const t=e.currentTarget.value;this.query.legendFormat=t,this.setState({legendFormat:t})})),Be(this,"onExemplarChange",(e=>{this.query.exemplar=e,this.setState({exemplar:e},this.onRunQuery)})),Be(this,"onRunQuery",(()=>{const{query:e}=this,{hide:t}=this.props.query;this.props.onChange(Object.assign({},e,{hide:t})),this.props.onRunQuery()}));const t={expr:"",legendFormat:"",interval:"",exemplar:e.app!==s.CoreApp.UnifiedAlerting},a=Object.assign({},t,e.query);this.query=a,this.state={interval:a.interval,legendFormat:a.legendFormat,formatOption:We.find((e=>e.value===a.format))||We[0],intervalFactorOption:Ke.find((e=>e.value===a.intervalFactor))||Ke[0],instant:Boolean(a.instant),exemplar:Boolean(a.exemplar)}}render(){const{datasource:e,query:t,range:a,data:n}=this.props,{formatOption:r,instant:l,interval:o,intervalFactorOption:c,legendFormat:u}=this.state,d=this.props.app!==s.CoreApp.UnifiedAlerting;return(0,i.jsx)(Ve,{datasource:e,query:t,range:a,onRunQuery:this.onRunQuery,onChange:this.onFieldChange,history:[],data:n,"data-testid":Je.editor,ExtraFieldElement:(0,i.jsxs)("div",{className:"gf-form-inline",children:[(0,i.jsxs)("div",{className:"gf-form",children:[Me||(Me=(0,i.jsx)(h.InlineFormLabel,{width:7,tooltip:"Controls the name of the time series, using name or pattern. For example {{hostname}} will be replaced with label value for the label hostname.",children:"Legend"})),(0,i.jsx)("input",{type:"text",className:"gf-form-input",placeholder:"legend format",value:u,onChange:this.onLegendChange,onBlur:this.onRunQuery})]}),(0,i.jsxs)("div",{className:"gf-form",children:[$e||($e=(0,i.jsx)(h.InlineFormLabel,{width:7,tooltip:(0,i.jsxs)(i.Fragment,{children:["An additional lower limit for the step parameter of the Prometheus query and for the"," ",(0,i.jsx)("code",{children:"$__interval"})," and ",(0,i.jsx)("code",{children:"$__rate_interval"}),' variables. The limit is absolute and not modified by the "Resolution" setting.']}),children:"Min step"})),(0,i.jsx)("input",{type:"text",className:"gf-form-input width-8","aria-label":"Set lower limit for the step parameter",placeholder:o,onChange:this.onIntervalChange,onBlur:this.onRunQuery,value:o})]}),(0,i.jsxs)("div",{className:"gf-form",children:[Ue||(Ue=(0,i.jsx)("div",{className:"gf-form-label",children:"Resolution"})),(0,i.jsx)(h.Select,{"aria-label":"Select resolution",isSearchable:!1,options:Ke,onChange:this.onIntervalFactorChange,value:c})]}),(0,i.jsxs)("div",{className:"gf-form",children:[Xe||(Xe=(0,i.jsx)("div",{className:"gf-form-label width-7",children:"Format"})),(0,i.jsx)(h.Select,{className:"select-container",width:16,isSearchable:!1,options:We,onChange:this.onFormatChange,value:r,"aria-label":"Select format"}),(0,i.jsx)(ze,{label:"Instant",checked:l,onChange:this.onInstantChange}),(0,i.jsx)(h.InlineFormLabel,{width:10,tooltip:"Link to Graph in Prometheus",children:(0,i.jsx)(fe,{datasource:e,query:this.query,panelData:n})})]}),d&&(0,i.jsx)(oe,{onChange:this.onExemplarChange,datasource:e,query:this.query,"data-testid":Je.exemplar})]})})}}const Je={editor:"prom-editor",exemplar:"exemplar-editor"};var He=a(68374);const Ze=[{label:"Auto",value:_.Auto,description:"Only includes unique labels"},{label:"Verbose",value:_.Verbose,description:"All label names and values"},{label:"Custom",value:_.Custom,description:"Provide a naming template"}],Ye=r.memo((e=>{let{legendFormat:t,onChange:a,onRunQuery:n}=e;const s=et(t),l=(0,r.useRef)(null);return(0,i.jsx)(d.EditorField,{label:"Legend",tooltip:"Series name override or template. Ex. {{hostname}} will be replaced with label value for hostname.",children:(0,i.jsxs)(i.Fragment,{children:[s===_.Custom&&(0,i.jsx)(M.H,{id:"legendFormat",minWidth:22,placeholder:"auto",defaultValue:t,onCommitChange:e=>{let s=e.currentTarget.value;0===s.length&&(s=_.Auto),s!==t&&(a(s),n())},ref:l}),s!==_.Custom&&(0,i.jsx)(h.Select,{inputId:"legend.mode",isSearchable:!1,placeholder:"Select legend mode",options:Ze,width:22,onChange:e=>{switch(e.value){case _.Auto:a(_.Auto);break;case _.Custom:a("{{label_name}}"),setTimeout((()=>{var e,t;null===(e=l.current)||void 0===e||e.focus(),null===(t=l.current)||void 0===t||t.setSelectionRange(2,12,"forward")}),10);break;case _.Verbose:a("")}n()},value:Ze.find((e=>e.value===s))})]})})}));function et(e){return e===_.Auto?_.Auto:null==e||""===e?_.Verbose:_.Custom}var tt,at;Ye.displayName="PromQueryLegendEditor";const nt=r.memo((e=>{let{query:t,app:a,onChange:n,onRunQuery:r}=e;const l=me(a===s.CoreApp.Explore),o=pe(t,n),c=We.find((e=>e.value===t.format))||We[0],u=function(e){return e.range&&e.instant?"both":e.instant?"instant":"range"}(t),m=l.find((e=>e.value===u)).label;return(0,i.jsx)(d.EditorRow,{children:(0,i.jsxs)(He.d,{title:"Options",collapsedInfo:rt(t,c.label,m),children:[(0,i.jsx)(Ye,{legendFormat:t.legendFormat,onChange:e=>n(Object.assign({},t,{legendFormat:e})),onRunQuery:r}),(0,i.jsx)(d.EditorField,{label:"Min step",tooltip:(0,i.jsxs)(i.Fragment,{children:["An additional lower limit for the step parameter of the Prometheus query and for the"," ",tt||(tt=(0,i.jsx)("code",{children:"$__interval"}))," and ",at||(at=(0,i.jsx)("code",{children:"$__rate_interval"}))," variables."]}),children:(0,i.jsx)(M.H,{type:"text","aria-label":"Set lower limit for the step parameter",placeholder:"auto",minWidth:10,onCommitChange:e=>{n(Object.assign({},t,{interval:e.currentTarget.value})),r()},defaultValue:t.interval})}),(0,i.jsx)(d.EditorField,{label:"Format",children:(0,i.jsx)(h.Select,{value:c,allowCustomValue:!0,onChange:e=>{n(Object.assign({},t,{format:e.value})),r()},options:We})}),(0,i.jsx)(d.EditorField,{label:"Type",children:(0,i.jsx)(h.RadioButtonGroup,{options:l,value:u,onChange:o})}),st(t,a)&&(0,i.jsx)(d.EditorField,{label:"Exemplars",children:(0,i.jsx)(d.EditorSwitch,{value:t.exemplar,onChange:e=>{const a=e.currentTarget.checked;n(Object.assign({},t,{exemplar:a})),r()}})}),t.intervalFactor&&t.intervalFactor>1&&(0,i.jsx)(d.EditorField,{label:"Resolution",children:(0,i.jsx)(h.Select,{"aria-label":"Select resolution",isSearchable:!1,options:Ke,onChange:e=>{n(Object.assign({},t,{intervalFactor:e.value})),r()},value:Ke.find((e=>e.value===t.intervalFactor))})})]})})}));function st(e,t){return!(t===s.CoreApp.UnifiedAlerting||!e.range)}function rt(e,t,a){const n=[];return n.push(`Legend: ${function(e){const t=et(e);var a;return t!==_.Custom?null===(a=Ze.find((e=>e.value===t)))||void 0===a?void 0:a.label:e}(e.legendFormat)}`),n.push(`Format: ${t}`),n.push(`Step ${e.interval}`),n.push(`Type: ${a}`),e.exemplar&&n.push("Exemplars: true"),n}function it(e){let{query:t,datasource:a,range:n,onRunQuery:s,onChange:r,data:l,app:o}=e;const c=(0,h.useStyles2)(lt);return(0,i.jsx)("div",{className:c.wrapper,children:(0,i.jsx)(Ve,{datasource:a,query:t,range:n,onRunQuery:s,onChange:r,history:[],data:l,"data-testid":Je.editor,app:o})})}nt.displayName="PromQueryBuilderOptions";const lt=e=>({wrapper:g.css`
      .gf-form {
        margin-bottom: 0;
      }
    `});var ot,ct,ut;const dt=r.memo((e=>{const{onChange:t,onRunQuery:a,data:n,app:l}=e,[o,c]=(0,r.useState)(!1),[g,f]=(0,r.useState)(!1),j=function(e,t){let a=e;return e.editorMode||(a=Object.assign({},e,{editorMode:I(e.expr)})),null==e.expr&&(a=Object.assign({},a,{expr:"",legendFormat:_.Auto})),null==e.range&&null==e.instant&&(a=Object.assign({},a,{range:!0}),t===s.CoreApp.Explore&&(a.instant=!0)),a}(e.query,l),[T,S]=D(),C=j.editorMode,E=(0,r.useCallback)((e=>{var a;if((0,u.reportInteraction)("user_grafana_prometheus_editor_mode_clicked",{newEditor:e,previousEditor:null!==(a=j.editorMode)&&void 0!==a?a:"",newQuery:!j.expr,app:null!=l?l:""}),e===y.c.Builder){if((0,p._)(j.expr||"").errors.length)return void c(!0)}w(j,e,t)}),[t,j,l]);(0,r.useEffect)((()=>{f(!1)}),[n]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(h.ConfirmModal,{isOpen:o,title:"Query parsing",body:"There were errors while trying to parse the query. Continuing to visual builder may loose some parts of the query.",confirmText:"Continue",onConfirm:()=>{w(j,y.c.Builder,t),c(!1)},onDismiss:()=>c(!1)}),(0,i.jsxs)(d.EditorHeader,{children:[C===y.c.Builder&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(d.InlineSelect,{value:null,placeholder:"Query patterns",allowCustomValue:!0,onChange:e=>{let{value:a}=e;const n=(0,p._)(j.expr||"");n.query.operations=null==a?void 0:a.operations,t(Object.assign({},j,{expr:m.Z.renderQuery(n.query)}))},options:m.Z.getQueryPatterns().map((e=>({label:e.name,value:e})))}),(0,i.jsx)(x.n,{label:"Raw query",value:T,onChange:e=>{const t=e.currentTarget.checked;S(t)}})]}),C===y.c.Builder&&(ot||(ot=(0,i.jsx)(v,{feedbackUrl:"https://github.com/grafana/grafana/discussions/47693"}))),ct||(ct=(0,i.jsx)(d.FlexItem,{grow:1})),l!==s.CoreApp.Explore&&(0,i.jsx)(h.Button,{variant:g?"primary":"secondary",size:"sm",onClick:a,icon:(null==n?void 0:n.state)===s.LoadingState.Loading?"fa fa-spinner":void 0,disabled:(null==n?void 0:n.state)===s.LoadingState.Loading,children:"Run queries"}),(0,i.jsx)(b.k,{mode:C,onChange:E})]}),ut||(ut=(0,i.jsx)(d.Space,{v:.5})),(0,i.jsxs)(d.EditorRows,{children:[C===y.c.Code&&(0,i.jsx)(it,Object.assign({},e)),C===y.c.Builder&&(0,i.jsx)(Z,{query:j,datasource:e.datasource,onChange:e=>{f(!0),t(e)},onRunQuery:e.onRunQuery,data:n,showRawQuery:T}),C===y.c.Explain&&(0,i.jsx)(se,{query:j.expr}),C!==y.c.Explain&&(0,i.jsx)(nt,{query:j,app:e.app,onChange:t,onRunQuery:a})]})]})}));dt.displayName="PromQueryEditorSelector";const ht=(0,r.memo)((e=>{const{range:t,query:a,data:n,datasource:l,history:o,onChange:c,onRunQuery:u}=e;return(0,r.useEffect)((()=>{void 0===a.expr&&c(Object.assign({},a,{expr:""})),void 0===a.exemplar&&c(Object.assign({},a,{exemplar:!0})),a.instant||a.range||a.expr||c(Object.assign({},a,{instant:!0,range:!0}))}),[c,a]),(0,i.jsx)(Ve,{app:s.CoreApp.Explore,datasource:l,query:a,range:t,onRunQuery:u,onChange:c,onBlur:()=>{},history:o,data:n,"data-testid":mt.editor,ExtraFieldElement:(0,i.jsx)(he,{query:a,onChange:c,datasource:l,onRunQuery:u})})}));ht.displayName="PromExploreQueryEditor";const mt={editor:"prom-editor-explore"};function pt(e){const{datasource:t,query:a,range:n,data:s,onChange:r,onRunQuery:l}=e;return(0,i.jsx)(Ve,{datasource:t,query:a,onRunQuery:l,onChange:r,history:[],range:n,data:s,"data-testid":gt.editor})}const gt={editor:"prom-editor-cloud-alerting"};function vt(e){const{app:t}=e;switch(t){case s.CoreApp.CloudAlerting:return(0,i.jsx)(pt,Object.assign({},e));case s.CoreApp.Explore:return u.config.featureToggles.promQueryBuilder?(0,i.jsx)(dt,Object.assign({},e)):(0,i.jsx)(ht,Object.assign({},e));default:return u.config.featureToggles.promQueryBuilder?(0,i.jsx)(dt,Object.assign({},e)):(0,i.jsx)(Ge,Object.assign({},e))}}const ft=(0,r.memo)(vt);var bt=a(47472),xt=a(78837),yt=a(82139);let jt;!function(e){e.Public="AzureCloud",e.China="AzureChinaCloud",e.USGovernment="AzureUSGovernment",e.Germany="AzureGermanCloud",e.None=""}(jt||(jt={}));const Tt=[{value:jt.Public,label:"Azure"},{value:jt.China,label:"Azure China"},{value:jt.USGovernment,label:"Azure US Government"},{value:jt.Germany,label:"Azure Germany"}];const _t=Symbol("Concealed client secret");function St(){return u.config.azure.cloud||jt.Public}function Ct(e){if(e.secureJsonFields.azureClientSecret)return _t;{var t;const a=null===(t=e.secureJsonData)||void 0===t?void 0:t.azureClientSecret;return"string"==typeof a&&a.length>0?a:void 0}}function wt(){return u.config.azure.managedIdentityEnabled?{authType:"msi"}:{authType:"clientsecret",azureCloud:St()}}var It,Et,Dt,qt,Rt,Ot,Ft,Nt=a(34148),At=a(5414),kt=a(11136);const Pt=[{value:"msi",label:"Managed Identity"},{value:"clientsecret",label:"App Registration"}],Lt=e=>{const{credentials:t,azureCloudOptions:a,onCredentialsChange:n,getSubscriptions:s}=e,l=function(e){switch(e.authType){case"msi":return!0;case"clientsecret":return!!(e.azureCloud&&e.tenantId&&e.clientId&&e.clientSecret)}}(t),[o,c]=(0,r.useState)([]),[u,d]=(0,r.useReducer)((e=>e+1),0);(0,r.useEffect)((()=>{if(!s||!l)return void h([]);let e=!1;return s().then((t=>{e||h(t,u)})),()=>{e=!0}}),[u]);const h=function(e){let a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(c(e),s)if(a&&!t.defaultSubscriptionId&&e.length>0)m(e[0]);else if(t.defaultSubscriptionId){e.find((e=>e.value===t.defaultSubscriptionId))||m(void 0)}},m=e=>{if(n){const a=Object.assign({},t,{defaultSubscriptionId:null==e?void 0:e.value});n(a)}};return(0,i.jsxs)("div",{className:"gf-form-group",children:[e.managedIdentityEnabled&&(0,i.jsx)("div",{className:"gf-form-inline",children:(0,i.jsxs)("div",{className:"gf-form",children:[It||(It=(0,i.jsx)(Nt.cJ0,{className:"width-12",tooltip:"Choose the type of authentication to Azure services",children:"Authentication"})),(0,i.jsx)(kt.Ph,{className:"width-15",value:Pt.find((e=>e.value===t.authType)),options:Pt,onChange:e=>{if(n){c([]);const a=Object.assign({},t,{authType:e.value||"msi",defaultSubscriptionId:void 0});n(a)}}})]})}),"clientsecret"===t.authType&&(0,i.jsxs)(i.Fragment,{children:[a&&(0,i.jsx)("div",{className:"gf-form-inline",children:(0,i.jsxs)("div",{className:"gf-form",children:[Et||(Et=(0,i.jsx)(Nt.cJ0,{className:"width-12",tooltip:"Choose an Azure Cloud",children:"Azure Cloud"})),(0,i.jsx)(kt.Ph,{className:"width-15",value:a.find((e=>e.value===t.azureCloud)),options:a,onChange:e=>{if(n&&"clientsecret"===t.authType){c([]);const a=Object.assign({},t,{azureCloud:e.value,defaultSubscriptionId:void 0});n(a)}}})]})}),(0,i.jsx)("div",{className:"gf-form-inline",children:(0,i.jsxs)("div",{className:"gf-form",children:[Dt||(Dt=(0,i.jsx)(Nt.cJ0,{className:"width-12",children:"Directory (tenant) ID"})),(0,i.jsx)("div",{className:"width-15",children:(0,i.jsx)(At.I,{className:"width-30",placeholder:"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",value:t.tenantId||"",onChange:e=>{if(n&&"clientsecret"===t.authType){c([]);const a=Object.assign({},t,{tenantId:e.target.value,defaultSubscriptionId:void 0});n(a)}}})})]})}),(0,i.jsx)("div",{className:"gf-form-inline",children:(0,i.jsxs)("div",{className:"gf-form",children:[qt||(qt=(0,i.jsx)(Nt.cJ0,{className:"width-12",children:"Application (client) ID"})),(0,i.jsx)("div",{className:"width-15",children:(0,i.jsx)(At.I,{className:"width-30",placeholder:"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",value:t.clientId||"",onChange:e=>{if(n&&"clientsecret"===t.authType){c([]);const a=Object.assign({},t,{clientId:e.target.value,defaultSubscriptionId:void 0});n(a)}}})})]})}),"symbol"==typeof t.clientSecret?(0,i.jsxs)("div",{className:"gf-form-inline",children:[Rt||(Rt=(0,i.jsxs)("div",{className:"gf-form",children:[(0,i.jsx)(Nt.cJ0,{className:"width-12",children:"Client Secret"}),(0,i.jsx)(At.I,{className:"width-25",placeholder:"configured",disabled:!0})]})),(0,i.jsx)("div",{className:"gf-form",children:(0,i.jsx)("div",{className:"max-width-30 gf-form-inline",children:(0,i.jsx)(Nt.zxk,{variant:"secondary",type:"button",onClick:()=>{if(n&&"clientsecret"===t.authType){c([]);const e=Object.assign({},t,{clientSecret:"",defaultSubscriptionId:void 0});n(e)}},children:"reset"})})})]}):(0,i.jsx)("div",{className:"gf-form-inline",children:(0,i.jsxs)("div",{className:"gf-form",children:[Ot||(Ot=(0,i.jsx)(Nt.cJ0,{className:"width-12",children:"Client Secret"})),(0,i.jsx)("div",{className:"width-15",children:(0,i.jsx)(At.I,{className:"width-30",placeholder:"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",value:t.clientSecret||"",onChange:e=>{if(n&&"clientsecret"===t.authType){c([]);const a=Object.assign({},t,{clientSecret:e.target.value,defaultSubscriptionId:void 0});n(a)}}})})]})})]}),s&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"gf-form-inline",children:(0,i.jsxs)("div",{className:"gf-form",children:[Ft||(Ft=(0,i.jsx)(Nt.cJ0,{className:"width-12",children:"Default Subscription"})),(0,i.jsx)("div",{className:"width-25",children:(0,i.jsx)(kt.Ph,{value:t.defaultSubscriptionId?o.find((e=>e.value===t.defaultSubscriptionId)):void 0,options:o,onChange:m})})]})}),(0,i.jsx)("div",{className:"gf-form-inline",children:(0,i.jsx)("div",{className:"gf-form",children:(0,i.jsx)("div",{className:"max-width-30 gf-form-inline",children:(0,i.jsx)(Nt.zxk,{variant:"secondary",size:"sm",type:"button",onClick:d,disabled:!l,children:"Load Subscriptions"})})})})]})]})};var Qt,Vt;const Mt=e=>{const{dataSourceConfig:t,onChange:a}=e,[n]=(0,r.useState)(u.config.featureToggles.prometheusAzureOverrideAudience||!!t.jsonData.azureEndpointResourceId),[s,l]=(0,r.useState)(!!t.jsonData.azureEndpointResourceId),o=(0,r.useMemo)((()=>function(e){const t=e.jsonData.azureCredentials;if(!t)return wt();switch(t.authType){case"msi":return u.config.azure.managedIdentityEnabled?{authType:"msi"}:{authType:"clientsecret",azureCloud:St()};case"clientsecret":return{authType:"clientsecret",azureCloud:t.azureCloud||St(),tenantId:t.tenantId,clientId:t.clientId,clientSecret:Ct(e)}}}(t)),[t]);return(0,i.jsxs)(i.Fragment,{children:[Qt||(Qt=(0,i.jsx)("h6",{children:"Azure Authentication"})),(0,i.jsx)(Lt,{managedIdentityEnabled:u.config.azure.managedIdentityEnabled,credentials:o,azureCloudOptions:Tt,onCredentialsChange:e=>{a(function(e,t){switch(t.authType){case"msi":if(!u.config.azure.managedIdentityEnabled)throw new Error("Managed Identity authentication is not enabled in Grafana config.");return Object.assign({},e,{jsonData:Object.assign({},e.jsonData,{azureCredentials:{authType:"msi"}})});case"clientsecret":return Object.assign({},e,{jsonData:Object.assign({},e.jsonData,{azureCredentials:{authType:"clientsecret",azureCloud:t.azureCloud||St(),tenantId:t.tenantId,clientId:t.clientId}}),secureJsonData:Object.assign({},e.secureJsonData,{azureClientSecret:"string"==typeof t.clientSecret&&t.clientSecret.length>0?t.clientSecret:void 0}),secureJsonFields:Object.assign({},e.secureJsonFields,{azureClientSecret:"symbol"==typeof t.clientSecret})})}}(t,e))}}),n&&(0,i.jsxs)(i.Fragment,{children:[Vt||(Vt=(0,i.jsx)("h6",{children:"Azure Configuration"})),(0,i.jsxs)("div",{className:"gf-form-group",children:[(0,i.jsx)(h.InlineFieldRow,{children:(0,i.jsx)(h.InlineField,{labelWidth:26,label:"Override AAD audience",children:(0,i.jsx)(h.InlineSwitch,{value:s,onChange:e=>{l(e.currentTarget.checked),e.currentTarget.checked||a(Object.assign({},t,{jsonData:Object.assign({},t.jsonData,{azureEndpointResourceId:void 0})}))}})})}),s&&(0,i.jsx)(h.InlineFieldRow,{children:(0,i.jsx)(h.InlineField,{labelWidth:26,label:"Resource ID",children:(0,i.jsx)(h.Input,{className:"width-30",value:t.jsonData.azureEndpointResourceId||"",onChange:e=>{s&&a(Object.assign({},t,{jsonData:Object.assign({},t.jsonData,{azureEndpointResourceId:e.currentTarget.value})}))}})})})]})]})]})};var $t,Ut,Xt,Bt=a(16695);function zt(e){let{value:t,onChange:a,onDelete:n}=e;const[s,l]=(0,r.useState)(Boolean(t.datasourceUid));return(0,i.jsxs)("div",{className:"gf-form-group",children:[(0,i.jsx)(h.InlineField,{label:"Internal link",labelWidth:24,children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(h.InlineSwitch,{value:s,"aria-label":Bt.wl.components.DataSource.Prometheus.configPage.internalLinkSwitch,onChange:e=>l(e.currentTarget.checked)}),(0,i.jsx)(h.Button,{variant:"destructive",title:"Remove link",icon:"times",onClick:e=>{e.preventDefault(),n()},className:g.css`
              margin-left: 8px;
            `})]})}),s?(0,i.jsx)(h.InlineField,{label:"Data source",labelWidth:24,tooltip:"The data source the exemplar is going to navigate to.",children:(0,i.jsx)(u.DataSourcePicker,{tracing:!0,current:t.datasourceUid,noDefault:!0,width:40,onChange:e=>a(Object.assign({},t,{datasourceUid:e.uid,url:void 0}))})}):(0,i.jsx)(h.InlineField,{label:"URL",labelWidth:24,tooltip:"The URL of the trace backend the user would go to see its trace.",children:(0,i.jsx)(h.Input,{placeholder:"https://example.com/${__value.raw}",spellCheck:!1,width:40,value:t.url,onChange:e=>a(Object.assign({},t,{datasourceUid:void 0,url:e.currentTarget.value}))})}),(0,i.jsx)(h.InlineField,{label:"URL Label",labelWidth:24,tooltip:"Use to override the button label on the exemplar traceID field.",children:(0,i.jsx)(h.Input,{placeholder:"Go to example.com",spellCheck:!1,width:40,value:t.urlDisplayLabel,onChange:e=>a(Object.assign({},t,{urlDisplayLabel:e.currentTarget.value}))})}),(0,i.jsx)(h.InlineField,{label:"Label name",labelWidth:24,tooltip:"The name of the field in the labels object that should be used to get the traceID.",children:(0,i.jsx)(h.Input,{placeholder:"traceID",spellCheck:!1,width:40,value:t.name,onChange:e=>a(Object.assign({},t,{name:e.currentTarget.value}))})})]})}function Wt(e){let{options:t,onChange:a}=e;return(0,i.jsxs)(i.Fragment,{children:[$t||($t=(0,i.jsx)("h3",{className:"page-heading",children:"Exemplars"})),t&&t.map(((e,n)=>(0,i.jsx)(zt,{value:e,onChange:e=>{const s=[...t];s.splice(n,1,e),a(s)},onDelete:()=>{const e=[...t];e.splice(n,1),a(e)}},n))),(0,i.jsx)(h.Button,{variant:"secondary","aria-label":Bt.wl.components.DataSource.Prometheus.configPage.exemplarsAddButton,className:g.css`
          margin-bottom: 10px;
        `,icon:"plus",onClick:e=>{e.preventDefault();const n=[...t||[],{name:"traceID"}];a(n)},children:"Add"})]})}const{Select:Kt,Input:Gt,FormField:Jt}=h.LegacyForms,Ht=[{value:"POST",label:"POST"},{value:"GET",label:"GET"}],Zt=e=>{var t;const{options:a,onOptionsChange:n}=e;return a.jsonData.httpMethod||(a.jsonData.httpMethod="POST"),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"gf-form-group",children:[(0,i.jsx)("div",{className:"gf-form-inline",children:(0,i.jsx)("div",{className:"gf-form",children:(0,i.jsx)(Jt,{label:"Scrape interval",labelWidth:13,inputEl:(0,i.jsx)(Gt,{className:"width-6",value:a.jsonData.timeInterval,spellCheck:!1,placeholder:"15s",onChange:ta("timeInterval",a,n),validationEvents:Yt}),tooltip:"Set this to the typical scrape and evaluation interval configured in Prometheus. Defaults to 15s."})})}),(0,i.jsx)("div",{className:"gf-form-inline",children:(0,i.jsx)("div",{className:"gf-form",children:(0,i.jsx)(Jt,{label:"Query timeout",labelWidth:13,inputEl:(0,i.jsx)(Gt,{className:"width-6",value:a.jsonData.queryTimeout,onChange:ta("queryTimeout",a,n),spellCheck:!1,placeholder:"60s",validationEvents:Yt}),tooltip:"Set the Prometheus query timeout."})})}),(0,i.jsxs)("div",{className:"gf-form",children:[Ut||(Ut=(0,i.jsx)(h.InlineFormLabel,{width:13,tooltip:"You can use either POST or GET HTTP method to query your Prometheus data source. POST is the recommended method as it allows bigger queries. Change this to GET if you have a Prometheus version older than 2.1 or if POST requests are restricted in your network.",children:"HTTP Method"})),(0,i.jsx)(Kt,{"aria-label":"Select HTTP method",options:Ht,value:Ht.find((e=>e.value===a.jsonData.httpMethod)),onChange:ta("httpMethod",a,n),width:7})]})]}),Xt||(Xt=(0,i.jsx)("h3",{className:"page-heading",children:"Misc"})),(0,i.jsxs)("div",{className:"gf-form-group",children:[(0,i.jsx)("div",{className:"gf-form",children:(0,i.jsx)(h.InlineField,{labelWidth:28,label:"Disable metrics lookup",tooltip:"Checking this option will disable the metrics chooser and metric/label support in the query field's autocomplete. This helps if you have performance issues with bigger Prometheus instances.",children:(0,i.jsx)(h.InlineSwitch,{value:null!==(t=a.jsonData.disableMetricsLookup)&&void 0!==t&&t,onChange:(0,s.onUpdateDatasourceJsonDataOptionChecked)(e,"disableMetricsLookup")})})}),(0,i.jsx)("div",{className:"gf-form-inline",children:(0,i.jsx)("div",{className:"gf-form max-width-30",children:(0,i.jsx)(Jt,{label:"Custom query parameters",labelWidth:14,tooltip:"Add Custom parameters to all Prometheus or Thanos queries.",inputEl:(0,i.jsx)(Gt,{className:"width-25",value:a.jsonData.customQueryParameters,onChange:ta("customQueryParameters",a,n),spellCheck:!1,placeholder:"Example: max_source_resolution=5m&timeout=10"})})})})]}),(0,i.jsx)(Wt,{options:a.jsonData.exemplarTraceIdDestinations,onChange:e=>(0,s.updateDatasourcePluginJsonDataOption)({onOptionsChange:n,options:a},"exemplarTraceIdDestinations",e)})]})},Yt={[h.EventsWithValidation.onBlur]:[(0,h.regexValidation)(/^$|^\d+(ms|[Mwdhmsy])$/,"Value is not valid, you can use number with time unit specifier: y, M, w, d, h, m, s")]},ea=e=>e?e.hasOwnProperty("currentTarget")?e.currentTarget.value:e.value:"",ta=(e,t,a)=>n=>{a(Object.assign({},t,{jsonData:Object.assign({},t.jsonData,{[e]:ea(n)})}))};var aa;var na,sa,ra,ia=a(64303),la=a.n(ia),oa=a(58788),ca=a(2937),ua=a(6639),da=a(73296),ha=a(88399),ma=a(26702),pa=a(10010),ga=a(25162),va=a(87173),fa=a(76913),ba=a(62236),xa=a(15458),ya=a(75478),ja=a(7166),Ta=a(51542),_a=a(17966);function Sa(e){const t=e.annotation,a=e.onAnnotationChange,n={expr:t.expr,refId:t.name,interval:t.step};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(d.EditorRows,{children:[(0,i.jsx)(it,Object.assign({},e,{query:n,onChange:e=>{a(Object.assign({},t,{expr:e.expr}))}})),(0,i.jsx)(d.EditorRow,{children:(0,i.jsx)(d.EditorField,{label:"Min step",tooltip:(0,i.jsxs)(i.Fragment,{children:["An additional lower limit for the step parameter of the Prometheus query and for the"," ",na||(na=(0,i.jsx)("code",{children:"$__interval"}))," and ",sa||(sa=(0,i.jsx)("code",{children:"$__rate_interval"}))," variables."]}),children:(0,i.jsx)(M.H,{type:"text","aria-label":"Set lower limit for the step parameter",placeholder:"auto",minWidth:10,onCommitChange:e=>{a(Object.assign({},t,{step:e.currentTarget.value}))},defaultValue:n.interval})})})]}),ra||(ra=(0,i.jsx)(d.Space,{v:.5})),(0,i.jsxs)(d.EditorRow,{children:[(0,i.jsx)(d.EditorField,{label:"Title",tooltip:"Use either the name or a pattern. For example, {{instance}} is replaced with label value for the label instance.",children:(0,i.jsx)(h.Input,{type:"text",placeholder:"{{alertname}}",value:t.titleFormat,onChange:e=>{a(Object.assign({},t,{titleFormat:e.currentTarget.value}))}})}),(0,i.jsx)(d.EditorField,{label:"Tags",children:(0,i.jsx)(h.Input,{type:"text",placeholder:"label1,label2",value:t.tagKeys,onChange:e=>{a(Object.assign({},t,{tagKeys:e.currentTarget.value}))}})}),(0,i.jsx)(d.EditorField,{label:"Text",tooltip:"Use either the name or a pattern. For example, {{instance}} is replaced with label value for the label instance.",children:(0,i.jsx)(h.Input,{type:"text",placeholder:"{{instance}}",value:t.textFormat,onChange:e=>{a(Object.assign({},t,{textFormat:e.currentTarget.value}))}})}),(0,i.jsx)(d.EditorField,{label:"Series value as timestamp",tooltip:"The unit of timestamp is milliseconds. If the unit of the series value is seconds, multiply its range vector by 1000.",children:(0,i.jsx)(d.EditorSwitch,{value:t.useValueForTime,onChange:e=>{a(Object.assign({},t,{useValueForTime:e.currentTarget.value}))}})})]})]})}var Ca=a(18887);class wa{constructor(e,t){var a,n,s;s=void 0,(n="range")in(a=this)?Object.defineProperty(a,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):a[n]=s,this.datasource=e,this.query=t,this.datasource=e,this.query=t,this.range=(0,ya.$t)().timeRange()}process(){if(this.query.match(/^label_names\(\)\s*$/))return this.labelNamesQuery();const e=this.query.match(/^label_values\((?:(.+),\s*)?([a-zA-Z_][a-zA-Z0-9_]*)\)\s*$/);if(e)return e[1]?this.labelValuesQuery(e[2],e[1]):this.labelValuesQuery(e[2]);const t=this.query.match(/^metrics\((.+)\)\s*$/);if(t)return this.metricNameQuery(t[1]);const a=this.query.match(/^query_result\((.+)\)\s*$/);return a?(0,oa.n)(this.queryResultQuery(a[1])):this.metricNameAndLabelsQuery(this.query)}labelNamesQuery(){const e=this.datasource.getPrometheusTime(this.range.from,!1),t=this.datasource.getPrometheusTime(this.range.to,!0),a={start:e.toString(),end:t.toString()};return this.datasource.metadataRequest("/api/v1/labels",a).then((e=>(0,re.map)(e.data.data,(e=>({text:e})))))}labelValuesQuery(e,t){const a=this.datasource.getPrometheusTime(this.range.from,!1),n=this.datasource.getPrometheusTime(this.range.to,!0);let s;if(t){const r={"match[]":t,start:a.toString(),end:n.toString()};return s="/api/v1/series",this.datasource.metadataRequest(s,r).then((t=>{const a=(0,re.map)(t.data.data,(t=>t[e]||"")).filter((e=>""!==e));return(0,re.uniq)(a).map((e=>({text:e,expandable:!0})))}))}{const t={start:a.toString(),end:n.toString()};return s=`/api/v1/label/${e}/values`,this.datasource.metadataRequest(s,t).then((e=>(0,re.map)(e.data.data,(e=>({text:e})))))}}metricNameQuery(e){const t=this.datasource.getPrometheusTime(this.range.from,!1),a=this.datasource.getPrometheusTime(this.range.to,!0),n={start:t.toString(),end:a.toString()};return this.datasource.metadataRequest("/api/v1/label/__name__/values",n).then((t=>(0,re.chain)(t.data.data).filter((t=>new RegExp(e).test(t))).map((e=>({text:e,expandable:!0}))).value()))}queryResultQuery(e){const t=this.datasource.getPrometheusTime(this.range.to,!0),a={expr:e};return this.datasource.performInstantQuery(a,t).pipe((0,pa.U)((e=>(0,re.map)(e.data.data.result,(e=>{let t=e.metric.__name__||"";return delete e.metric.__name__,t+="{"+(0,re.map)(e.metric,((e,t)=>t+'="'+e+'"')).join(",")+"}",t+=" "+e.value[1]+" "+1e3*e.value[0],{text:t,expandable:!0}})))))}metricNameAndLabelsQuery(e){const t=this.datasource.getPrometheusTime(this.range.from,!1),a=this.datasource.getPrometheusTime(this.range.to,!0),n={"match[]":e,start:t.toString(),end:a.toString()},s=this;return this.datasource.metadataRequest("/api/v1/series",n).then((e=>(0,re.map)(e.data.data,(e=>({text:s.datasource.getOriginalMetricName(e),expandable:!0})))))}}var Ia=a(24314);const Ea=["__name__"];const Da=/^[+-]?inf(?:inity)?$/i;function qa(e,t,a){const[n,r]=(0,re.partition)(e.data,(e=>((e,t)=>{var a,n,r,i;if(t.app===s.CoreApp.Explore&&("vector"===(null===(a=e.meta)||void 0===a||null===(n=a.custom)||void 0===n?void 0:n.resultType)||"scalar"===(null===(r=e.meta)||void 0===r||null===(i=r.custom)||void 0===i?void 0:i.resultType)))return!0;const l=t.targets.find((t=>t.refId===e.refId));return"table"===(null==l?void 0:l.format)})(e,t))),i=function(e){if(0===e.length||1===e.length&&0===e[0].length)return e;const t=(0,re.groupBy)(e,"refId"),a=Object.keys(t);return a.map((n=>{const r=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return e>1?`Value #${t}`:"Value"}(a.length,n),i=Aa({data:[],valueName:r}),l=Na([]),o=[];t[n].forEach((e=>{var t;const a=null!==(t=e.fields[1].labels)&&void 0!==t?t:{};Object.keys(a).sort().forEach((e=>{if(!o.some((t=>t.name===e))){const t="le"===e;o.push({name:e,config:{filterable:!0},type:t?s.FieldType.number:s.FieldType.string,values:new s.ArrayVector})}}))})),t[n].forEach((e=>{e.fields[0].values.toArray().forEach((e=>l.values.add(e))),e.fields[1].values.toArray().forEach((t=>{var a;i.values.add(Qa(t));const n=null!==(a=e.fields[1].labels)&&void 0!==a?a:{};o.forEach((e=>e.values.add(Fa(n,e.name))))}))}));return{refId:n,fields:[l,...o,i],meta:Object.assign({},e[0].meta,{preferredVisualisationType:"table"}),length:l.values.length}}))}(n),[l,o]=(0,re.partition)(r,(e=>{var t,a;return"exemplar"===(null===(t=e.meta)||void 0===t||null===(a=t.custom)||void 0===a?void 0:a.resultType)})),{exemplarTraceIdDestinations:c}=a,u=l.map((e=>{if(null!=c&&c.length)for(const a of c){const n=e.fields.find((e=>e.name===a.name));if(n){var t;const e=Oa(a);n.config.links=null!==(t=n.config.links)&&void 0!==t&&t.length?[...n.config.links,...e]:e}}return Object.assign({},e,{meta:Object.assign({},e.meta,{dataTopic:s.DataTopic.Annotations})})})),[d,h]=(0,re.partition)(o,(e=>((e,t)=>{const a=t.targets.find((t=>t.refId===e.refId));return"heatmap"===(null==a?void 0:a.format)})(e,t))),m=ka(Pa(d.sort(La))),p=h.map((e=>Object.assign({},e,{meta:Object.assign({},e.meta,{preferredVisualisationType:"graph"})})));return Object.assign({},e,{data:[...p,...i,...m,...u]})}function Ra(e,t){const a={format:t.target.format,step:t.query.step,legendFormat:t.target.legendFormat,start:t.query.start,end:t.query.end,query:t.query.expr,responseListLength:t.responseListLength,scopedVars:t.scopedVars,refId:t.target.refId,valueWithRefId:t.target.valueWithRefId,meta:{preferredVisualisationType:t.query.instant?"table":"graph"}},n=e.data.data;if(null!=(l=n)&&Array.isArray(l)&&l.length&&"exemplars"in l[0]){var r;const e=[];n.forEach((t=>{const a=t.exemplars.map((e=>Object.assign({[s.TIME_SERIES_TIME_FIELD_NAME]:1e3*e.timestamp,[s.TIME_SERIES_VALUE_FIELD_NAME]:e.value},e.labels,t.seriesLabels)));e.push(...a)}));const l=function(e,t){const a=t.step||15,n={},r=[];for(const t of e){const e=String(Math.floor(t[s.TIME_SERIES_TIME_FIELD_NAME]/1e3/a)*a*1e3);n[e]||(n[e]=[]),n[e].push(t),r.push(t[s.TIME_SERIES_VALUE_FIELD_NAME])}const i=(0,Ia.deviation)(r),l=Object.keys(n).sort(),o=[];for(const e of l){const t=n[e];if(1===t.length)o.push(t[0]);else{const e=t.map((e=>e[s.TIME_SERIES_VALUE_FIELD_NAME])).sort(Ia.descending).reduce(((e,t)=>{if(0===e.length)e.push(t);else{const a=e[e.length-1];i&&a-t>=2*i&&e.push(t)}return e}),[]);o.push(...e.map((e=>t.find((t=>t[s.TIME_SERIES_VALUE_FIELD_NAME]===e)))))}}return o}(e,a),o=new s.ArrayDataFrame(l);if(o.meta={dataTopic:s.DataTopic.Annotations},null!==(r=t.exemplarTraceIdDestinations)&&void 0!==r&&r.length)for(const e of t.exemplarTraceIdDestinations){const t=o.fields.find((t=>t.name===e.name));if(t){var i;const a=Oa(e);t.config.links=null!==(i=t.config.links)&&void 0!==i&&i.length?[...t.config.links,...a]:a}}return[o]}var l;if(null==n||!n.result)return[];if("scalar"===n.resultType)return[{meta:a.meta,refId:a.refId,length:1,fields:[Na([n.result]),Aa({data:[n.result]})]}];if("table"===a.format){const e=function(e,t){if(!e||0===e.length)return{meta:t.meta,refId:t.refId,length:0,fields:[]};const a=t.responseListLength>1||t.valueWithRefId?`Value #${t.refId}`:"Value",n=Na([]),r=Object.keys(e.reduce(((e,t)=>Object.assign({},e,t.metric)),{})).sort().map((e=>({name:e,config:{filterable:!0},type:"le"===e?s.FieldType.number:s.FieldType.string,values:new s.ArrayVector}))),i=Aa({data:[],valueName:a});return e.forEach((e=>{S(e)?e.values.forEach((t=>{n.values.add(1e3*t[0]),r.forEach((t=>t.values.add(Fa(e.metric,t.name)))),i.values.add(Qa(t[1]))})):(n.values.add(1e3*e.value[0]),r.forEach((t=>t.values.add(Fa(e.metric,t.name)))),i.values.add(Qa(e.value[1])))})),{meta:t.meta,refId:t.refId,length:n.values.length,fields:[n,...r,i]}}(n.result,a);return[e]}const o=[];return n.result.forEach((e=>o.push(function(e,t){const{name:a,labels:n}=function(e,t){if(null!=t&&t.legendFormat){return{name:(0,Ca.W)((0,u.getTemplateSrv)().replace(t.legendFormat,null==t?void 0:t.scopedVars),e),labels:e}}const{__name__:a}=e,n=function(e,t){if(null==e)return{};var a,n,s={},r=Object.keys(e);for(n=0;n<r.length;n++)a=r[n],t.indexOf(a)>=0||(s[a]=e[a]);return s}(e,Ea),r=(0,s.formatLabels)(n);let i=`${null!=a?a:""}${r}`;i||(i=t.query);return{name:i,labels:n}}(e.metric,t),r=[];if(S(e)){const s=t.step?1e3*t.step:NaN;let i=1e3*t.start;const l=[];for(const t of e.values){let e=Qa(t[1]);isNaN(e)&&(e=null);const a=1e3*t[0];for(let e=i;e<a;e+=s)l.push([e,null]);i=a+s,l.push([a,e])}const o=1e3*t.end;for(let e=i;e<=o;e+=s)l.push([e,null]);r.push(Na(l,!0)),r.push(Aa({data:l,parseValue:!1,labels:n,displayNameFromDS:a}))}else r.push(Na([e.value])),r.push(Aa({data:[e.value],labels:n,displayNameFromDS:a}));return{meta:t.meta,refId:t.refId,length:r[0].values.length,fields:r,name:a}}(e,a)))),"heatmap"===a.format?ka(Pa(o.sort(La))):o}function Oa(e){const t=[];if(e.datasourceUid){var a;const n=(0,u.getDataSourceSrv)().getInstanceSettings(e.datasourceUid);t.push({title:e.urlDisplayLabel||`Query with ${null==n?void 0:n.name}`,url:"",internal:{query:{query:"${__value.raw}",queryType:"traceId"},datasourceUid:e.datasourceUid,datasourceName:null!==(a=null==n?void 0:n.name)&&void 0!==a?a:"Data source not found"}})}return e.url&&t.push({title:e.urlDisplayLabel||`Go to ${e.url}`,url:e.url,targetBlank:!0}),t}function Fa(e,t){return e.hasOwnProperty(t)?"le"===t?Qa(e[t]):e[t]:""}function Na(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return{name:s.TIME_SERIES_TIME_FIELD_NAME,type:s.FieldType.time,config:{},values:new s.ArrayVector(e.map((e=>t?e[0]:1e3*e[0])))}}function Aa(e){let{data:t,valueName:a=s.TIME_SERIES_VALUE_FIELD_NAME,parseValue:n=!0,labels:r,displayNameFromDS:i}=e;return{name:a,type:s.FieldType.number,display:(0,s.getDisplayProcessor)(),config:{displayNameFromDS:i},labels:r,values:new s.ArrayVector(t.map((e=>n?Qa(e[1]):e[1])))}}function ka(e){if(0===e.length)return[];const t=e[0].fields.find((e=>e.type===s.FieldType.time)),a=e.map((e=>{let t=e.fields.find((e=>e.type===s.FieldType.number));return Object.assign({},t,{name:t.config.displayNameFromDS})}));return[Object.assign({},e[0],{meta:Object.assign({},e[0].meta,{type:s.DataFrameType.HeatmapBuckets}),fields:[t,...a]})]}function Pa(e){for(let t=e.length-1;t>0;t--){const a=e[t].fields.find((e=>e.name===s.TIME_SERIES_VALUE_FIELD_NAME)),n=e[t-1].fields.find((e=>e.name===s.TIME_SERIES_VALUE_FIELD_NAME));if(!a||!n)throw new Error("Prometheus heatmap transform error: data should be a time series");for(let e=0;e<a.values.length;e++){const t=n.values.get(e)||[0];a.values.toArray()[e]-=t}}return e}function La(e,t){let a,n;try{var s,r;a=Qa(null!==(s=e.name)&&void 0!==s?s:""),n=Qa(null!==(r=t.name)&&void 0!==r?r:"")}catch(e){return console.error(e),0}return a>n?1:a<n?-1:0}function Qa(e){return Da.test(e)?"-"===e[0]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY:parseFloat(e)}var Va,Ma,$a,Ua,Xa,Ba=a(80890);class za extends s.StandardVariableSupport{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(0,u.getTemplateSrv)(),a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(0,ya.$t)();super(),this.datasource=e,this.templateSrv=t,this.timeSrv=a,this.query=this.query.bind(this)}query(e){const t=e.targets[0].expr;if(!t)return(0,ca.of)({data:[]});const a=Object.assign({},e.scopedVars,{__interval:{text:this.datasource.interval,value:this.datasource.interval},__interval_ms:{text:s.rangeUtil.intervalToMs(this.datasource.interval),value:s.rangeUtil.intervalToMs(this.datasource.interval)}},this.datasource.getRangeScopedVars(this.timeSrv.timeRange())),n=this.templateSrv.replace(t,a,this.datasource.interpolateQueryExpr),r=new wa(this.datasource,n);return(0,Ba.D)(r.process()).pipe((0,pa.U)((e=>({data:e}))))}toDataQuery(e){return{refId:"PrometheusDatasource-VariableQuery",expr:e.query}}}function Wa(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const Ka=["api/v1/query","api/v1/query_range","api/v1/series","api/v1/labels"];class Ga extends u.DataSourceWithBackend{constructor(e){var t,a;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(0,ja.J)(),r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(0,ya.$t)(),i=arguments.length>3?arguments[3]:void 0;super(e),Wa(this,"type",void 0),Wa(this,"editorSrc",void 0),Wa(this,"ruleMappings",void 0),Wa(this,"url",void 0),Wa(this,"id",void 0),Wa(this,"directUrl",void 0),Wa(this,"access",void 0),Wa(this,"basicAuth",void 0),Wa(this,"withCredentials",void 0),Wa(this,"metricsNameCache",new(la())({max:10})),Wa(this,"interval",void 0),Wa(this,"queryTimeout",void 0),Wa(this,"httpMethod",void 0),Wa(this,"languageProvider",void 0),Wa(this,"exemplarTraceIdDestinations",void 0),Wa(this,"lookupsDisabled",void 0),Wa(this,"customQueryParameters",void 0),Wa(this,"exemplarsAvailable",void 0),Wa(this,"subType",void 0),Wa(this,"rulerEnabled",void 0),Wa(this,"init",(async()=>{this.loadRules(),this.exemplarsAvailable=await this.areExemplarsAvailable()})),Wa(this,"prepareTargets",((e,t,a)=>{const n=[],r=[],i=(0,re.cloneDeep)(e.targets);for(const l of i){if(!l.expr||l.hide)continue;l.requestId=e.panelId+l.refId;const i=this.languageProvider.histogramMetrics.find((e=>l.expr.includes(e)));if(e.app===s.CoreApp.Explore&&l.range===l.instant){const s=(0,re.cloneDeep)(l);s.format="table",s.instant=!0,s.range=!1,s.valueWithRefId=!0,delete s.maxDataPoints,s.requestId+="_instant";const o=(0,re.cloneDeep)(l);if(o.format="time_series",o.instant=!1,s.range=!0,l.exemplar){if(!i||i&&!r.some((e=>e.expr.includes(i)))){const s=(0,re.cloneDeep)(l);s.instant=!1,s.requestId+="_exemplar",n.push(this.createQuery(s,e,t,a)),r.push(s)}s.exemplar=!1,o.exemplar=!1}r.push(s,o),n.push(this.createQuery(s,e,t,a),this.createQuery(o,e,t,a))}else if(l.instant&&e.app===s.CoreApp.Explore){const s=(0,re.cloneDeep)(l);s.format="table",n.push(this.createQuery(s,e,t,a)),r.push(s)}else{if(l.exemplar&&!l.instant){if(!i||i&&!r.some((e=>e.expr.includes(i)))){const s=(0,re.cloneDeep)(l);s.requestId+="_exemplar",n.push(this.createQuery(s,e,t,a)),r.push(s)}l.exemplar=!1}n.push(this.createQuery(l,e,t,a)),r.push(l)}}return{queries:n,activeTargets:r}})),Wa(this,"handleErrors",((e,t)=>{const a={message:e&&e.statusText||"Unknown error during query transaction. Please check JS console logs.",refId:t.refId};return e.data?"string"==typeof e.data?a.message=e.data:e.data.error&&(a.message=(0,ba.Xh)(e.data.error)):e.message?a.message=e.message:"string"==typeof e&&(a.message=e),a.status=e.status,a.statusText=e.statusText,a})),Wa(this,"processAnnotationResponse",((e,t)=>{const a=(0,u.toDataQueryResponse)({data:t}).data;if(!a||!a.length)return[];const n=e.annotation,{tagKeys:r="",titleFormat:i="",textFormat:l=""}=n,o=1e3*s.rangeUtil.intervalToSeconds(n.step||"60s"),c=r.split(","),d=[];for(const t of a){const a=t.fields[0],s=t.fields[1],r=(null==s?void 0:s.labels)||{},u=Object.keys(r).filter((e=>c.includes(e))).map((e=>r[e])),m=[];let p=0;s.values.toArray().forEach((t=>{let n,s;const r=a.values.get(p);e.annotation.useValueForTime?(n=Math.floor(parseFloat(t)),s=1):(n=Math.floor(parseFloat(r)),s=parseFloat(t)),p++,m.push([n,s])}));const g=m.filter((e=>e[1]>=1)).map((e=>e[0]));let v=null;for(const e of g){var h;v&&(null!==(h=v.timeEnd)&&void 0!==h?h:0)+o>=e?v.timeEnd=e:(v&&d.push(v),v={time:e,timeEnd:e,annotation:n,title:(0,Ca.W)(i,r),tags:u,text:(0,Ca.W)(l,r)})}v&&(v.timeEnd=g[g.length-1],d.push(v))}return d})),this.templateSrv=n,this.timeSrv=r,this.type="prometheus",this.subType=Ta.T8.Prometheus,this.rulerEnabled=!1,this.editorSrc="app/features/prometheus/partials/query.editor.html",this.id=e.id,this.url=e.url,this.access=e.access,this.basicAuth=e.basicAuth,this.withCredentials=e.withCredentials,this.interval=e.jsonData.timeInterval||"15s",this.queryTimeout=e.jsonData.queryTimeout,this.httpMethod=e.jsonData.httpMethod||"GET",this.directUrl=null!==(t=e.jsonData.directUrl)&&void 0!==t?t:this.url,this.exemplarTraceIdDestinations=e.jsonData.exemplarTraceIdDestinations,this.ruleMappings={},this.languageProvider=null!=i?i:new R.ZP(this),this.lookupsDisabled=null!==(a=e.jsonData.disableMetricsLookup)&&void 0!==a&&a,this.customQueryParameters=new URLSearchParams(e.jsonData.customQueryParameters),this.variables=new za(this,this.templateSrv,this.timeSrv),this.exemplarsAvailable=!0,this.annotations={QueryEditor:Sa}}getQueryDisplayText(e){return e.expr}_addTracingHeaders(e,t){e.headers={};!this.url.match(/^http/)&&(e.headers["X-Dashboard-Id"]=t.dashboardId,e.headers["X-Panel-Id"]=t.panelId)}_request(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t=t||{};for(const[e,a]of this.customQueryParameters)null==t[e]&&(t[e]=a);let n=this.url+e;e.startsWith(`/api/datasources/${this.id}`)&&(n=e);const s=(0,re.defaults)(a,{url:n,method:this.httpMethod,headers:{}});return"GET"===s.method?t&&Object.keys(t).length&&(s.url=s.url+(s.url.search(/\?/)>=0?"&":"?")+Object.entries(t).map((e=>{let[t,a]=e;return`${encodeURIComponent(t)}=${encodeURIComponent(a)}`})).join("&")):(s.headers["Content-Type"]="application/x-www-form-urlencoded",s.data=t),(this.basicAuth||this.withCredentials)&&(s.withCredentials=!0),this.basicAuth&&(s.headers.Authorization=this.basicAuth),(0,u.getBackendSrv)().fetch(s)}async importFromAbstractQueries(e){return e.map((e=>this.languageProvider.importFromAbstractQuery(e)))}async exportToAbstractQueries(e){return e.map((e=>this.languageProvider.exportToAbstractQuery(e)))}async metadataRequest(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Ka.some((t=>e.includes(t))))try{return await(0,oa.n)(this._request(`/api/datasources/${this.id}/resources${e}`,t,{method:this.httpMethod,hideFromInspector:!0,showErrorAlert:!1}))}catch(e){if("POST"!==this.httpMethod||405!==e.status&&400!==e.status)throw e;console.warn("Couldn't use configured POST HTTP method for this request. Trying to use GET method instead.")}return await(0,oa.n)(this._request(`/api/datasources/${this.id}/resources${e}`,t,{method:"GET",hideFromInspector:!0}))}interpolateQueryExpr(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;if(!t.multi&&!t.includeAll)return Ja(e);if("string"==typeof e)return Ha(e);const a=e.map((e=>Ha(e)));return 1===a.length?a[0]:"("+a.join("|")+")"}targetContainsTemplate(e){return this.templateSrv.containsTemplate(e.expr)}shouldRunExemplarQuery(e,t){if(e.exemplar){const a=this.languageProvider.histogramMetrics.find((t=>e.expr.includes(t))),n=t.targets.findIndex((t=>t.refId===e.refId)),s=t.targets.slice(0,n).filter((e=>!e.hide));return!(a&&(!a||s.some((e=>e.expr.includes(a)))))}return!1}processTargetV2(e,t){return Object.assign({},e,{queryType:T.timeSeriesQuery,exemplar:this.shouldRunExemplarQuery(e,t),requestId:t.panelId+e.refId,utcOffsetSec:60*this.timeSrv.timeRange().to.utcOffset()})}query(e){if("proxy"===this.access){const t=e.targets.map((t=>this.processTargetV2(t,e)));return super.query(Object.assign({},e,{targets:t})).pipe((0,pa.U)((t=>qa(t,e,{exemplarTraceIdDestinations:this.exemplarTraceIdDestinations}))))}{const t=this.getPrometheusTime(e.range.from,!1),a=this.getPrometheusTime(e.range.to,!0),{queries:n,activeTargets:r}=this.prepareTargets(e,t,a);return n&&n.length?e.app===s.CoreApp.Explore?this.exploreQuery(n,r,a):this.panelsQuery(n,r,a,e.requestId,e.scopedVars):(0,ca.of)({data:[],state:s.LoadingState.Done})}}exploreQuery(e,t,a){let n=e.length;const r=e.map(((r,i)=>{const l=t[i],o=(0,ua.z)((0,ga.b)((()=>n--)),(0,va.h)((e=>!e.cancelled)),(0,pa.U)((t=>({data:Ra(t,{query:r,target:l,responseListLength:e.length,exemplarTraceIdDestinations:this.exemplarTraceIdDestinations}),key:r.requestId,state:0===n?s.LoadingState.Done:s.LoadingState.Loading}))));return this.runQuery(r,a,o)}));return(0,da.T)(...r)}panelsQuery(e,t,a,n,r){const i=e.map(((n,s)=>{const i=t[s],l=(0,ua.z)((0,va.h)((e=>!e.cancelled)),(0,pa.U)((t=>Ra(t,{query:n,target:i,responseListLength:e.length,scopedVars:r,exemplarTraceIdDestinations:this.exemplarTraceIdDestinations}))));return this.runQuery(n,a,l)}));return(0,ha.D)(i).pipe((0,pa.U)((e=>({data:e.reduce(((e,t)=>[...e,...t]),[]),key:n,state:s.LoadingState.Done}))))}runQuery(e,t,a){return e.instant?this.performInstantQuery(e,t).pipe(a):e.exemplar?this.getExemplars(e).pipe((0,fa.K)((()=>(0,ca.of)({data:[],state:s.LoadingState.Done}))),a):this.performTimeSeriesQuery(e,e.start,e.end).pipe(a)}createQuery(e,t,a,n){const r={hinting:e.hinting,instant:e.instant,exemplar:e.exemplar,step:0,expr:"",requestId:e.requestId,refId:e.refId,start:0,end:0},i=Math.ceil(n-a);let l=s.rangeUtil.intervalToSeconds(t.interval);const o=s.rangeUtil.intervalToSeconds(this.templateSrv.replace(e.interval||t.interval,t.scopedVars)),c=e.interval?s.rangeUtil.intervalToSeconds(this.templateSrv.replace(e.interval,t.scopedVars)):s.rangeUtil.intervalToSeconds(this.interval),u=e.intervalFactor||1,d=this.adjustInterval(l,o,i,u);let h=Object.assign({},t.scopedVars,this.getRangeScopedVars(t.range),this.getRateIntervalScopedVariable(d,c));l!==d&&(l=d,h=Object.assign({},t.scopedVars,Object.assign({__interval:{text:l+"s",value:l+"s"},__interval_ms:{text:1e3*l,value:1e3*l}},this.getRateIntervalScopedVariable(l,c),this.getRangeScopedVars(t.range)))),r.step=l;let m=e.expr;m=this.enhanceExprWithAdHocFilters(m),r.expr=this.templateSrv.replace(m,h,this.interpolateQueryExpr);const p=function(e,t,a,n){const s=Math.floor((t+n)/a)*a-n,r=Math.floor((e+n)/a)*a-n;return{end:s,start:r}}(a,n,r.step,60*this.timeSrv.timeRange().to.utcOffset());return r.start=p.start,r.end=p.end,this._addTracingHeaders(r,t),r}getRateIntervalScopedVariable(e,t){0===t&&(t=15);const a=Math.max(e+t,4*t);return{__rate_interval:{text:a+"s",value:a+"s"}}}adjustInterval(e,t,a,n){let s=a/11e3;return s>1&&(s=Math.ceil(s)),Math.max(e*n,t,s)}performTimeSeriesQuery(e,t,a){if(t>a)throw{message:"Invalid time range"};const n={query:e.expr,start:t,end:a,step:e.step};return this.queryTimeout&&(n.timeout=this.queryTimeout),this._request("/api/v1/query_range",n,{requestId:e.requestId,headers:e.headers}).pipe((0,fa.K)((t=>t.cancelled?(0,ca.of)(t):(0,ma._)(this.handleErrors(t,e)))))}performInstantQuery(e,t){const a={query:e.expr,time:t};return this.queryTimeout&&(a.timeout=this.queryTimeout),this._request("/api/v1/query",a,{requestId:e.requestId,headers:e.headers}).pipe((0,fa.K)((t=>t.cancelled?(0,ca.of)(t):(0,ma._)(this.handleErrors(t,e)))))}metricFindQuery(e){if(!e)return Promise.resolve([]);const t=Object.assign({__interval:{text:this.interval,value:this.interval},__interval_ms:{text:s.rangeUtil.intervalToMs(this.interval),value:s.rangeUtil.intervalToMs(this.interval)}},this.getRangeScopedVars(this.timeSrv.timeRange())),a=this.templateSrv.replace(e,t,this.interpolateQueryExpr);return new wa(this,a).process()}getRangeScopedVars(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.timeSrv.timeRange();const t=e.to.diff(e.from),a=Math.round(t/1e3);return{__range_ms:{text:t,value:t},__range_s:{text:a,value:a},__range:{text:a+"s",value:a+"s"}}}async annotationQuery(e){const t=e.annotation,{expr:a=""}=t;if(!a)return Promise.resolve([]);const n={expr:a,range:!0,instant:!1,exemplar:!1,interval:e.annotation.step||"60s",queryType:T.timeSeriesQuery,refId:"X",datasource:this.getRef()};return await(0,oa.n)((0,u.getBackendSrv)().fetch({url:"/api/ds/query",method:"POST",data:{from:(1e3*this.getPrometheusTime(e.range.from,!1)).toString(),to:(1e3*this.getPrometheusTime(e.range.to,!0)).toString(),queries:[this.applyTemplateVariables(n,{})]},requestId:`prom-query-${t.name}`}).pipe((0,pa.U)((t=>this.processAnnotationResponse(e,t.data)))))}getExemplars(e){return this._request("/api/v1/query_exemplars",{query:e.expr,start:e.start.toString(),end:e.end.toString()},{requestId:e.requestId,headers:e.headers})}async getSubtitle(){const e=await this.getBuildInfo();return e?this.getBuildInfoMessage(e):null}async getTagKeys(e){if(null!=e&&e.series){const t=await Promise.all(e.series.map((e=>this.languageProvider.fetchSeriesLabels(e))));return[...new Set(...t.map((e=>Object.keys(e))))].map((e=>({text:e})))}{var t,a,n;const e=await this.metadataRequest("/api/v1/labels");return null!==(t=null==e||null===(a=e.data)||void 0===a||null===(n=a.data)||void 0===n?void 0:n.map((e=>({text:e}))))&&void 0!==t?t:[]}}async getTagValues(){var e,t,a;let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const s=await this.metadataRequest(`/api/v1/label/${n.key}/values`);return null!==(e=null==s||null===(t=s.data)||void 0===t||null===(a=t.data)||void 0===a?void 0:a.map((e=>({text:e}))))&&void 0!==e?e:[]}async getBuildInfo(){try{return await(0,xa.W)({url:this.url,name:this.name,type:"prometheus"})}catch(e){return}}getBuildInfoMessage(e){var t,a;const n=Va||(Va=(0,i.jsx)(h.Badge,{color:"green",icon:"check",text:"Ruler API enabled"})),s=Ma||(Ma=(0,i.jsx)(h.Badge,{color:"orange",icon:"exclamation-triangle",text:"Ruler API not enabled"})),r=$a||($a=(0,i.jsx)(h.Tooltip,{placement:"top",content:"Prometheus does not allow editing rules, connect to either a Mimir or Cortex datasource to manage alerts via Grafana.",children:(0,i.jsx)("div",{children:(0,i.jsx)(h.Badge,{color:"red",icon:"exclamation-triangle",text:"Ruler API not supported"})})})),l={[Ta.T8.Lotex]:"/public/app/plugins/datasource/prometheus/img/cortex_logo.svg",[Ta.T8.Mimir]:"/public/app/plugins/datasource/prometheus/img/mimir_logo.svg",[Ta.T8.Prometheus]:"/public/app/plugins/datasource/prometheus/img/prometheus_logo.svg"},o={[Ta.T8.Lotex]:"blue",[Ta.T8.Mimir]:"orange",[Ta.T8.Prometheus]:"red"},c={[Ta.T8.Lotex]:"Cortex",[Ta.T8.Mimir]:"Mimir",[Ta.T8.Prometheus]:"Prometheus"},u=(0,i.jsx)(h.Badge,{text:(0,i.jsxs)("span",{children:[(0,i.jsx)("img",{style:{width:14,height:14,verticalAlign:"text-bottom"},src:l[null!==(t=e.application)&&void 0!==t?t:Ta.T8.Prometheus]})," ",e.application?c[e.application]:"Unknown"]}),color:o[null!==(a=e.application)&&void 0!==a?a:Ta.T8.Prometheus]});return(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"max-content max-content",rowGap:"0.5rem",columnGap:"2rem",marginTop:"1rem"},children:[Ua||(Ua=(0,i.jsx)("div",{children:"Type"})),(0,i.jsx)("div",{children:u}),(0,i.jsxs)(i.Fragment,{children:[Xa||(Xa=(0,i.jsx)("div",{children:"Ruler API"})),e.application===Ta.T8.Prometheus&&(0,i.jsx)("div",{children:r}),e.application!==Ta.T8.Prometheus&&(0,i.jsx)("div",{children:e.features.rulerApiEnabled?n:s})]})]})}async testDatasource(){const e=(new Date).getTime(),t={targets:[{refId:"test",expr:"1+1",instant:!0}],requestId:`${this.id}-health`,scopedVars:{},dashboardId:0,panelId:0,interval:"1m",intervalMs:6e4,maxDataPoints:1,range:{from:(0,s.dateTime)(e-1e3),to:(0,s.dateTime)(e)}},a=await this.getBuildInfo();return(0,oa.n)(this.query(t)).then((e=>{return e&&e.data&&e.state===s.LoadingState.Done?{status:"success",message:"Data source is working",details:a&&{verboseMessage:this.getBuildInfoMessage(a)}}:{status:"error",message:`Error reading Prometheus: ${null==e||null===(t=e.error)||void 0===t?void 0:t.message}`};var t})).catch((e=>(console.error("Prometheus Error",e),{status:"error",message:e.message})))}interpolateVariablesInQueries(e,t){let a=e;return e&&e.length&&(a=e.map((e=>Object.assign({},e,{datasource:this.getRef(),expr:this.templateSrv.replace(e.expr,t,this.interpolateQueryExpr),interval:this.templateSrv.replace(e.interval,t)})))),a}getQueryHints(e,t){var a;return function(e,t,a){const n=[];if(e.trim().match(/^\w+_bucket$|^\w+_bucket{.*}$/)){const t="Selected metric has buckets.";n.push({type:"HISTOGRAM_QUANTILE",label:t,fix:{label:"Consider calculating aggregated quantile by adding histogram_quantile().",action:{type:"ADD_HISTOGRAM_QUANTILE",query:e}}})}if(-1===e.indexOf("rate(")&&-1===e.indexOf("increase(")){var s,r;const t=e.match(/\b(\w+_(total|sum|count))\b/);let l=t?t[1]:"";const o=null!==(s=null==a||null===(r=a.languageProvider)||void 0===r?void 0:r.metricsMetadata)&&void 0!==s?s:{},c=Object.keys(o);let u=!1;var i;if(c.length>0&&(l=null!==(i=c.find((t=>{if("counter"===o[t].type.toLowerCase()){const a=new RegExp(`\\b${t}\\b`);if(e.match(a))return u=!0,!0}return!1})))&&void 0!==i?i:""),l){const t=e.trim().match(/^\w+$|^\w+{.*}$/);let a,s=`Selected metric ${u?"is":"looks like"} a counter.`;t?a={label:"Consider calculating rate of counter by adding rate().",action:{type:"ADD_RATE",query:e}}:s=`${s} Consider calculating rate of counter by adding rate().`,n.push({type:"APPLY_RATE",label:s,fix:a})}}if(a&&a.ruleMappings){const t=a.ruleMappings,s=Object.keys(t).reduce(((a,n)=>e.search(n)>-1?Object.assign({},a,{[n]:t[n]}):a),{});if((0,re.size)(s)>0){const t="Query contains recording rules.";n.push({type:"EXPAND_RULES",label:t,fix:{label:"Expand rules",action:{type:"EXPAND_RULES",query:e,mapping:s}}})}}t&&t.length>=20&&e.trim().match(/^\w+$/)&&n.push({type:"ADD_SUM",label:"Many time series results returned.",fix:{label:"Consider aggregating with sum().",action:{type:"ADD_SUM",query:e,preventSubmit:!0}}});return n}(null!==(a=e.expr)&&void 0!==a?a:"",t,this)}getInitHints(){return function(e){const t=[];return e.directUrl.includes("/loki")&&!e.languageProvider.metrics.length&&t.push({label:"Using Loki as a Prometheus data source is no longer supported. You must use the Loki data source for your Loki instance.",type:"INFO"}),e.lookupsDisabled&&t.push({label:"Labels and metrics lookup was disabled in data source settings.",type:"INFO"}),t}(this)}async loadRules(){try{var e,t;const a=null===(e=(await this.metadataRequest("/api/v1/rules")).data)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.groups;a&&(this.ruleMappings=function(e){return e.reduce(((e,t)=>t.rules.filter((e=>"recording"===e.type)).reduce(((e,t)=>Object.assign({},e,{[t.name]:t.query})),e)),{})}(a))}catch(e){console.log("Rules API is experimental. Ignore next error."),console.error(e)}}async areExemplarsAvailable(){try{return"success"===(await this.getResource("/api/v1/query_exemplars",{query:"test",start:(0,s.dateTime)().subtract(30,"minutes").valueOf(),end:(0,s.dateTime)().valueOf()})).data.status}catch(e){return!1}}modifyQuery(e,t){var a;let n=null!==(a=e.expr)&&void 0!==a?a:"";switch(t.type){case"ADD_FILTER":n=(0,_a.F)(n,t.key,t.value);break;case"ADD_FILTER_OUT":n=(0,_a.F)(n,t.key,t.value,"!=");break;case"ADD_HISTOGRAM_QUANTILE":n=`histogram_quantile(0.95, sum(rate(${n}[$__rate_interval])) by (le))`;break;case"ADD_RATE":n=`rate(${n}[$__rate_interval])`;break;case"ADD_SUM":n=`sum(${n.trim()}) by ($1)`;break;case"EXPAND_RULES":t.mapping&&(n=(0,Ce.ll)(n,t.mapping))}return Object.assign({},e,{expr:n})}getPrometheusTime(e,t){return"string"==typeof e&&(e=s.dateMath.parse(e,t)),Math.ceil(e.valueOf()/1e3)}getTimeRangeParams(){const e=this.timeSrv.timeRange();return{start:this.getPrometheusTime(e.from,!1).toString(),end:this.getPrometheusTime(e.to,!0).toString()}}getOriginalMetricName(e){return function(e){const t=e.__name__||"";return delete e.__name__,`${t}{${Object.entries(e).map((e=>`${e[0]}="${e[1]}"`)).join(",")}}`}(e)}enhanceExprWithAdHocFilters(e){const t=this.templateSrv.getAdhocFilters(this.name).reduce(((e,t)=>{const{key:a,operator:n}=t;let{value:s}=t;return"=~"!==n&&"!~"!==n||(s=Ja(s)),(0,_a.F)(e,a,s,n)}),e);return t}filterQuery(e){return!(e.hide||!e.expr)}applyTemplateVariables(e,t){const a=(0,re.cloneDeep)(t);delete a.__interval,delete a.__interval_ms;const n=this.enhanceExprWithAdHocFilters(e.expr);return Object.assign({},e,{legendFormat:this.templateSrv.replace(e.legendFormat,a),expr:this.templateSrv.replace(n,a,this.interpolateQueryExpr),interval:this.templateSrv.replace(e.interval,a)})}getVariables(){return this.templateSrv.getVariables().map((e=>`$${e.name}`))}interpolateString(e){return this.templateSrv.replace(e,void 0,this.interpolateQueryExpr)}}function Ja(e){return"string"==typeof e?e.replace(/\\/g,"\\\\").replace(/'/g,"\\\\'"):e}function Ha(e){return"string"==typeof e?e.replace(/\\/g,"\\\\\\\\").replace(/[$^*{}\[\]\'+?.()|]/g,"\\\\$&"):e}const Za=new s.DataSourcePlugin(Ga).setQueryEditor(ft).setConfigEditor((e=>{const{options:t,onOptionsChange:a}=e,n=(0,yt.Tc)(),s={azureAuthSupported:!!xt.vc.featureToggles.prometheus_azure_auth,getAzureAuthEnabled:e=>function(e){return!!e.jsonData.azureCredentials}(e),setAzureAuthEnabled:(e,t)=>t?function(e){return{jsonData:Object.assign({},e.jsonData,{azureCredentials:wt()})}}(e):function(e){return{jsonData:Object.assign({},e.jsonData,{azureAuth:void 0,azureCredentials:void 0,azureEndpointResourceId:void 0})}}(e),azureSettingsUI:Mt};return(0,i.jsxs)(i.Fragment,{children:["direct"===t.access&&(aa||(aa=(0,i.jsx)(h.Alert,{title:"Deprecation Notice",severity:"warning",children:"Browser access mode in the Prometheus datasource is deprecated and will be removed in a future release."}))),(0,i.jsx)(h.DataSourceHttpSettings,{defaultUrl:"http://localhost:9090",dataSourceConfig:t,showAccessOptions:!0,onChange:a,sigV4AuthToggleEnabled:xt.vc.sigV4AuthEnabled,azureAuthSettings:s,renderSigV4Editor:(0,i.jsx)(bt.SIGV4ConnectionConfig,Object.assign({},e))}),(0,i.jsx)(h.AlertingSettings,{alertmanagerDataSources:n,options:t,onOptionsChange:a}),(0,i.jsx)(Zt,{options:t,onOptionsChange:a})]})})).setQueryEditorHelp(o)},53454:(e,t,a)=>{"use strict";a.d(t,{Os:()=>r,Ty:()=>n,YO:()=>l,ZP:()=>o,fP:()=>s,r8:()=>i});const n=[{label:"$__interval",sortValue:"$__interval"},{label:"$__rate_interval",sortValue:"$__rate_interval"},{label:"$__range",sortValue:"$__range"},{label:"1m",sortValue:"00:01:00"},{label:"5m",sortValue:"00:05:00"},{label:"10m",sortValue:"00:10:00"},{label:"30m",sortValue:"00:30:00"},{label:"1h",sortValue:"01:00:00"},{label:"1d",sortValue:"24:00:00"}],s=["by","group_left","group_right","ignoring","on","offset","without"],r=["or","and","unless"],i=[{label:"sum",insertText:"sum",documentation:"Calculate sum over dimensions"},{label:"min",insertText:"min",documentation:"Select minimum over dimensions"},{label:"max",insertText:"max",documentation:"Select maximum over dimensions"},{label:"avg",insertText:"avg",documentation:"Calculate the average over dimensions"},{label:"group",insertText:"group",documentation:"All values in the resulting vector are 1"},{label:"stddev",insertText:"stddev",documentation:"Calculate population standard deviation over dimensions"},{label:"stdvar",insertText:"stdvar",documentation:"Calculate population standard variance over dimensions"},{label:"count",insertText:"count",documentation:"Count number of elements in the vector"},{label:"count_values",insertText:"count_values",documentation:"Count number of elements with the same value"},{label:"bottomk",insertText:"bottomk",documentation:"Smallest k elements by sample value"},{label:"topk",insertText:"topk",documentation:"Largest k elements by sample value"},{label:"quantile",insertText:"quantile",documentation:"Calculate φ-quantile (0 ≤ φ ≤ 1) over dimensions"},{label:"acos",insertText:"acos",detail:"acos(v instant-vector)",documentation:"calculates the arccosine of all elements in v"},{label:"acosh",insertText:"acosh",detail:"acosh(v instant-vector)",documentation:"calculates the inverse hyperbolic cosine of all elements in v"},{label:"asin",insertText:"asin",detail:"asin(v instant-vector)",documentation:"calculates the arcsine of all elements in v"},{label:"asinh",insertText:"asinh",detail:"asinh(v instant-vector)",documentation:"calculates the inverse hyperbolic sine of all elements in v"},{label:"atan",insertText:"atan",detail:"atan(v instant-vector)",documentation:"calculates the arctangent of all elements in v"},{label:"atanh",insertText:"atanh",detail:"atanh(v instant-vector)",documentation:"calculates the inverse hyperbolic tangent of all elements in v"},{label:"cos",insertText:"cos",detail:"cos(v instant-vector)",documentation:"calculates the cosine of all elements in v"},{label:"cosh",insertText:"cosh",detail:"cosh(v instant-vector)",documentation:"calculates the hyperbolic cosine of all elements in v"},{label:"sin",insertText:"sin",detail:"sin(v instant-vector)",documentation:"calculates the sine of all elements in v"},{label:"sinh",insertText:"sinh",detail:"sinh(v instant-vector)",documentation:"calculates the hyperbolic sine of all elements in v"},{label:"tan",insertText:"tan",detail:"tan(v instant-vector)",documentation:"calculates the tangent of all elements in v"},{label:"tanh",insertText:"tanh",detail:"tanh(v instant-vector)",documentation:"calculates the hyperbolic tangent of all elements in v"},{insertText:"abs",label:"abs",detail:"abs(v instant-vector)",documentation:"Returns the input vector with all sample values converted to their absolute value."},{insertText:"absent",label:"absent",detail:"absent(v instant-vector)",documentation:"Returns an empty vector if the vector passed to it has any elements and a 1-element vector with the value 1 if the vector passed to it has no elements. This is useful for alerting on when no time series exist for a given metric name and label combination."},{insertText:"absent_over_time",label:"absent_over_time",detail:"absent(v range-vector)",documentation:"Returns an empty vector if the range vector passed to it has any elements and a 1-element vector with the value 1 if the range vector passed to it has no elements."},{insertText:"ceil",label:"ceil",detail:"ceil(v instant-vector)",documentation:"Rounds the sample values of all elements in `v` up to the nearest integer."},{insertText:"changes",label:"changes",detail:"changes(v range-vector)",documentation:"For each input time series, `changes(v range-vector)` returns the number of times its value has changed within the provided time range as an instant vector."},{insertText:"clamp",label:"clamp",detail:"clamp(v instant-vector, min scalar, max scalar)",documentation:"Clamps the sample values of all elements in `v` to have a lower limit of `min` and an upper limit of `max`."},{insertText:"clamp_max",label:"clamp_max",detail:"clamp_max(v instant-vector, max scalar)",documentation:"Clamps the sample values of all elements in `v` to have an upper limit of `max`."},{insertText:"clamp_min",label:"clamp_min",detail:"clamp_min(v instant-vector, min scalar)",documentation:"Clamps the sample values of all elements in `v` to have a lower limit of `min`."},{insertText:"count_scalar",label:"count_scalar",detail:"count_scalar(v instant-vector)",documentation:"Returns the number of elements in a time series vector as a scalar. This is in contrast to the `count()` aggregation operator, which always returns a vector (an empty one if the input vector is empty) and allows grouping by labels via a `by` clause."},{insertText:"deg",label:"deg",detail:"deg(v instant-vector)",documentation:"Converts radians to degrees for all elements in v"},{insertText:"day_of_month",label:"day_of_month",detail:"day_of_month(v=vector(time()) instant-vector)",documentation:"Returns the day of the month for each of the given times in UTC. Returned values are from 1 to 31."},{insertText:"day_of_week",label:"day_of_week",detail:"day_of_week(v=vector(time()) instant-vector)",documentation:"Returns the day of the week for each of the given times in UTC. Returned values are from 0 to 6, where 0 means Sunday etc."},{insertText:"days_in_month",label:"days_in_month",detail:"days_in_month(v=vector(time()) instant-vector)",documentation:"Returns number of days in the month for each of the given times in UTC. Returned values are from 28 to 31."},{insertText:"delta",label:"delta",detail:"delta(v range-vector)",documentation:"Calculates the difference between the first and last value of each time series element in a range vector `v`, returning an instant vector with the given deltas and equivalent labels. The delta is extrapolated to cover the full time range as specified in the range vector selector, so that it is possible to get a non-integer result even if the sample values are all integers."},{insertText:"deriv",label:"deriv",detail:"deriv(v range-vector)",documentation:"Calculates the per-second derivative of the time series in a range vector `v`, using simple linear regression."},{insertText:"drop_common_labels",label:"drop_common_labels",detail:"drop_common_labels(instant-vector)",documentation:"Drops all labels that have the same name and value across all series in the input vector."},{insertText:"exp",label:"exp",detail:"exp(v instant-vector)",documentation:"Calculates the exponential function for all elements in `v`.\nSpecial cases are:\n* `Exp(+Inf) = +Inf` \n* `Exp(NaN) = NaN`"},{insertText:"floor",label:"floor",detail:"floor(v instant-vector)",documentation:"Rounds the sample values of all elements in `v` down to the nearest integer."},{insertText:"histogram_quantile",label:"histogram_quantile",detail:"histogram_quantile(φ float, b instant-vector)",documentation:"Calculates the φ-quantile (0 ≤ φ ≤ 1) from the buckets `b` of a histogram. The samples in `b` are the counts of observations in each bucket. Each sample must have a label `le` where the label value denotes the inclusive upper bound of the bucket. (Samples without such a label are silently ignored.) The histogram metric type automatically provides time series with the `_bucket` suffix and the appropriate labels."},{insertText:"holt_winters",label:"holt_winters",detail:"holt_winters(v range-vector, sf scalar, tf scalar)",documentation:"Produces a smoothed value for time series based on the range in `v`. The lower the smoothing factor `sf`, the more importance is given to old data. The higher the trend factor `tf`, the more trends in the data is considered. Both `sf` and `tf` must be between 0 and 1."},{insertText:"hour",label:"hour",detail:"hour(v=vector(time()) instant-vector)",documentation:"Returns the hour of the day for each of the given times in UTC. Returned values are from 0 to 23."},{insertText:"idelta",label:"idelta",detail:"idelta(v range-vector)",documentation:"Calculates the difference between the last two samples in the range vector `v`, returning an instant vector with the given deltas and equivalent labels."},{insertText:"increase",label:"increase",detail:"increase(v range-vector)",documentation:"Calculates the increase in the time series in the range vector. Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for. The increase is extrapolated to cover the full time range as specified in the range vector selector, so that it is possible to get a non-integer result even if a counter increases only by integer increments."},{insertText:"irate",label:"irate",detail:"irate(v range-vector)",documentation:"Calculates the per-second instant rate of increase of the time series in the range vector. This is based on the last two data points. Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for."},{insertText:"label_join",label:"label_join",detail:"label_join(v instant-vector, dst_label string, separator string, src_label_1 string, src_label_2 string, ...)",documentation:"For each timeseries in `v`, joins all the values of all the `src_labels` using `separator` and returns the timeseries with the label `dst_label` containing the joined value. There can be any number of `src_labels` in this function."},{insertText:"label_replace",label:"label_replace",detail:"label_replace(v instant-vector, dst_label string, replacement string, src_label string, regex string)",documentation:"For each timeseries in `v`, `label_replace(v instant-vector, dst_label string, replacement string, src_label string, regex string)`  matches the regular expression `regex` against the label `src_label`.  If it matches, then the timeseries is returned with the label `dst_label` replaced by the expansion of `replacement`. `$1` is replaced with the first matching subgroup, `$2` with the second etc. If the regular expression doesn't match then the timeseries is returned unchanged."},{insertText:"ln",label:"ln",detail:"ln(v instant-vector)",documentation:"Calculates the natural logarithm for all elements in `v`.\nSpecial cases are:\n * `ln(+Inf) = +Inf`\n * `ln(0) = -Inf`\n * `ln(x < 0) = NaN`\n * `ln(NaN) = NaN`"},{insertText:"log2",label:"log2",detail:"log2(v instant-vector)",documentation:"Calculates the binary logarithm for all elements in `v`. The special cases are equivalent to those in `ln`."},{insertText:"log10",label:"log10",detail:"log10(v instant-vector)",documentation:"Calculates the decimal logarithm for all elements in `v`. The special cases are equivalent to those in `ln`."},{insertText:"minute",label:"minute",detail:"minute(v=vector(time()) instant-vector)",documentation:"Returns the minute of the hour for each of the given times in UTC. Returned values are from 0 to 59."},{insertText:"month",label:"month",detail:"month(v=vector(time()) instant-vector)",documentation:"Returns the month of the year for each of the given times in UTC. Returned values are from 1 to 12, where 1 means January etc."},{insertText:"pi",label:"pi",detail:"pi()",documentation:"Returns pi"},{insertText:"predict_linear",label:"predict_linear",detail:"predict_linear(v range-vector, t scalar)",documentation:"Predicts the value of time series `t` seconds from now, based on the range vector `v`, using simple linear regression."},{insertText:"rad",label:"rad",detail:"rad(v instant-vector)",documentation:"Converts degrees to radians for all elements in v"},{insertText:"rate",label:"rate",detail:"rate(v range-vector)",documentation:"Calculates the per-second average rate of increase of the time series in the range vector. Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for. Also, the calculation extrapolates to the ends of the time range, allowing for missed scrapes or imperfect alignment of scrape cycles with the range's time period."},{insertText:"resets",label:"resets",detail:"resets(v range-vector)",documentation:"For each input time series, `resets(v range-vector)` returns the number of counter resets within the provided time range as an instant vector. Any decrease in the value between two consecutive samples is interpreted as a counter reset."},{insertText:"round",label:"round",detail:"round(v instant-vector, to_nearest=1 scalar)",documentation:"Rounds the sample values of all elements in `v` to the nearest integer. Ties are resolved by rounding up. The optional `to_nearest` argument allows specifying the nearest multiple to which the sample values should be rounded. This multiple may also be a fraction."},{insertText:"scalar",label:"scalar",detail:"scalar(v instant-vector)",documentation:"Given a single-element input vector, `scalar(v instant-vector)` returns the sample value of that single element as a scalar. If the input vector does not have exactly one element, `scalar` will return `NaN`."},{insertText:"sgn",label:"sgn",detail:"sgn(v instant-vector)",documentation:"Returns a vector with all sample values converted to their sign, defined as this: 1 if v is positive, -1 if v is negative and 0 if v is equal to zero."},{insertText:"sort",label:"sort",detail:"sort(v instant-vector)",documentation:"Returns vector elements sorted by their sample values, in ascending order."},{insertText:"sort_desc",label:"sort_desc",detail:"sort_desc(v instant-vector)",documentation:"Returns vector elements sorted by their sample values, in descending order."},{insertText:"sqrt",label:"sqrt",detail:"sqrt(v instant-vector)",documentation:"Calculates the square root of all elements in `v`."},{insertText:"time",label:"time",detail:"time()",documentation:"Returns the number of seconds since January 1, 1970 UTC. Note that this does not actually return the current time, but the time at which the expression is to be evaluated."},{insertText:"timestamp",label:"timestamp",detail:"timestamp(v instant-vector)",documentation:"Returns the timestamp of each of the samples of the given vector as the number of seconds since January 1, 1970 UTC."},{insertText:"vector",label:"vector",detail:"vector(s scalar)",documentation:"Returns the scalar `s` as a vector with no labels."},{insertText:"year",label:"year",detail:"year(v=vector(time()) instant-vector)",documentation:"Returns the year for each of the given times in UTC."},{insertText:"avg_over_time",label:"avg_over_time",detail:"avg_over_time(range-vector)",documentation:"The average value of all points in the specified interval."},{insertText:"min_over_time",label:"min_over_time",detail:"min_over_time(range-vector)",documentation:"The minimum value of all points in the specified interval."},{insertText:"max_over_time",label:"max_over_time",detail:"max_over_time(range-vector)",documentation:"The maximum value of all points in the specified interval."},{insertText:"sum_over_time",label:"sum_over_time",detail:"sum_over_time(range-vector)",documentation:"The sum of all values in the specified interval."},{insertText:"count_over_time",label:"count_over_time",detail:"count_over_time(range-vector)",documentation:"The count of all values in the specified interval."},{insertText:"quantile_over_time",label:"quantile_over_time",detail:"quantile_over_time(scalar, range-vector)",documentation:"The φ-quantile (0 ≤ φ ≤ 1) of the values in the specified interval."},{insertText:"stddev_over_time",label:"stddev_over_time",detail:"stddev_over_time(range-vector)",documentation:"The population standard deviation of the values in the specified interval."},{insertText:"stdvar_over_time",label:"stdvar_over_time",detail:"stdvar_over_time(range-vector)",documentation:"The population standard variance of the values in the specified interval."},{insertText:"last_over_time",label:"last_over_time",detail:"last_over_time(range-vector)",documentation:"The most recent point value in specified interval."}],l=i.map((e=>e.label)),o={comment:{pattern:/#.*/},"context-aggregation":{pattern:/((by|without)\s*)\([^)]*\)/,lookbehind:!0,inside:{"label-key":{pattern:/[^(),\s][^,)]*[^),\s]*/,alias:"attr-name"},punctuation:/[()]/}},"context-labels":{pattern:/\{[^}]*(?=}?)/,greedy:!0,inside:{comment:{pattern:/#.*/},"label-key":{pattern:/[a-z_]\w*(?=\s*(=|!=|=~|!~))/,alias:"attr-name",greedy:!0},"label-value":{pattern:/"(?:\\.|[^\\"])*"/,greedy:!0,alias:"attr-value"},punctuation:/[{]/}},function:new RegExp(`\\b(?:${i.map((e=>e.label)).join("|")})(?=\\s*\\()`,"i"),"context-range":[{pattern:/\[[^\]]*(?=])/,inside:{"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}},{pattern:/(offset\s+)\w+/,lookbehind:!0,inside:{"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}}],idList:{pattern:/\d+(\|\d+)+/,alias:"number"},number:/\b-?\d+((\.\d*)?([eE][+-]?\d+)?)?\b/,operator:new RegExp(`/[-+*/=%^~]|&&?|\\|?\\||!=?|<(?:=>?|<|>)?|>[>=]?|\\b(?:${s.join("|")})\\b`,"i"),punctuation:/[{};()`,.]/}},98616:(e,t,a)=>{var n,s=a(68404),r=(n=s)&&"object"==typeof n&&"default"in n?n.default:n,i=a(69783),l=a(43215),o=a(82897),c=function(){return(c=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++)for(var s in t=arguments[a])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)};function u(e,t,a,n){return new(a||(a=Promise))((function(s,r){function i(e){try{o(n.next(e))}catch(e){r(e)}}function l(e){try{o(n.throw(e))}catch(e){r(e)}}function o(e){var t;e.done?s(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(i,l)}o((n=n.apply(e,t||[])).next())}))}function d(e,t){var a,n,s,r,i={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return r={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function l(r){return function(l){return function(r){if(a)throw new TypeError("Generator is already executing.");for(;i;)try{if(a=1,n&&(s=2&r[0]?n.return:r[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,r[1])).done)return s;switch(n=0,s&&(r=[2&r[0],s.value]),r[0]){case 0:case 1:s=r;break;case 4:return i.label++,{value:r[1],done:!1};case 5:i.label++,n=r[1],r=[0];continue;case 7:r=i.ops.pop(),i.trys.pop();continue;default:if(!((s=(s=i.trys).length>0&&s[s.length-1])||6!==r[0]&&2!==r[0])){i=0;continue}if(3===r[0]&&(!s||r[1]>s[0]&&r[1]<s[3])){i.label=r[1];break}if(6===r[0]&&i.label<s[1]){i.label=s[1],s=r;break}if(s&&i.label<s[2]){i.label=s[2],i.ops.push(r);break}s[2]&&i.ops.pop(),i.trys.pop();continue}r=t.call(e,i)}catch(e){r=[6,e],n=0}finally{a=s=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,l])}}}function h(e,t){var a="function"==typeof Symbol&&e[Symbol.iterator];if(!a)return e;var n,s,r=a.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=r.next()).done;)i.push(n.value)}catch(e){s={error:e}}finally{try{n&&!n.done&&(a=r.return)&&a.call(r)}finally{if(s)throw s.error}}return i}var m,p=["af-south-1","ap-east-1","ap-northeast-1","ap-northeast-2","ap-northeast-3","ap-south-1","ap-southeast-1","ap-southeast-2","ca-central-1","cn-north-1","cn-northwest-1","eu-central-1","eu-north-1","eu-west-1","eu-west-2","eu-west-3","me-south-1","sa-east-1","us-east-1","us-east-2","us-gov-east-1","us-gov-west-1","us-iso-east-1","us-isob-east-1","us-west-1","us-west-2"];(m=t._e||(t._e={})).Keys="keys",m.Credentials="credentials",m.Default="default",m.EC2IAMRole="ec2_iam_role",m.ARN="arn";var g,v=[{label:"Workspace IAM Role",value:t._e.EC2IAMRole},{label:"AWS SDK Default",value:t._e.Default},{label:"Access & secret key",value:t._e.Keys},{label:"Credentials file",value:t._e.Credentials}],f=function(e){return{value:e,label:e}},b=function(e){var a,n,o,u,d,m,g,b,x,y=h(s.useState((e.standardRegions||p).map(f)),2),j=y[0],T=y[1],_=e.loadRegions,S=e.onOptionsChange,C=e.skipHeader,w=void 0!==C&&C,I=e.skipEndpoint,E=void 0!==I&&I,D=e.options,q=D.jsonData.profile;void 0===q&&(q=D.database);var R=window.grafanaBootData.settings,O=null!==(a=R.awsAllowedAuthProviders)&&void 0!==a?a:[t._e.Default,t._e.Keys,t._e.Credentials],F=null===(n=R.awsAssumeRoleEnabled)||void 0===n||n,N=v.find((function(e){return e.value===D.jsonData.authType}));return s.useEffect((function(){!N&&O.length&&S(c(c({},D),{jsonData:c(c({},D.jsonData),{authType:O[0]})}))}),[N,D,S]),s.useEffect((function(){_&&_().then((function(e){return T(e.map(f))}))}),[_]),r.createElement(i.FieldSet,{label:w?"":"Connection Details","data-testid":"connection-config"},r.createElement(i.InlineField,{label:"Authentication Provider",labelWidth:28,tooltip:"Specify which AWS credentials chain to use."},r.createElement(i.Select,{"aria-label":"Authentication Provider",className:"width-30",value:N,options:v.filter((function(e){return O.includes(e.value)})),defaultValue:D.jsonData.authType,onChange:function(t){l.onUpdateDatasourceJsonDataOptionSelect(e,"authType")(t)},menuShouldPortal:!0})),"credentials"===D.jsonData.authType&&r.createElement(i.InlineField,{label:"Credentials Profile Name",labelWidth:28,tooltip:"Credentials profile name, as specified in ~/.aws/credentials, leave blank for default."},r.createElement(i.Input,{"aria-label":"Credentials Profile Name",className:"width-30",placeholder:"default",value:q,onChange:l.onUpdateDatasourceJsonDataOption(e,"profile")})),"keys"===D.jsonData.authType&&r.createElement(r.Fragment,null,r.createElement(i.InlineField,{label:"Access Key ID",labelWidth:28},(null===(o=e.options.secureJsonFields)||void 0===o?void 0:o.accessKey)?r.createElement(i.ButtonGroup,{className:"width-30"},r.createElement(i.Input,{disabled:!0,placeholder:"Configured"}),r.createElement(i.ToolbarButton,{icon:"edit",tooltip:"Edit Access Key ID",type:"button",onClick:l.onUpdateDatasourceResetOption(e,"accessKey")})):r.createElement(i.Input,{"aria-label":"Access Key ID",className:"width-30",value:null!==(d=null===(u=D.secureJsonData)||void 0===u?void 0:u.accessKey)&&void 0!==d?d:"",onChange:l.onUpdateDatasourceSecureJsonDataOption(e,"accessKey")})),r.createElement(i.InlineField,{label:"Secret Access Key",labelWidth:28},(null===(m=e.options.secureJsonFields)||void 0===m?void 0:m.secretKey)?r.createElement(i.ButtonGroup,{className:"width-30"},r.createElement(i.Input,{disabled:!0,placeholder:"Configured"}),r.createElement(i.ToolbarButton,{icon:"edit",type:"button",tooltip:"Edit Secret Access Key",onClick:l.onUpdateDatasourceResetOption(e,"secretKey")})):r.createElement(i.Input,{"aria-label":"Secret Access Key",className:"width-30",value:null!==(b=null===(g=D.secureJsonData)||void 0===g?void 0:g.secretKey)&&void 0!==b?b:"",onChange:l.onUpdateDatasourceSecureJsonDataOption(e,"secretKey")}))),F&&r.createElement(r.Fragment,null,r.createElement(i.InlineField,{label:"Assume Role ARN",labelWidth:28,tooltip:"Optionally, specify the ARN of a role to assume. Specifying a role here will ensure that the selected authentication provider is used to assume the specified role rather than using the credentials directly. Leave blank if you don't need to assume a role at all"},r.createElement(i.Input,{"aria-label":"Assume Role ARN",className:"width-30",placeholder:"arn:aws:iam:*",value:D.jsonData.assumeRoleArn||"",onChange:l.onUpdateDatasourceJsonDataOption(e,"assumeRoleArn")})),r.createElement(i.InlineField,{label:"External ID",labelWidth:28,tooltip:"If you are assuming a role in another account, that has been created with an external ID, specify the external ID here."},r.createElement(i.Input,{"aria-label":"External ID",className:"width-30",placeholder:"External ID",value:D.jsonData.externalId||"",onChange:l.onUpdateDatasourceJsonDataOption(e,"externalId")}))),!E&&r.createElement(i.InlineField,{label:"Endpoint",labelWidth:28,tooltip:"Optionally, specify a custom endpoint for the service"},r.createElement(i.Input,{"aria-label":"Endpoint",className:"width-30",placeholder:null!==(x=e.defaultEndpoint)&&void 0!==x?x:"https://{service}.{region}.amazonaws.com",value:D.jsonData.endpoint||"",onChange:l.onUpdateDatasourceJsonDataOption(e,"endpoint")})),r.createElement(i.InlineField,{label:"Default Region",labelWidth:28,tooltip:"Specify the region, such as for US West (Oregon) use ` us-west-2 ` as the region."},r.createElement(i.Select,{"aria-label":"Default Region",className:"width-30",value:j.find((function(e){return e.value===D.jsonData.defaultRegion})),options:j,defaultValue:D.jsonData.defaultRegion,allowCustomValue:!0,onChange:l.onUpdateDatasourceJsonDataOptionSelect(e,"defaultRegion"),formatCreateLabel:function(e){return"Use region: "+e},menuShouldPortal:!0})),e.children)};function x(e){var t=this,a=h(s.useState(e.value||e.default||null),2),n=a[0],l=a[1],m=h(s.useState(n?[n]:[]),2),p=m[0],g=m[1],v=h(s.useState(e.dependencies),2),f=v[0],b=v[1],x=h(s.useState(!1),2),y=x[0],j=x[1],T=h(s.useState(!1),2),_=T[0],S=T[1],C=s.useMemo((function(){var t=[{label:"default ("+e.default+")",value:"__default",description:"Default value set in the data source"}];return e.value&&"__default"!==e.value&&t.push({label:e.value,value:e.value}),t}),[e.default,e.value]),w=h(s.useState(e.default?C:[]),2),I=w[0],E=w[1];return s.useEffect((function(){void 0!==e.resources&&g(e.resources)}),[e.resources]),s.useEffect((function(){var t=e.default?C:[];p.length?(p.forEach((function(e){var a="string"==typeof e?e:e.value;t.find((function(e){return e.value===a}))||("string"==typeof e?t.push({label:e,value:e}):t.push(e))})),E(t)):E([])}),[p,C,e.default]),s.useEffect((function(){o.isEqual(e.dependencies,f)||(S(!1),l(null),e.onChange(null),b(e.dependencies))}),[e,f]),r.createElement(i.InlineField,{label:e.label,labelWidth:e.labelWidth,tooltip:e.tooltip,hidden:e.hidden},r.createElement("div",{"data-testid":e["data-testid"],title:e.title},r.createElement(i.Select,c({},e,{"aria-label":e.label,options:I,onChange:function(t){e.onChange(t),t.value&&l(t.value)},isLoading:y,className:e.className||"min-width-6",onOpenMenu:function(){return e.fetch&&u(t,void 0,void 0,(function(){return d(this,(function(a){switch(a.label){case 0:j(!0),a.label=1;case 1:return a.trys.push([1,,3,4]),[4,u(t,void 0,void 0,(function(){var t;return d(this,(function(a){switch(a.label){case 0:return _?[2]:e.saveOptions?[4,e.saveOptions()]:[3,2];case 1:a.sent(),a.label=2;case 2:return a.trys.push([2,,4,5]),[4,e.fetch()];case 3:return t=a.sent(),g(t),[3,5];case 4:return S(!0),[7];case 5:return[2]}}))}))];case 2:return a.sent(),[3,4];case 3:return j(!1),[7];case 4:return[2]}}))}))},menuShouldPortal:!0}))))}(g=t.rB||(t.rB={}))[g.Previous=0]="Previous",g[g.Null=1]="Null",g[g.Value=2]="Value";var y=[{label:"Previous Value",value:t.rB.Previous},{label:"NULL",value:t.rB.Null},{label:"Value",value:t.rB.Value}];function j(e){return"string"==typeof e?e:e.map((function(e){return function(e){return"'"+String(e).replace(/'/g,"''")+"'"}(e)})).join(",")}t.ConnectionConfig=b,t.SIGV4ConnectionConfig=function(e){var t,a,n,s,i=e.onOptionsChange,l=e.options,o={onOptionsChange:function(e){var t,a,n,s,r=c(c({},l),{jsonData:c(c({},l.jsonData),{sigV4AuthType:e.jsonData.authType,sigV4Profile:e.jsonData.profile,sigV4AssumeRoleArn:e.jsonData.assumeRoleArn,sigV4ExternalId:e.jsonData.externalId,sigV4Region:e.jsonData.defaultRegion,sigV4Endpoint:e.jsonData.endpoint}),secureJsonFields:{sigV4AccessKey:null===(t=e.secureJsonFields)||void 0===t?void 0:t.accessKey,sigV4SecretKey:null===(a=e.secureJsonFields)||void 0===a?void 0:a.secretKey},secureJsonData:{sigV4AccessKey:null===(n=e.secureJsonData)||void 0===n?void 0:n.accessKey,sigV4SecretKey:null===(s=e.secureJsonData)||void 0===s?void 0:s.secretKey}});i(r)},options:c(c({},l),{jsonData:c(c({},l.jsonData),{authType:l.jsonData.sigV4AuthType,profile:l.jsonData.sigV4Profile,assumeRoleArn:l.jsonData.sigV4AssumeRoleArn,externalId:l.jsonData.sigV4ExternalId,defaultRegion:l.jsonData.sigV4Region,endpoint:l.jsonData.sigV4Endpoint}),secureJsonFields:{accessKey:null===(t=l.secureJsonFields)||void 0===t?void 0:t.sigV4AccessKey,secretKey:null===(a=l.secureJsonFields)||void 0===a?void 0:a.sigV4SecretKey},secureJsonData:{accessKey:null===(n=l.secureJsonData)||void 0===n?void 0:n.sigV4AccessKey,secretKey:null===(s=l.secureJsonData)||void 0===s?void 0:s.sigV4SecretKey}})};return r.createElement(r.Fragment,null,r.createElement("div",{className:"gf-form"},r.createElement("h6",null,"SigV4 Auth Details")),r.createElement(b,c({},o,{skipHeader:!0,skipEndpoint:!0})))}},47472:(e,t,a)=>{"use strict";e.exports=a(98616)}}]);
//# sourceMappingURL=prometheusPlugin.8fe80bcd12a80b3cb23b.js.map