(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7004],{44415:(e,t,a)=>{"use strict";a.r(t),a.d(t,{plugin:()=>Ja});var n,s=a(19177),r=a(76687),i=a(52010);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=a(10967),u=a(92379),d=a(70534),h=a(89467),m=a(84071),p=a(17533),g=a(43853),v=a(49184),f=a(46801),b=a(22814);let x,y;function j(e){return"values"in e}!function(e){e.timeSeriesQuery="timeSeriesQuery"}(x||(x={})),function(e){e.Auto="__auto",e.Verbose="__verbose",e.Custom="__custom"}(y||(y={}));const T="PrometheusQueryEditorModeDefault";function _(e,t,a){""===e.expr&&b.Z.set(T,t),a(Object.assign({},e,{editorMode:t}))}function S(e){if(null!=e&&""!==e)return f.c.Code;const t=b.Z.get(T);switch(t){case f.c.Builder:case f.c.Code:case f.c.Explain:return t;default:return f.c.Builder}}const C="PrometheusQueryEditorRawQueryDefault";function w(){const[e,t]=(0,r.useState)(function(){const e=b.Z.get(C);return void 0===e||Boolean(parseInt(e,10))}());return[e,(0,r.useCallback)((e=>{!function(e){b.Z.set(C,e?"1":"0")}(e),t(e)}),[])]}var I=a(25293),E=a(21391),D=a(1512),q=a(84242),R=a(30394),O=a(68490),F=a(63781),N=a.n(F);function A(e){let{query:t,onChange:a,onGetMetrics:n}=e;const l=(0,d.useStyles2)(P),[o,c]=(0,r.useState)({}),h=(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)(N(),{searchWords:t.inputValue.split(" "),textToHighlight:null!==(a=e.label)&&void 0!==a?a:"",highlightClassName:l.highlight})}),[l.highlight]);return(0,i.jsx)(u.EditorFieldGroup,{children:(0,i.jsx)(u.EditorField,{label:"Metric",children:(0,i.jsx)(d.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:h,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 P=e=>({select:O.css`
    min-width: 125px;
  `,highlight:O.css`
    label: select__match-highlight;
    background: inherit;
    padding: inherit;
    color: ${e.colors.warning.contrastText};
    background-color: ${e.colors.warning.main};
  `});var k,L=a(84114),Q=a(30798);const V=r.memo((e=>{let{nestedQuery:t,index:a,datasource:n,onChange:r,onRemove:l,onRunQuery:o}=e;const c=(0,d.useStyles2)($);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)(d.Select,{width:"auto",options:M,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)(d.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)(Q.H,{className:c.vectorMatchInput,minWidth:20,defaultValue:t.vectorMatches,onCommitChange:e=>{r(a,Object.assign({},t,{vectorMatches:e.currentTarget.value,vectorMatchesType:t.vectorMatchesType||"on"}))}})]}),k||(k=(0,i.jsx)(u.FlexItem,{grow:1})),(0,i.jsx)(d.IconButton,{name:"times",size:"sm",onClick:()=>l(a)})]}),(0,i.jsx)("div",{className:c.body,children:(0,i.jsx)(u.EditorRows,{children:(0,i.jsx)(z,{query:t.query,datasource:n,nested:!0,onRunQuery:o,onChange:e=>{r(a,Object.assign({},t,{query:e}))}})})})]})})),M=L.iQ.map((e=>({label:e.sign,value:e.sign})));V.displayName="NestedQuery";const $=e=>({card:(0,O.css)({label:"card",display:"flex",flexDirection:"column",gap:e.spacing(.5)}),header:(0,O.css)({label:"header",padding:e.spacing(.5,.5,.5,1),gap:e.spacing(1),display:"flex",alignItems:"center"}),name:(0,O.css)({label:"name",whiteSpace:"nowrap"}),body:(0,O.css)({label:"body",paddingLeft:e.spacing(2)}),vectorMatchInput:(0,O.css)({label:"vectorMatchInput",marginLeft:-1}),vectorMatchWrapper:(0,O.css)({label:"vectorMatchWrapper",display:"flex"})});function U(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)(u.Stack,{direction:"column",gap:1,children:l.map(((e,t)=>(0,i.jsx)(V,{nestedQuery:e,index:t,onChange:o,datasource:n,onRemove:c,onRunQuery:r},t.toString())))})}const X=r.memo((e=>{let{datasource:t,query:a,onChange:n,data:s}=e;const[l,o]=(0,r.useState)([]),c=(0,d.useStyles2)(B);return(0,r.useEffect)((()=>{const e={expr:h.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)(d.Tooltip,{content:`${e.label} ${null===(s=e.fix)||void 0===s?void 0:s.label}`,children:(0,i.jsx)(d.Button,{onClick:()=>{const s={expr:h.Z.renderQuery(a),refId:""},r=t.modifyQuery(s,e.fix.action),i=(0,m._)(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)}))})})}));X.displayName="PromQueryBuilderHints";const B=e=>({container:O.css`
      display: flex;
      margin-bottom: ${e.spacing(1)};
      align-items: center;
    `,hint:O.css`
      margin-right: ${e.spacing(1)};
    `}),z=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();e.languageProvider.metricsMetadata||(e.languageProvider.metricsMetadata={});let a;if(t.labels.length>0){var n;const s=h.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,E.UQ)(t,e.languageProvider.metricsMetadata)})))}(t,a))),[t,a,o]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(u.EditorRow,{children:[(0,i.jsx)(A,{query:a,onChange:n,onGetMetrics:c}),(0,i.jsx)(D.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=h.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=h.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)(R.B,{children:[(0,i.jsx)(q.P,{queryModeller:h.Z,datasource:t,query:a,onChange:n,onRunQuery:s}),(0,i.jsx)(X,{datasource:t,query:a,onChange:n,data:l})]}),a.binaryQueries&&a.binaryQueries.length>0&&(0,i.jsx)(U,{query:a,datasource:t,onChange:n,onRunQuery:s})]})}));z.displayName="PromQueryBuilder";var W=a(55704),K=a(63750);function G(e){let{query:t}=e;return(0,i.jsx)(u.EditorRow,{children:(0,i.jsx)(u.EditorFieldGroup,{children:(0,i.jsx)(u.EditorField,{label:"Raw query",children:(0,i.jsx)(K.U,{query:t,lang:{grammar:W.ZP,name:"promql"}})})})})}function J(e){const{query:t,onChange:a,onRunQuery:n,datasource:s,data:l,showRawQuery:o}=e,[c,u]=(0,r.useReducer)(H.reducer,{expr:t.expr});(0,r.useEffect)((()=>{u(Y(t.expr))}),[t.expr]);return c.visQuery?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(z,{query:c.visQuery,datasource:s,onChange:t=>{const n=h.Z.renderQuery(t);u(Z({visQuery:t,expr:n})),a(Object.assign({},e.query,{expr:n}))},onRunQuery:n,data:l}),o&&(0,i.jsx)(G,{query:t.expr})]}):null}const H=(0,I.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,m._)(t.payload);e.visQuery=a.query}}}}),{visualQueryChange:Z,exprChanged:Y}=H.actions;var ee=a(47281),te=a(1486);const ae=r.memo((e=>{let{query:t}=e;const a=(0,m._)(t||"").query,n={grammar:W.ZP,name:"promql"};return(0,i.jsxs)(u.Stack,{gap:.5,direction:"column",children:[(0,i.jsx)(ee.B,{children:(0,i.jsx)(K.U,{query:t,lang:n})}),(0,i.jsx)(ee.B,{stepNumber:1,title:(0,i.jsx)(K.U,{query:`${a.metric} ${h.Z.renderLabels(a.labels)}`,lang:n}),children:"Fetch all series matching metric name and label filters."}),(0,i.jsx)(te.V,{stepNumber:2,queryModeller:h.Z,query:a,lang:n})]})}));ae.displayName="PromQueryBuilderExplained";var ne=a(86832),se=a(37762);const re=["datasource","onChange","query"];function ie(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,re);const[l,o]=(0,r.useState)(null),c=(0,d.useStyles2)(le),u=(0,se.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 h=(0,O.cx)({[c.activeIcon]:!!n.exemplar},c.eyeIcon);return(0,i.jsx)(d.InlineLabel,{width:"auto","data-testid":s["data-testid"],children:(0,i.jsx)(d.Tooltip,{content:null!=l?l:"",children:(0,i.jsxs)("div",{className:c.iconWrapper,children:["Exemplars",(0,i.jsx)(d.IconButton,{name:"eye",tooltip:n.exemplar?"Disable query with exemplars":"Enable query with exemplars",disabled:!!l,className:h,onClick:()=>{a(!n.exemplar)}})]})})})}function le(e){return{eyeIcon:O.css`
      margin-left: ${e.spacing(2)};
    `,activeIcon:O.css`
      color: ${e.colors.primary.main};
    `,iconWrapper:O.css`
      display: flex;
      align-items: center;
    `}}var oe,ce;const ue=(0,r.memo)((e=>{var t;let{query:a,datasource:n,onChange:s,onRunQuery:l}=e;const o=de(!0),c=(0,se.Z)(a),u=(0,r.useCallback)((e=>{(0,ne.isEqual)(a,c)&&e===a.exemplar||s(Object.assign({},a,{exemplar:e}))}),[c,a,s]);const h=he(a,s);return(0,i.jsxs)("div",{"aria-label":"Prometheus extra field",className:"gf-form-inline","data-testid":me.extraFieldEditor,children:[(0,i.jsxs)("div",{"data-testid":me.queryTypeField,className:(0,O.cx)("gf-form explore-input-margin",O.css`
              flex-wrap: nowrap;
            `),"aria-label":"Query type field",children:[oe||(oe=(0,i.jsx)(d.InlineFormLabel,{width:"auto",children:"Query type"})),(0,i.jsx)(d.RadioButtonGroup,{options:o,value:a.range&&a.instant?"both":a.instant?"instant":"range",onChange:h})]}),(0,i.jsxs)("div",{"data-testid":me.stepField,className:(0,O.cx)("gf-form",O.css`
              flex-wrap: nowrap;
            `),"aria-label":"Step field",children:[ce||(ce=(0,i.jsx)(d.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)(ie,{onChange:u,datasource:n,query:a})]})}));function de(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 he(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}))}}ue.displayName="PromExploreExtraField";const me={extraFieldEditor:"prom-editor-extra-field",stepField:"prom-editor-extra-field-step",queryTypeField:"prom-editor-extra-field-query-type"},pe=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,ne.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"})},ge=(0,r.memo)(pe);var ve=a(16245),fe=a(42805);var be,xe,ye,je,Te,_e=a(93107),Se=a(42153);function Ce(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const we="{}",Ie="__name__";function Ee(e){let t="";const a=[];for(const n of e)if((n.name===Ie||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(_e.tU).join("|")}"`):1===e.length&&(n.name===Ie?t=e[0]:a.push(`${n.name}="${(0,_e.U9)(e[0])}"`))}return[t,"{",a.join(","),"}"].join("")}const De=(0,d.stylesFactory)((e=>({wrapper:O.css`
    background-color: ${e.colors.bg2};
    padding: ${e.spacing.sm};
    width: 100%;
  `,list:O.css`
    margin-top: ${e.spacing.sm};
    display: flex;
    flex-wrap: wrap;
    max-height: 200px;
    overflow: auto;
    align-content: flex-start;
  `,section:O.css`
    & + & {
      margin: ${e.spacing.md} 0;
    }
    position: relative;
  `,selector:O.css`
    font-family: ${e.typography.fontFamily.monospace};
    margin-bottom: ${e.spacing.sm};
  `,status:O.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:O.css`
    opacity: 1;
  `,error:O.css`
    color: ${e.palette.brandDanger};
  `,valueList:O.css`
    margin-right: ${e.spacing.sm};
  `,valueListWrapper:O.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:O.css`
    display: flex;
    flex-wrap: wrap;
    margin-top: ${e.spacing.sm};
  `,valueTitle:O.css`
    margin-left: -${e.spacing.xs};
    margin-bottom: ${e.spacing.sm};
  `,validationStatus:O.css`
    padding: ${e.spacing.xs};
    margin-bottom: ${e.spacing.sm};
    color: ${e.colors.textStrong};
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  `})));class qe extends r.Component{constructor(){super(...arguments),Ce(this,"valueListsRef",r.createRef()),Ce(this,"state",{labels:[],labelSearchTerm:"",metricSearchTerm:"",status:"Ready",error:"",validationStatus:"",valueSearchTerm:""}),Ce(this,"onChangeLabelSearch",(e=>{this.setState({labelSearchTerm:e.target.value})})),Ce(this,"onChangeMetricSearch",(e=>{this.setState({metricSearchTerm:e.target.value})})),Ce(this,"onChangeValueSearch",(e=>{this.setState({valueSearchTerm:e.target.value})})),Ce(this,"onClickRunQuery",(()=>{const e=Ee(this.state.labels);this.props.onChange(e)})),Ce(this,"onClickRunRateQuery",(()=>{const e=`rate(${Ee(this.state.labels)}[$__interval])`;this.props.onChange(e)})),Ce(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(Ie,we)})),Ce(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)))})),Ce(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)))})),Ce(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)))})),Ce(this,"onClickValidate",(()=>{const e=Ee(this.state.labels);this.validateSelector(e)})),Ce(this,"doFacetting",(e=>{const t=Ee(this.state.labels);if(t===we){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===Ie)&&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(Ie,we);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,we)}))}))}))}}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,Ee(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!==Ee(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===Ie&&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!==Ee(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,h=De(a);if(0===n.length)return(0,i.jsx)("div",{className:h.wrapper,children:be||(be=(0,i.jsx)(d.LoadingPlaceholder,{text:"Loading labels..."}))});let m=n.find((e=>e.name===Ie));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 g=n.filter((e=>!e.hidden&&e.name!==Ie));s&&(g=g.filter((e=>e.selected||e.name.includes(s))));let v=g.filter((e=>e.selected&&e.values));u&&(v=v.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 f=Ee(this.state.labels),b=f===we,x=(null===(e=m)||void 0===e||null===(t=e.values)||void 0===t?void 0:t.length)||0;return(0,i.jsxs)("div",{className:h.wrapper,children:[(0,i.jsxs)(d.HorizontalGroup,{align:"flex-start",spacing:"lg",children:[(0,i.jsx)("div",{children:(0,i.jsxs)("div",{className:h.section,children:[xe||(xe=(0,i.jsx)(d.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)(d.Input,{onChange:this.onChangeMetricSearch,"aria-label":"Filter expression for metric",value:r})}),(0,i.jsx)("div",{role:"list",className:h.valueListWrapper,children:(0,i.jsx)(Se.t7,{height:Math.min(450,25*x),itemCount:x,itemSize:25,itemKey:e=>m.values[e].name,width:300,className:h.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)(d.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:h.section,children:[ye||(ye=(0,i.jsx)(d.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)(d.Input,{onChange:this.onChangeLabelSearch,"aria-label":"Filter expression for label",value:s})}),(0,i.jsx)("div",{className:h.list,style:{height:120},children:g.map((e=>(0,i.jsx)(d.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:h.section,children:[je||(je=(0,i.jsx)(d.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)(d.Input,{onChange:this.onChangeValueSearch,"aria-label":"Filter expression for label values",value:u})}),(0,i.jsx)("div",{className:h.valueListArea,ref:this.valueListsRef,children:v.map((e=>{var t,a,n;return(0,i.jsxs)("div",{role:"list","aria-label":`Values for ${e.name}`,className:h.valueListWrapper,children:[(0,i.jsx)("div",{className:h.valueTitle,children:(0,i.jsx)(d.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)(Se.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:h.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)(d.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:h.section,children:[Te||(Te=(0,i.jsx)(d.Label,{children:"4. Resulting selector"})),(0,i.jsx)("div",{"aria-label":"selector",className:h.selector,children:f}),c&&(0,i.jsx)("div",{className:h.validationStatus,children:c}),(0,i.jsxs)(d.HorizontalGroup,{children:[(0,i.jsx)(d.Button,{"aria-label":"Use selector for query button",disabled:b,onClick:this.onClickRunQuery,children:"Use query"}),(0,i.jsx)(d.Button,{"aria-label":"Use selector as metrics button",variant:"secondary",disabled:b,onClick:this.onClickRunRateQuery,children:"Use as rate query"}),(0,i.jsx)(d.Button,{"aria-label":"Validate submit button",variant:"secondary",disabled:b,onClick:this.onClickValidate,children:"Validate selector"}),(0,i.jsx)(d.Button,{"aria-label":"Selector clear button",variant:"secondary",onClick:this.onClickClear,children:"Clear"}),(0,i.jsx)("div",{className:(0,O.cx)(h.status,(l||o)&&h.statusShowing),children:(0,i.jsx)("span",{className:o?h.error:"",children:o||l})})]})]})]})}}const Re=(0,d.withTheme)(qe),Oe=r.lazy((()=>a.e(6031).then(a.bind(a,5994)))),Fe=e=>(0,i.jsx)(r.Suspense,{fallback:null,children:(0,i.jsx)(Oe,Object.assign({},e))}),Ne=["runQueryOnBlur","onRunQuery","onChange"];const Ae=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,Ne),o=e=>{t.current=e,s(e),n()};return(0,i.jsx)(Fe,Object.assign({onRunQuery:o,onBlur:e=>{a?e!==t.current&&o(e):s(e)}},l))};function Pe(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class ke extends r.PureComponent{constructor(e,t){super(e,t),Pe(this,"plugins",void 0),Pe(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})})),Pe(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}})),Pe(this,"onChangeLabelBrowser",(e=>{this.onChangeQuery(e,!0),this.setState({labelBrowserVisible:!1})})),Pe(this,"onChangeQuery",((e,t)=>{const{query:a,onChange:n,onRunQuery:s}=this.props;if(n){n(Object.assign({},a,{expr:e})),t&&s&&s()}})),Pe(this,"onClickChooserButton",(()=>{this.setState((e=>({labelBrowserVisible:!e.labelBrowserVisible})))})),Pe(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()})),Pe(this,"onUpdateLanguage",(()=>{const{datasource:{languageProvider:e}}=this.props,{metrics:t}=e;t&&this.setState({syntaxLoaded:!0})})),Pe(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,d.BracesPlugin)(),(0,d.SlatePrism)({onlyIn:e=>"code_block"===e.type,getSyntax:e=>"promql"},Object.assign({},ve.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,_e.o8)(e.from.valueOf())===(0,_e.o8)(t.from.valueOf()),n=(0,_e.o8)(e.to.valueOf())===(0,_e.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,h=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)(fe.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:[h,(0,i.jsx)(d.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)(Ae,{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)(Re,{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 Le=ke;var Qe,Ve,Me,$e;function Ue(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:Xe}=d.LegacyForms,Be=[{label:"Time series",value:"time_series"},{label:"Table",value:"table"},{label:"Heatmap",value:"heatmap"}],ze=(0,ne.map)([1,2,3,4,5,10],(e=>({value:e,label:"1/"+e})));class We extends r.PureComponent{constructor(e){super(e),Ue(this,"query",void 0),Ue(this,"onFieldChange",((e,t)=>{this.query.expr=e.expr})),Ue(this,"onFormatChange",(e=>{this.query.format=e.value,this.setState({formatOption:e},this.onRunQuery)})),Ue(this,"onInstantChange",(e=>{const t=e.target.checked;this.query.instant=t,this.setState({instant:t},this.onRunQuery)})),Ue(this,"onIntervalChange",(e=>{const t=e.currentTarget.value;this.query.interval=t,this.setState({interval:t})})),Ue(this,"onIntervalFactorChange",(e=>{this.query.intervalFactor=e.value,this.setState({intervalFactorOption:e},this.onRunQuery)})),Ue(this,"onLegendChange",(e=>{const t=e.currentTarget.value;this.query.legendFormat=t,this.setState({legendFormat:t})})),Ue(this,"onExemplarChange",(e=>{this.query.exemplar=e,this.setState({exemplar:e},this.onRunQuery)})),Ue(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:Be.find((e=>e.value===a.format))||Be[0],intervalFactorOption:ze.find((e=>e.value===a.intervalFactor))||ze[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,h=this.props.app!==s.CoreApp.UnifiedAlerting;return(0,i.jsx)(Le,{datasource:e,query:t,range:a,onRunQuery:this.onRunQuery,onChange:this.onFieldChange,history:[],data:n,"data-testid":Ke.editor,ExtraFieldElement:(0,i.jsxs)("div",{className:"gf-form-inline",children:[(0,i.jsxs)("div",{className:"gf-form",children:[Qe||(Qe=(0,i.jsx)(d.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:[Ve||(Ve=(0,i.jsx)(d.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:[Me||(Me=(0,i.jsx)("div",{className:"gf-form-label",children:"Resolution"})),(0,i.jsx)(d.Select,{"aria-label":"Select resolution",isSearchable:!1,options:ze,onChange:this.onIntervalFactorChange,value:c})]}),(0,i.jsxs)("div",{className:"gf-form",children:[$e||($e=(0,i.jsx)("div",{className:"gf-form-label width-7",children:"Format"})),(0,i.jsx)(d.Select,{className:"select-container",width:16,isSearchable:!1,options:Be,onChange:this.onFormatChange,value:r,"aria-label":"Select format"}),(0,i.jsx)(Xe,{label:"Instant",checked:l,onChange:this.onInstantChange}),(0,i.jsx)(d.InlineFormLabel,{width:10,tooltip:"Link to Graph in Prometheus",children:(0,i.jsx)(ge,{datasource:e,query:this.query,panelData:n})})]}),h&&(0,i.jsx)(ie,{onChange:this.onExemplarChange,datasource:e,query:this.query,"data-testid":Ke.exemplar})]})})}}const Ke={editor:"prom-editor",exemplar:"exemplar-editor"};var Ge=a(75788);const Je=[{label:"Auto",value:y.Auto,description:"Only includes unique labels"},{label:"Verbose",value:y.Verbose,description:"All label names and values"},{label:"Custom",value:y.Custom,description:"Provide a naming template"}],He=r.memo((e=>{let{legendFormat:t,onChange:a,onRunQuery:n}=e;const s=Ze(t),l=(0,r.useRef)(null);return(0,i.jsx)(u.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===y.Custom&&(0,i.jsx)(Q.H,{id:"legendFormat",minWidth:22,placeholder:"auto",defaultValue:t,onCommitChange:e=>{let s=e.currentTarget.value;0===s.length&&(s=y.Auto),s!==t&&(a(s),n())},ref:l}),s!==y.Custom&&(0,i.jsx)(d.Select,{inputId:"legend.mode",isSearchable:!1,placeholder:"Select legend mode",options:Je,width:22,onChange:e=>{switch(e.value){case y.Auto:a(y.Auto);break;case y.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 y.Verbose:a("")}n()},value:Je.find((e=>e.value===s))})]})})}));function Ze(e){return e===y.Auto?y.Auto:null==e||""===e?y.Verbose:y.Custom}var Ye,et;He.displayName="PromQueryLegendEditor";const tt=r.memo((e=>{let{query:t,app:a,onChange:n,onRunQuery:r}=e;const l=de(a===s.CoreApp.Explore),o=he(t,n),c=Be.find((e=>e.value===t.format))||Be[0],h=function(e){return e.range&&e.instant?"both":e.instant?"instant":"range"}(t),m=l.find((e=>e.value===h)).label;return(0,i.jsx)(u.EditorRow,{children:(0,i.jsxs)(Ge.d,{title:"Options",collapsedInfo:nt(t,c.label,m),children:[(0,i.jsx)(He,{legendFormat:t.legendFormat,onChange:e=>n(Object.assign({},t,{legendFormat:e})),onRunQuery:r}),(0,i.jsx)(u.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"," ",Ye||(Ye=(0,i.jsx)("code",{children:"$__interval"}))," and ",et||(et=(0,i.jsx)("code",{children:"$__rate_interval"}))," variables."]}),children:(0,i.jsx)(Q.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)(u.EditorField,{label:"Format",children:(0,i.jsx)(d.Select,{value:c,allowCustomValue:!0,onChange:e=>{n(Object.assign({},t,{format:e.value})),r()},options:Be})}),(0,i.jsx)(u.EditorField,{label:"Type",children:(0,i.jsx)(d.RadioButtonGroup,{options:l,value:h,onChange:o})}),at(t,a)&&(0,i.jsx)(u.EditorField,{label:"Exemplars",children:(0,i.jsx)(u.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)(u.EditorField,{label:"Resolution",children:(0,i.jsx)(d.Select,{"aria-label":"Select resolution",isSearchable:!1,options:ze,onChange:e=>{n(Object.assign({},t,{intervalFactor:e.value})),r()},value:ze.find((e=>e.value===t.intervalFactor))})})]})})}));function at(e,t){return!(t===s.CoreApp.UnifiedAlerting||!e.range)}function nt(e,t,a){var n;const s=[];return s.push(`Legend: ${function(e){const t=Ze(e);var a;return t!==y.Custom?null===(a=Je.find((e=>e.value===t)))||void 0===a?void 0:a.label:e}(e.legendFormat)}`),s.push(`Format: ${t}`),s.push(`Step: ${null!==(n=e.interval)&&void 0!==n?n:"auto"}`),s.push(`Type: ${a}`),e.exemplar&&s.push("Exemplars: true"),s}function st(e){let{query:t,datasource:a,range:n,onRunQuery:s,onChange:r,data:l,app:o}=e;const c=(0,d.useStyles2)(rt);return(0,i.jsx)("div",{className:c.wrapper,children:(0,i.jsx)(Le,{datasource:a,query:t,range:n,onRunQuery:s,onChange:r,history:[],data:l,"data-testid":Ke.editor,app:o})})}tt.displayName="PromQueryBuilderOptions";const rt=e=>({wrapper:O.css`
      .gf-form {
        margin-bottom: 0;
      }
    `});var it,lt,ot;const ct=r.memo((e=>{const{onChange:t,onRunQuery:a,data:n,app:l}=e,[o,b]=(0,r.useState)(!1),[x,j]=(0,r.useState)(!1),T=function(e,t){let a=e;return e.editorMode||(a=Object.assign({},e,{editorMode:S(e.expr)})),null==e.expr&&(a=Object.assign({},a,{expr:"",legendFormat:y.Auto})),null==e.range&&null==e.instant&&(a=Object.assign({},a,{range:!0}),t===s.CoreApp.Explore&&(a.instant=!0)),a}(e.query,l),[C,I]=w(),E=T.editorMode,D=(0,r.useCallback)((e=>{var a;if((0,c.reportInteraction)("user_grafana_prometheus_editor_mode_clicked",{newEditor:e,previousEditor:null!==(a=T.editorMode)&&void 0!==a?a:"",newQuery:!T.expr,app:null!=l?l:""}),e===f.c.Builder){if((0,m._)(T.expr||"").errors.length)return void b(!0)}_(T,e,t)}),[t,T,l]);(0,r.useEffect)((()=>{j(!1)}),[n]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(d.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:()=>{_(T,f.c.Builder,t),b(!1)},onDismiss:()=>b(!1)}),(0,i.jsxs)(u.EditorHeader,{children:[(0,i.jsx)(u.InlineSelect,{value:null,placeholder:"Query patterns",allowCustomValue:!0,onChange:e=>{let{value:a}=e;const n=(0,m._)(T.expr||"");n.query.operations=null==a?void 0:a.operations,t(Object.assign({},T,{expr:h.Z.renderQuery(n.query)}))},options:h.Z.getQueryPatterns().map((e=>({label:e.name,value:e})))}),E===f.c.Builder&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v.n,{label:"Raw query",value:C,onChange:e=>{const t=e.currentTarget.checked;I(t)}}),it||(it=(0,i.jsx)(p.R,{feedbackUrl:"https://github.com/grafana/grafana/discussions/47693"}))]}),lt||(lt=(0,i.jsx)(u.FlexItem,{grow:1})),l!==s.CoreApp.Explore&&(0,i.jsx)(d.Button,{variant:x?"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)(g.k,{mode:E,onChange:D})]}),ot||(ot=(0,i.jsx)(u.Space,{v:.5})),(0,i.jsxs)(u.EditorRows,{children:[E===f.c.Code&&(0,i.jsx)(st,Object.assign({},e)),E===f.c.Builder&&(0,i.jsx)(J,{query:T,datasource:e.datasource,onChange:e=>{j(!0),t(e)},onRunQuery:e.onRunQuery,data:n,showRawQuery:C}),E===f.c.Explain&&(0,i.jsx)(ae,{query:T.expr}),E!==f.c.Explain&&(0,i.jsx)(tt,{query:T,app:e.app,onChange:t,onRunQuery:a})]})]})}));ct.displayName="PromQueryEditorSelector";const ut=(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)(Le,{app:s.CoreApp.Explore,datasource:l,query:a,range:t,onRunQuery:u,onChange:c,onBlur:()=>{},history:o,data:n,"data-testid":dt.editor,ExtraFieldElement:(0,i.jsx)(ue,{query:a,onChange:c,datasource:l,onRunQuery:u})})}));ut.displayName="PromExploreQueryEditor";const dt={editor:"prom-editor-explore"};function ht(e){const{datasource:t,query:a,range:n,data:s,onChange:r,onRunQuery:l}=e;return(0,i.jsx)(Le,{datasource:t,query:a,onRunQuery:l,onChange:r,history:[],range:n,data:s,"data-testid":mt.editor})}const mt={editor:"prom-editor-cloud-alerting"};function pt(e){const{app:t}=e;switch(t){case s.CoreApp.CloudAlerting:return(0,i.jsx)(ht,Object.assign({},e));case s.CoreApp.Explore:return c.config.featureToggles.promQueryBuilder?(0,i.jsx)(ct,Object.assign({},e)):(0,i.jsx)(ut,Object.assign({},e));default:return c.config.featureToggles.promQueryBuilder?(0,i.jsx)(ct,Object.assign({},e)):(0,i.jsx)(We,Object.assign({},e))}}const gt=(0,r.memo)(pt);var vt=a(1181),ft=a(72e3),bt=a(13698);let xt;!function(e){e.Public="AzureCloud",e.China="AzureChinaCloud",e.USGovernment="AzureUSGovernment",e.Germany="AzureGermanCloud",e.None=""}(xt||(xt={}));const yt=[{value:xt.Public,label:"Azure"},{value:xt.China,label:"Azure China"},{value:xt.USGovernment,label:"Azure US Government"},{value:xt.Germany,label:"Azure Germany"}];const jt=Symbol("Concealed client secret");function Tt(){return c.config.azure.cloud||xt.Public}function _t(e){if(e.secureJsonFields.azureClientSecret)return jt;{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 St(){return c.config.azure.managedIdentityEnabled?{authType:"msi"}:{authType:"clientsecret",azureCloud:Tt()}}var Ct,wt,It,Et,Dt,qt,Rt,Ot=a(30315),Ft=a(25086),Nt=a(32362);const At=[{value:"msi",label:"Managed Identity"},{value:"clientsecret",label:"App Registration"}],Pt=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:[Ct||(Ct=(0,i.jsx)(Ot.cJ0,{className:"width-12",tooltip:"Choose the type of authentication to Azure services",children:"Authentication"})),(0,i.jsx)(Nt.Ph,{className:"width-15",value:At.find((e=>e.value===t.authType)),options:At,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:[wt||(wt=(0,i.jsx)(Ot.cJ0,{className:"width-12",tooltip:"Choose an Azure Cloud",children:"Azure Cloud"})),(0,i.jsx)(Nt.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:[It||(It=(0,i.jsx)(Ot.cJ0,{className:"width-12",children:"Directory (tenant) ID"})),(0,i.jsx)("div",{className:"width-15",children:(0,i.jsx)(Ft.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:[Et||(Et=(0,i.jsx)(Ot.cJ0,{className:"width-12",children:"Application (client) ID"})),(0,i.jsx)("div",{className:"width-15",children:(0,i.jsx)(Ft.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:[Dt||(Dt=(0,i.jsxs)("div",{className:"gf-form",children:[(0,i.jsx)(Ot.cJ0,{className:"width-12",children:"Client Secret"}),(0,i.jsx)(Ft.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)(Ot.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:[qt||(qt=(0,i.jsx)(Ot.cJ0,{className:"width-12",children:"Client Secret"})),(0,i.jsx)("div",{className:"width-15",children:(0,i.jsx)(Ft.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:[Rt||(Rt=(0,i.jsx)(Ot.cJ0,{className:"width-12",children:"Default Subscription"})),(0,i.jsx)("div",{className:"width-25",children:(0,i.jsx)(Nt.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)(Ot.zxk,{variant:"secondary",size:"sm",type:"button",onClick:d,disabled:!l,children:"Load Subscriptions"})})})})]})]})};var kt,Lt;const Qt=e=>{const{dataSourceConfig:t,onChange:a}=e,[n]=(0,r.useState)(c.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 St();switch(t.authType){case"msi":return c.config.azure.managedIdentityEnabled?{authType:"msi"}:{authType:"clientsecret",azureCloud:Tt()};case"clientsecret":return{authType:"clientsecret",azureCloud:t.azureCloud||Tt(),tenantId:t.tenantId,clientId:t.clientId,clientSecret:_t(e)}}}(t)),[t]);return(0,i.jsxs)(i.Fragment,{children:[kt||(kt=(0,i.jsx)("h6",{children:"Azure Authentication"})),(0,i.jsx)(Pt,{managedIdentityEnabled:c.config.azure.managedIdentityEnabled,credentials:o,azureCloudOptions:yt,onCredentialsChange:e=>{a(function(e,t){switch(t.authType){case"msi":if(!c.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||Tt(),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:[Lt||(Lt=(0,i.jsx)("h6",{children:"Azure Configuration"})),(0,i.jsxs)("div",{className:"gf-form-group",children:[(0,i.jsx)(d.InlineFieldRow,{children:(0,i.jsx)(d.InlineField,{labelWidth:26,label:"Override AAD audience",children:(0,i.jsx)(d.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)(d.InlineFieldRow,{children:(0,i.jsx)(d.InlineField,{labelWidth:26,label:"Resource ID",children:(0,i.jsx)(d.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 Vt,Mt,$t,Ut=a(55324);function Xt(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)(d.InlineField,{label:"Internal link",labelWidth:24,children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(d.InlineSwitch,{value:s,"aria-label":Ut.wl.components.DataSource.Prometheus.configPage.internalLinkSwitch,onChange:e=>l(e.currentTarget.checked)}),(0,i.jsx)(d.Button,{variant:"destructive",title:"Remove link",icon:"times",onClick:e=>{e.preventDefault(),n()},className:O.css`
              margin-left: 8px;
            `})]})}),s?(0,i.jsx)(d.InlineField,{label:"Data source",labelWidth:24,tooltip:"The data source the exemplar is going to navigate to.",children:(0,i.jsx)(c.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)(d.InlineField,{label:"URL",labelWidth:24,tooltip:"The URL of the trace backend the user would go to see its trace.",children:(0,i.jsx)(d.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)(d.InlineField,{label:"URL Label",labelWidth:24,tooltip:"Use to override the button label on the exemplar traceID field.",children:(0,i.jsx)(d.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)(d.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)(d.Input,{placeholder:"traceID",spellCheck:!1,width:40,value:t.name,onChange:e=>a(Object.assign({},t,{name:e.currentTarget.value}))})})]})}function Bt(e){let{options:t,onChange:a}=e;return(0,i.jsxs)(i.Fragment,{children:[Vt||(Vt=(0,i.jsx)("h3",{className:"page-heading",children:"Exemplars"})),t&&t.map(((e,n)=>(0,i.jsx)(Xt,{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)(d.Button,{variant:"secondary","aria-label":Ut.wl.components.DataSource.Prometheus.configPage.exemplarsAddButton,className:O.css`
          margin-bottom: 10px;
        `,icon:"plus",onClick:e=>{e.preventDefault();const n=[...t||[],{name:"traceID"}];a(n)},children:"Add"})]})}const{Select:zt,Input:Wt,FormField:Kt}=d.LegacyForms,Gt=[{value:"POST",label:"POST"},{value:"GET",label:"GET"}],Jt=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)(Kt,{label:"Scrape interval",labelWidth:13,inputEl:(0,i.jsx)(Wt,{className:"width-6",value:a.jsonData.timeInterval,spellCheck:!1,placeholder:"15s",onChange:Yt("timeInterval",a,n),validationEvents:Ht}),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)(Kt,{label:"Query timeout",labelWidth:13,inputEl:(0,i.jsx)(Wt,{className:"width-6",value:a.jsonData.queryTimeout,onChange:Yt("queryTimeout",a,n),spellCheck:!1,placeholder:"60s",validationEvents:Ht}),tooltip:"Set the Prometheus query timeout."})})}),(0,i.jsxs)("div",{className:"gf-form",children:[Mt||(Mt=(0,i.jsx)(d.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)(zt,{"aria-label":"Select HTTP method",options:Gt,value:Gt.find((e=>e.value===a.jsonData.httpMethod)),onChange:Yt("httpMethod",a,n),width:7})]})]}),$t||($t=(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)(d.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)(d.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)(Kt,{label:"Custom query parameters",labelWidth:14,tooltip:"Add Custom parameters to all Prometheus or Thanos queries.",inputEl:(0,i.jsx)(Wt,{className:"width-25",value:a.jsonData.customQueryParameters,onChange:Yt("customQueryParameters",a,n),spellCheck:!1,placeholder:"Example: max_source_resolution=5m&timeout=10"})})})})]}),(0,i.jsx)(Bt,{options:a.jsonData.exemplarTraceIdDestinations,onChange:e=>(0,s.updateDatasourcePluginJsonDataOption)({onOptionsChange:n,options:a},"exemplarTraceIdDestinations",e)})]})},Ht={[d.EventsWithValidation.onBlur]:[(0,d.regexValidation)(/^$|^\d+(ms|[Mwdhmsy])$/,"Value is not valid, you can use number with time unit specifier: y, M, w, d, h, m, s")]},Zt=e=>e?e.hasOwnProperty("currentTarget")?e.currentTarget.value:e.value:"",Yt=(e,t,a)=>n=>{a(Object.assign({},t,{jsonData:Object.assign({},t.jsonData,{[e]:Zt(n)})}))};var ea;var ta,aa,na,sa=a(62566),ra=a.n(sa),ia=a(25341),la=a(41276),oa=a(87633),ca=a(2927),ua=a(18852),da=a(26422),ha=a(79978),ma=a(28788),pa=a(3163),ga=a(87569),va=a(74624),fa=a(39425),ba=a(33414),xa=a(26497),ya=a(23697),ja=a(46588);function Ta(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)(u.EditorRows,{children:[(0,i.jsx)(st,Object.assign({},e,{query:n,onChange:e=>{a(Object.assign({},t,{expr:e.expr}))}})),(0,i.jsx)(u.EditorRow,{children:(0,i.jsx)(u.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"," ",ta||(ta=(0,i.jsx)("code",{children:"$__interval"}))," and ",aa||(aa=(0,i.jsx)("code",{children:"$__rate_interval"}))," variables."]}),children:(0,i.jsx)(Q.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})})})]}),na||(na=(0,i.jsx)(u.Space,{v:.5})),(0,i.jsxs)(u.EditorRow,{children:[(0,i.jsx)(u.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)(d.Input,{type:"text",placeholder:"{{alertname}}",value:t.titleFormat,onChange:e=>{a(Object.assign({},t,{titleFormat:e.currentTarget.value}))}})}),(0,i.jsx)(u.EditorField,{label:"Tags",children:(0,i.jsx)(d.Input,{type:"text",placeholder:"label1,label2",value:t.tagKeys,onChange:e=>{a(Object.assign({},t,{tagKeys:e.currentTarget.value}))}})}),(0,i.jsx)(u.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)(d.Input,{type:"text",placeholder:"{{instance}}",value:t.textFormat,onChange:e=>{a(Object.assign({},t,{textFormat:e.currentTarget.value}))}})}),(0,i.jsx)(u.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)(u.EditorSwitch,{value:t.useValueForTime,onChange:e=>{a(Object.assign({},t,{useValueForTime:e.currentTarget.value}))}})})]})]})}var _a=a(26581);class Sa{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,ba.$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,ia.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,ne.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,ne.map)(t.data.data,(t=>t[e]||"")).filter((e=>""!==e));return(0,ne.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,ne.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,ne.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,ha.U)((e=>(0,ne.map)(e.data.data.result,(e=>{let t=e.metric.__name__||"";return delete e.metric.__name__,t+="{"+(0,ne.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,ne.map)(e.data.data,(e=>({text:s.datasource.getOriginalMetricName(e),expandable:!0})))))}}var Ca=a(81810);const wa=["__name__"];const Ia=/^[+-]?inf(?:inity)?$/i;function Ea(e,t,a){const[n,r]=(0,ne.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,ne.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=Fa({data:[],valueName:r}),l=Oa([]),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(ka(t));const n=null!==(a=e.fields[1].labels)&&void 0!==a?a:{};o.forEach((e=>e.values.add(Ra(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,ne.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=qa(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,ne.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=Na(Aa(d.sort(Pa))),p=h.map((e=>Object.assign({},e,{meta:Object.assign({},e.meta,{preferredVisualisationType:"graph"})})));return Object.assign({},e,{data:[...p,...i,...m,...u]})}function Da(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,Ca.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(Ca.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=qa(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:[Oa([n.result]),Fa({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=Oa([]),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=Fa({data:[],valueName:a});return e.forEach((e=>{j(e)?e.values.forEach((t=>{n.values.add(1e3*t[0]),r.forEach((t=>t.values.add(Ra(e.metric,t.name)))),i.values.add(ka(t[1]))})):(n.values.add(1e3*e.value[0]),r.forEach((t=>t.values.add(Ra(e.metric,t.name)))),i.values.add(ka(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,_a.W)((0,c.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,wa),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(j(e)){const s=t.step?1e3*t.step:NaN;let i=1e3*t.start;const l=[];for(const t of e.values){let e=ka(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(Oa(l,!0)),r.push(Fa({data:l,parseValue:!1,labels:n,displayNameFromDS:a}))}else r.push(Oa([e.value])),r.push(Fa({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?Na(Aa(o.sort(Pa))):o}function qa(e){const t=[];if(e.datasourceUid){var a;const n=(0,c.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 Ra(e,t){return e.hasOwnProperty(t)?"le"===t?ka(e[t]):e[t]:""}function Oa(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 Fa(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?ka(e[1]):e[1])))}}function Na(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.HeatmapRows}),fields:[t,...a]})]}function Aa(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 Pa(e,t){let a,n;try{var s,r;a=ka(null!==(s=e.name)&&void 0!==s?s:""),n=ka(null!==(r=t.name)&&void 0!==r?r:"")}catch(e){return console.error(e),0}return a>n?1:a<n?-1:0}function ka(e){return Ia.test(e)?"-"===e[0]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY:parseFloat(e)}var La,Qa,Va,Ma,$a,Ua=a(65687);class Xa extends s.StandardVariableSupport{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(0,c.getTemplateSrv)(),a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(0,ba.$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,la.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 Sa(this.datasource,n);return(0,Ua.D)(r.process()).pipe((0,ha.U)((e=>({data:e}))))}toDataQuery(e){return{refId:"PrometheusDatasource-VariableQuery",expr:e.query}}}function Ba(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const za=["api/v1/query","api/v1/query_range","api/v1/series","api/v1/labels"];class Wa extends c.DataSourceWithBackend{constructor(e){var t,a;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(0,xa.J)(),r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(0,ba.$t)(),i=arguments.length>3?arguments[3]:void 0;super(e),Ba(this,"type",void 0),Ba(this,"editorSrc",void 0),Ba(this,"ruleMappings",void 0),Ba(this,"url",void 0),Ba(this,"id",void 0),Ba(this,"directUrl",void 0),Ba(this,"access",void 0),Ba(this,"basicAuth",void 0),Ba(this,"withCredentials",void 0),Ba(this,"metricsNameCache",new(ra())({max:10})),Ba(this,"interval",void 0),Ba(this,"queryTimeout",void 0),Ba(this,"httpMethod",void 0),Ba(this,"languageProvider",void 0),Ba(this,"exemplarTraceIdDestinations",void 0),Ba(this,"lookupsDisabled",void 0),Ba(this,"customQueryParameters",void 0),Ba(this,"exemplarsAvailable",void 0),Ba(this,"subType",void 0),Ba(this,"rulerEnabled",void 0),Ba(this,"init",(async()=>{this.loadRules(),this.exemplarsAvailable=await this.areExemplarsAvailable()})),Ba(this,"prepareTargets",((e,t,a)=>{const n=[],r=[],i=(0,ne.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,ne.cloneDeep)(l);s.format="table",s.instant=!0,s.range=!1,s.valueWithRefId=!0,delete s.maxDataPoints,s.requestId+="_instant";const o=(0,ne.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,ne.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,ne.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,ne.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}})),Ba(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,va.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})),Ba(this,"processAnnotationResponse",((e,t)=>{const a=(0,c.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"),u=r.split(","),d=[];for(const t of a){const a=t.fields[0],s=t.fields[1],r=(null==s?void 0:s.labels)||{},c=Object.keys(r).filter((e=>u.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,_a.W)(i,r),tags:c,text:(0,_a.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=ya.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 E.ZP(this),this.lookupsDisabled=null!==(a=e.jsonData.disableMetricsLookup)&&void 0!==a&&a,this.customQueryParameters=new URLSearchParams(e.jsonData.customQueryParameters),this.variables=new Xa(this,this.templateSrv,this.timeSrv),this.exemplarsAvailable=!0,this.annotations={QueryEditor:Ta}}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,ne.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,c.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]:{},a=arguments.length>2?arguments[2]:void 0;if(za.some((t=>e.includes(t))))try{return await(0,ia.n)(this._request(`/api/datasources/${this.id}/resources${e}`,t,Object.assign({method:this.httpMethod,hideFromInspector:!0,showErrorAlert:!1},a)))}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,ia.n)(this._request(`/api/datasources/${this.id}/resources${e}`,t,Object.assign({method:"GET",hideFromInspector:!0},a)))}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 Ka(e);if("string"==typeof e)return Ga(e);const a=e.map((e=>Ga(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:x.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,ha.U)((t=>Ea(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,la.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,oa.z)((0,ma.b)((()=>n--)),(0,pa.h)((e=>!e.cancelled)),(0,ha.U)((t=>({data:Da(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,ca.T)(...r)}panelsQuery(e,t,a,n,r){const i=e.map(((n,s)=>{const i=t[s],l=(0,oa.z)((0,pa.h)((e=>!e.cancelled)),(0,ha.U)((t=>Da(t,{query:n,target:i,responseListLength:e.length,scopedVars:r,exemplarTraceIdDestinations:this.exemplarTraceIdDestinations}))));return this.runQuery(n,a,l)}));return(0,ua.D)(i).pipe((0,ha.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,ga.K)((()=>(0,la.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,ga.K)((t=>t.cancelled?(0,la.of)(t):(0,da._)(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,ga.K)((t=>t.cancelled?(0,la.of)(t):(0,da._)(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 Sa(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:x.timeSeriesQuery,refId:"X",datasource:this.getRef()};return await(0,ia.n)((0,c.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,ha.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,fa.W)({url:this.url,name:this.name,type:"prometheus"})}catch(e){return}}getBuildInfoMessage(e){var t,a;const n=La||(La=(0,i.jsx)(d.Badge,{color:"green",icon:"check",text:"Ruler API enabled"})),s=Qa||(Qa=(0,i.jsx)(d.Badge,{color:"orange",icon:"exclamation-triangle",text:"Ruler API not enabled"})),r=Va||(Va=(0,i.jsx)(d.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)(d.Badge,{color:"red",icon:"exclamation-triangle",text:"Ruler API not supported"})})})),l={[ya.T8.Lotex]:"/public/app/plugins/datasource/prometheus/img/cortex_logo.svg",[ya.T8.Mimir]:"/public/app/plugins/datasource/prometheus/img/mimir_logo.svg",[ya.T8.Prometheus]:"/public/app/plugins/datasource/prometheus/img/prometheus_logo.svg"},o={[ya.T8.Lotex]:"blue",[ya.T8.Mimir]:"orange",[ya.T8.Prometheus]:"red"},c={[ya.T8.Lotex]:"Cortex",[ya.T8.Mimir]:"Mimir",[ya.T8.Prometheus]:"Prometheus"},u=(0,i.jsx)(d.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:ya.T8.Prometheus]})," ",e.application?c[e.application]:"Unknown"]}),color:o[null!==(a=e.application)&&void 0!==a?a:ya.T8.Prometheus]});return(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"max-content max-content",rowGap:"0.5rem",columnGap:"2rem",marginTop:"1rem"},children:[Ma||(Ma=(0,i.jsx)("div",{children:"Type"})),(0,i.jsx)("div",{children:u}),(0,i.jsxs)(i.Fragment,{children:[$a||($a=(0,i.jsx)("div",{children:"Ruler API"})),e.application===ya.T8.Prometheus&&(0,i.jsx)("div",{children:r}),e.application!==ya.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,ia.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,ne.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",{},{showErrorAlert:!1})).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.metadataRequest("/api/v1/query_exemplars",{query:"test",start:(0,s.dateTime)().subtract(30,"minutes").valueOf().toString(),end:(0,s.dateTime)().valueOf().toString()},{showErrorAlert:!1})).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,ja.F)(n,t.key,t.value);break;case"ADD_FILTER_OUT":n=(0,ja.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,_e.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=Ka(s)),(0,ja.F)(e,a,s,n)}),e);return t}filterQuery(e){return!(e.hide||!e.expr)}applyTemplateVariables(e,t){const a=(0,ne.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 Ka(e){return"string"==typeof e?e.replace(/\\/g,"\\\\").replace(/'/g,"\\\\'"):e}function Ga(e){return"string"==typeof e?e.replace(/\\/g,"\\\\\\\\").replace(/[$^*{}\[\]\'+?.()|]/g,"\\\\$&"):e}const Ja=new s.DataSourcePlugin(Wa).setQueryEditor(gt).setConfigEditor((e=>{const{options:t,onOptionsChange:a}=e,n=(0,bt.Tc)(),s={azureAuthSupported:!!ft.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:St()})}}(e):function(e){return{jsonData:Object.assign({},e.jsonData,{azureAuth:void 0,azureCredentials:void 0,azureEndpointResourceId:void 0})}}(e),azureSettingsUI:Qt};return(0,i.jsxs)(i.Fragment,{children:["direct"===t.access&&(ea||(ea=(0,i.jsx)(d.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)(d.DataSourceHttpSettings,{defaultUrl:"http://localhost:9090",dataSourceConfig:t,showAccessOptions:!0,onChange:a,sigV4AuthToggleEnabled:ft.vc.sigV4AuthEnabled,azureAuthSettings:s,renderSigV4Editor:(0,i.jsx)(vt.SIGV4ConnectionConfig,Object.assign({},e))}),(0,i.jsx)(d.AlertingSettings,{alertmanagerDataSources:n,options:t,onOptionsChange:a}),(0,i.jsx)(Jt,{options:t,onOptionsChange:a})]})})).setQueryEditorHelp(o)},55704:(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:/[{};()`,.]/}},42935:(e,t,a)=>{var n,s=a(76687),r=(n=s)&&"object"==typeof n&&"default"in n?n.default:n,i=a(70534),l=a(19177),o=a(86832),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})))}},1181:(e,t,a)=>{"use strict";e.exports=a(42935)}}]);
//# sourceMappingURL=prometheusPlugin.69aa95568fb2a09ce12c.js.map