(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7004],{86980:(Qe,j,o)=>{"use strict";o.r(j),o.d(j,{plugin:()=>vl});var q=o(7238),e=o(68404);const J=[{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."}],w=a=>e.createElement("div",null,e.createElement("h2",null,"PromQL Cheat Sheet"),J.map((t,n)=>e.createElement("div",{className:"cheat-sheet-item",key:n},e.createElement("div",{className:"cheat-sheet-item__title"},t.title),t.expression?e.createElement("button",{type:"button",className:"cheat-sheet-item__example",onClick:r=>a.onClickExample({refId:"A",expr:t.expression})},e.createElement("code",null,t.expression)):null,e.createElement("div",{className:"cheat-sheet-item__label"},t.label))));var G=o(40400),ye=o(82897),Le=o(49922),ue=o(68183),A=o(26418),Ne=o(41818),Re=o(98102),_=o(31403),x=o(52423),ae=o(72648),Xe=o(35029),Be=o(2352),l=o(99822),p=o(4252),C=o(72948),N=o(45204),T=o(21899);const z=a=>{const{pattern:t,onPatternSelect:n,hasNewQueryOption:r,hasPreviousQuery:s,selectedPatternName:i,setSelectedPatternName:c}=a,b=(0,ae.wW)(M),m={grammar:T.ZP,name:"promql"};return e.createElement(C.Z,{className:b.card},e.createElement(C.Z.Heading,null,t.name),e.createElement("div",{className:b.rawQueryContainer},e.createElement(N.U,{"aria-label":`${t.name} raw query`,query:p.Z.renderQuery({labels:[],operations:t.operations,binaryQueries:t.binaryQueries}),lang:m,className:b.rawQuery})),e.createElement(C.Z.Actions,null,i!==t.name?e.createElement(_.zx,{size:"sm","aria-label":"use this query button",onClick:()=>{s?c(t.name):n(t)}},"Use this query"):e.createElement(e.Fragment,null,e.createElement("div",{className:b.spacing},`If you would like to use this query, ${r?"you can either apply this query pattern or create a new query":"this query pattern will be applied to your current query"}.`),e.createElement(_.zx,{size:"sm","aria-label":"back button",fill:"outline",onClick:()=>c(null)},"Back"),e.createElement(_.zx,{size:"sm","aria-label":"apply query starter button",onClick:()=>{n(t)}},"Apply query"),r&&e.createElement(_.zx,{size:"sm","aria-label":"create new query button",onClick:()=>{n(t,!0)}},"Create new query"))))},M=a=>({card:x.css`
      width: 49.5%;
      display: flex;
      flex-direction: column;
    `,rawQueryContainer:x.css`
      flex-grow: 1;
    `,rawQuery:x.css`
      background-color: ${a.colors.background.primary};
      padding: ${a.spacing(1)};
      margin-top: ${a.spacing(1)};
    `,spacing:x.css`
      margin-bottom: ${a.spacing(1)};
    `});var le=o(74852),B=o(62513);const Y=a=>{const{isOpen:t,onClose:n,onChange:r,onAddQuery:s,query:i,queries:c,app:b}=a,[m,h]=(0,e.useState)([]),[y,g]=(0,e.useState)(null),O=(0,ae.wW)(Z),u=!!s,E=(0,e.useMemo)(()=>{const S=(0,le._)(i.expr),F=S.query.operations.length>0,U=S.query.metric,P=S.query.labels.length>0,L=S.query.binaryQueries?S.query.binaryQueries.length>0:!1;return F||U||P||L},[i.expr]),Q=(S,F=!1)=>{const U=(0,le._)(F?"":i.expr);(0,Ne.ff)("grafana_prom_kickstart_your_query_selected",{app:b??"",editorMode:i.editorMode,selectedPattern:S.name,preSelectedOperationsCount:U.query.operations.length,preSelectedLabelsCount:U.query.labels.length,createNewQuery:u&&F}),U.query.operations=S.operations,U.query.binaryQueries=S.binaryQueries,u&&F?s({...i,refId:(0,l.Hs)(c??[i]),expr:p.Z.renderQuery(U.query)}):r({...i,expr:p.Z.renderQuery(U.query)}),g(null),n()};return e.createElement(Xe.u,{"aria-label":"Kick start your query modal",isOpen:t,title:"Kick start your query",onDismiss:n},e.createElement("div",{className:O.spacing},"Kick start your query by selecting one of these queries. You can then continue to complete your query."),Object.values(B.Fz).map(S=>e.createElement(Be.U,{"aria-label":`open and close ${S} query starter card`,key:S,label:`${(0,ye.capitalize)(S)} query starters`,isOpen:m.includes(S),collapsible:!0,onToggle:()=>h(F=>F.includes(S)?F.filter(U=>U!==S):[...F,S])},e.createElement("div",{className:O.cardsContainer},p.Z.getQueryPatterns().filter(F=>F.type===S).map(F=>e.createElement(z,{key:F.name,pattern:F,hasNewQueryOption:u,hasPreviousQuery:E,onPatternSelect:Q,selectedPatternName:y,setSelectedPatternName:g}))))),e.createElement(_.zx,{"aria-label":"close kick start your query modal",variant:"secondary",onClick:n},"Close"))},Z=a=>({cardsContainer:x.css`
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      justify-content: space-between;
    `,spacing:x.css`
      margin-bottom: ${a.spacing(1)};
    `});var ne=o(92611),pe=o(61458),ve=o(89290),re=o(58079),ce=o(58379),f=o(37462);const se="PrometheusQueryEditorModeDefault";function Ce(a,t,n){a.expr===""&&ce.Z.set(se,t),n({...a,editorMode:t})}function Se(a,t=re.c.Builder){if(a!=null&&a!=="")return re.c.Code;const n=ce.Z.get(se);switch(n){case re.c.Builder:case re.c.Code:return n;default:return t}}function Ke(a,t,n){let r=a;a.editorMode||(r={...a,editorMode:Se(a.expr,n)}),a.expr==null&&(r={...r,expr:"",legendFormat:f.pD.Auto}),a.range==null&&a.instant==null&&(r={...r,range:!0},t===G.zj.Explore&&(r.instant=!0));const s=a.instant&&a.range;return t===G.zj.UnifiedAlerting&&s&&(r={...r,instant:!1,range:!0}),r}var Ve=o(32557),k=o(35645),Bt=o(34719),He=o(36784),kt=o(58439),Wt=o(41285),Ut=o(19023),$t=o(73250),Kt=o(75765),Je=o(44812),Ht=o(99151),Ge=o.n(Ht),Ie=o(63134),te=o(53217),Jt=o(14677),Gt=o.n(Jt);const ut=" ",xe=1e3;function Zt({datasource:a,query:t,onChange:n,onGetMetrics:r,labelsFilters:s}){const i=(0,ae.wW)(Yt),[c,b]=(0,e.useState)({}),m=(0,e.useCallback)((u,E)=>{const Q=u.label??u.value;return Q?Q.toLowerCase?E.split(ut).reduce((F,U)=>F&&Q.toLowerCase().includes(U.toLowerCase()),!0):!0:!1},[]),h=(0,e.useCallback)((u,E)=>u.__isNew__?u.label:e.createElement(Gt(),{searchWords:E.inputValue.split(ut),textToHighlight:u.label??"",highlightClassName:i.highlight}),[i.highlight]),y=(u,E)=>{const Q=(0,Je.Vl)(u);return qt(Q,E)},g=u=>a.metricFindQuery(y(u,s)).then(Q=>(Q.length>xe&&Q.splice(0,Q.length-xe),Q.map(S=>({label:S.text,value:S.text})))),O=Ge()(u=>g(u),300);return e.createElement(A.EditorFieldGroup,null,e.createElement(A.EditorField,{label:"Metric"},e.createElement(te.qb,{inputId:"prometheus-metric-select",className:i.select,value:t.metric?(0,Ie.E)(t.metric):void 0,placeholder:"Select metric",allowCustomValue:!0,formatOptionLabel:h,filterOption:m,onOpenMenu:async()=>{b({isLoading:!0});const u=await r();u.length>xe&&u.splice(0,u.length-xe),b({metrics:u,isLoading:void 0})},loadOptions:O,isLoading:c.isLoading,defaultOptions:c.metrics,onChange:({value:u})=>{u&&n({...t,metric:u})}})))}const Yt=a=>({select:x.css`
    min-width: 125px;
  `,highlight:x.css`
    label: select__match-highlight;
    background: inherit;
    padding: inherit;
    color: ${a.colors.warning.contrastText};
    background-color: ${a.colors.warning.main};
  `}),qt=(a,t)=>{const n=t?_t(t):[];return`label_values({__name__=~".*${a}"${n?n.join(""):""}},__name__)`},_t=a=>a.map(t=>`,${t.label}="${t.value}"`);function ea({item:a,defaultOp:t,onChange:n,onDelete:r,onGetLabelNames:s,onGetLabelValues:i,invalidLabel:c,invalidValue:b,getLabelValuesAutofillSuggestions:m}){const[h,y]=(0,e.useState)({}),g=(E=a.op)=>dt.find(Q=>Q.label===E)?.isMultiValue,O=E=>E?E.indexOf("|")>0?E.split("|"):[E]:[],u=Ge()(E=>m(E,a.label),350);return e.createElement("div",{"data-testid":"prometheus-dimensions-filter-item"},e.createElement(A.InputGroup,null,e.createElement(te.Ph,{placeholder:"Select label","aria-label":ue.wl.components.QueryBuilder.labelSelect,inputId:"prometheus-dimensions-filter-item-key",width:"auto",value:a.label?(0,Ie.E)(a.label):null,allowCustomValue:!0,onOpenMenu:async()=>{y({isLoadingLabelNames:!0});const E=await s(a);y({labelNames:E,isLoadingLabelNames:void 0})},isLoading:h.isLoadingLabelNames??!1,options:h.labelNames,onChange:E=>{E.label&&n({...a,op:a.op??t,label:E.label})},invalid:c}),e.createElement(te.Ph,{"aria-label":ue.wl.components.QueryBuilder.matchOperatorSelect,className:"query-segment-operator",value:(0,Ie.E)(a.op??t),options:dt,width:"auto",onChange:E=>{E.value!=null&&n({...a,op:E.value,value:g(E.value)?a.value:O(a?.value)[0]})}}),e.createElement(te.qb,{placeholder:"Select value","aria-label":ue.wl.components.QueryBuilder.valueSelect,inputId:"prometheus-dimensions-filter-item-value",width:"auto",value:g()?O(a?.value).map(Ie.E):O(a?.value).map(Ie.E)[0],allowCustomValue:!0,onOpenMenu:async()=>{y({isLoadingLabelValues:!0});const E=await i(a);E.length>xe&&E.splice(0,E.length-xe),y({...h,labelValues:E,isLoadingLabelValues:void 0})},defaultOptions:h.labelValues,isMulti:g(),isLoading:h.isLoadingLabelValues,loadOptions:u,onChange:E=>{if(E.value)n({...a,value:E.value,op:a.op??t});else{const Q=E.map(S=>S.label).join("|");n({...a,value:Q,op:a.op??t})}},invalid:b}),e.createElement(A.AccessoryButton,{"aria-label":"remove",icon:"times",variant:"secondary",onClick:r})))}const dt=[{label:"=",value:"=",isMultiValue:!1},{label:"!=",value:"!=",isMultiValue:!1},{label:"<",value:"<",isMultiValue:!1},{label:">",value:">",isMultiValue:!1},{label:"=~",value:"=~",isMultiValue:!0},{label:"!~",value:"!~",isMultiValue:!0}],ta="Select at least 1 label filter (label and value)";function aa({labelsFilters:a,onChange:t,onGetLabelNames:n,onGetLabelValues:r,labelFilterRequired:s,getLabelValuesAutofillSuggestions:i}){const c="=",[b,m]=(0,e.useState)([{op:c}]);(0,e.useEffect)(()=>{a.length>0?m(a):m([{op:c}])},[a]);const h=g=>{m(g);const O=g.filter(u=>u.label!=null&&u.value!=null);(0,ye.isEqual)(O,a)||t(O)},y=b.some(g=>g.label&&g.value);return e.createElement(A.EditorFieldGroup,null,e.createElement(A.EditorField,{label:"Label filters",error:ta,invalid:s&&!y},e.createElement(A.EditorList,{items:b,onChange:h,renderItem:(g,O,u)=>e.createElement(ea,{item:g,defaultOp:c,onChange:O,onDelete:u,onGetLabelNames:n,onGetLabelValues:r,invalidLabel:s&&!g.label,invalidValue:s&&!g.value,getLabelValuesAutofillSuggestions:i})})))}var la=o(12398),na=o(67487),Te=o(46967),me=o(81764),Me=o(8944),Ze=o(77117),ra=o(39904);function sa({feedbackUrl:a}){const t=(0,ae.wW)(oa);return e.createElement(A.Stack,{gap:1},e.createElement("a",{href:a,className:t.link,title:"The Metric Encyclopedia is new, please let us know how we can improve it",target:"_blank",rel:"noreferrer noopener"},e.createElement(ra.J,{name:"comment-alt-message"})," Give feedback"))}function oa(a){return{link:(0,x.css)({color:a.colors.text.secondary,fontSize:a.typography.bodySmall.fontSize,":hover":{color:a.colors.text.link}})}}const ia=[{value:"counter",description:"A cumulative metric that represents a single monotonically increasing counter whose value can only increase or be reset to zero on restart."},{value:"gauge",description:"A metric that represents a single numerical value that can arbitrarily go up and down."},{value:"histogram",description:"A histogram samples observations (usually things like request durations or response sizes) and counts them in configurable buckets."},{value:"summary",description:"A summary samples observations (usually things like request durations and response sizes) and can calculate configurable quantiles over a sliding time window."}],Ae={browse:"Browse metric names by text",metadataSearchSwicth:"Browse by metadata type and description in addition to metric name",type:"Counter, gauge, histogram, or summary",variables:"Select a template variable for your metric",excludeNoMetadata:"Exclude results with no metadata when filtering",setUseBackend:"Use the backend to browse metrics and disable fuzzy search metadata browsing"},ca=10,ua=new la.Z({intraMode:1,intraIns:1,intraSub:1,intraTrn:1,intraDel:1});function da(a,t,n){const r=ua.filter(a,t);r&&n(r)}const mt=(0,ye.debounce)(da,300),ma=a=>{const{datasource:t,isOpen:n,onClose:r,onChange:s,query:i}=a,[c,b]=(0,e.useState)([]),[m,h]=(0,e.useState)(!0),[y,g]=(0,e.useState)([]),[O,u]=(0,e.useState)(!0),[E,Q]=(0,e.useState)([]),[S,F]=(0,e.useState)([]),[U,P]=(0,e.useState)([]),[L,oe]=(0,e.useState)(ca),[I,$]=(0,e.useState)(1),[K,R]=(0,e.useState)(""),[H,be]=(0,e.useState)([]),[ge,ie]=(0,e.useState)([]),[je,fl]=(0,e.useState)(!1),[st,bl]=(0,e.useState)(!1),[ze,El]=(0,e.useState)([]),[Fe,zt]=(0,e.useState)(null),[Qt,yl]=(0,e.useState)(0),[Rt,ot]=(0,e.useState)(),[we,Cl]=(0,e.useState)(!1),$e=(0,e.useCallback)(async()=>{h(!0),t.languageProvider.metricsMetadata||await t.languageProvider.loadMetricsMetadata(),t.languageProvider.metricsMetadata||(u(!1),t.languageProvider.metricsMetadata={});let d;if(i.labels.length>0){const W=p.Z.renderLabels(i.labels);d=(await t.languageProvider.getSeries(W,!0)).__name__??[]}else d=await t.languageProvider.getLabelValues("__name__")??[];let D=[],V=[],X=d.map(W=>{const de=(0,He.nW)(W,t.languageProvider.metricsMetadata),Ee=(0,He.ws)(W,t.languageProvider.metricsMetadata);return D.push(`${W} ${de} ${Ee}`),V.push(W),{value:W,type:de,description:Ee}});g(X),Q(D),F(V),b(t.getVariables().map(W=>({value:W,label:W}))),yl(X.length),ot(X.length),h(!1)},[i,t]);(0,e.useEffect)(()=>{$e()},[$e]);const ee=(0,ae.wW)(ha),Sl=ia.map(d=>({value:d.value,label:d.value,description:d.description}));function xl(d,D){if(!d.length)return[];const V=D===0?1:D,X=Math.floor(it(d).length/V)+1;return[...Array(X).keys()].map(W=>W+1)}function Dl(d,D,V){const X=V===0?1:V,W=D===1?0:(D-1)*X,de=W+X;return d.slice(W,de)}function wl(){return ze.length>0}function it(d,D){let V=d;return K&&(V=V.filter((X,W)=>we?!0:je?H.includes(W):ge.includes(W))),Fe&&!D&&(V=V.filter((X,W)=>[Fe,Fe.toLowerCase()].includes(X.value[0]))),ze.length>0&&!we&&(V=V.filter((X,W)=>{const de=ze.some(ct=>ct.value===X.type),Ee=!X.type;return de||Ee&&!st})),V}function Pl(d){const D=it(d).sort(pa(!0,wl()));return Rt!==D.length&&D.length!==0&&ot(D.length),Dl(D,I,L)}const Xt=(0,e.useMemo)(()=>Ge()(async d=>{h(!0);const D=(0,Je.Vl)(d),V=i.labels.map(Ee=>`,${Ee.label}="${Ee.value}"`),X=`label_values({__name__=~".*${D}"${i.labels?V.join():""}},__name__)`,de=await t.metricFindQuery(X).then(Ee=>Ee.map(ct=>({value:ct.text})));g(de),ot(de.length),h(!1)},300),[t,i.labels]);function Nl(){const d={A:0,B:0,C:0,D:0,E:0,F:0,G:0,H:0,I:0,J:0,K:0,L:0,M:0,N:0,O:0,P:0,Q:0,R:0,S:0,T:0,U:0,V:0,W:0,X:0,Y:0,Z:0};return it(y,!0).forEach((D,V)=>{const X=D.value[0].toUpperCase();ga.includes(X)&&!d[X]&&(d[X]+=1)}),Object.keys(d).map(D=>{const V=d[D]>0;function X(){zt(Fe===D?null:D),$(1)}const W=Fe===D?ee.selAlpha:"",de=V?ee.active:ee.gray;return e.createElement("span",{onClick:V?X:()=>{},className:`${W} ${de}`,key:D,"data-testid":"letter-"+D},D+" ")})}return e.createElement(Xe.u,{"data-testid":fe.metricModal,isOpen:n,title:"Browse Metrics",onDismiss:r,"aria-label":"Metric Encyclopedia"},e.createElement(sa,{feedbackUrl:"https://forms.gle/DEMAJHoAMpe3e54CA"}),e.createElement("div",{className:ee.spacing},"Browse ",Qt," metric",Qt>1?"s":""," by text, by type, alphabetically or select a variable.",m&&e.createElement("div",{className:ee.inlineSpinner},e.createElement(na.$,null))),i.labels.length>0&&e.createElement("div",{className:ee.spacing},e.createElement("i",null,"These metrics have been pre-filtered by labels chosen in the label filters.")),e.createElement("div",{className:"gf-form"},e.createElement(Te.I,{"data-testid":fe.searchMetric,placeholder:Ae.browse,value:K,autoFocus:!0,onInput:d=>{const D=d.currentTarget.value??"";R(D),we&&D===""?$e():we?Xt(D):je?mt(E,D,be):mt(S,D,ie),$(1)}}),O&&!we&&e.createElement(me._,{label:"",className:ee.labelColor,tooltip:e.createElement("div",null,Ae.metadataSearchSwicth)},e.createElement(Me.x,{"data-testid":fe.searchWithMetadata,showLabel:!0,value:je,onChange:()=>{fl(!je),$(1)}})),e.createElement(me._,{label:"",className:ee.labelColor,tooltip:e.createElement("div",null,Ae.setUseBackend)},e.createElement(Me.x,{"data-testid":fe.setUseBackend,showLabel:!0,value:we,onChange:()=>{const d=!we;Cl(d),d===!1?$e():K!==""&&Xt(K),$(1)}}))),O&&!we&&e.createElement(e.Fragment,null,e.createElement("div",{className:"gf-form"},e.createElement("h6",null,"Filter by Type")),e.createElement("div",{className:"gf-form"},e.createElement(te.NU,{"data-testid":fe.selectType,inputId:"my-select",options:Sl,value:ze,placeholder:Ae.type,onChange:d=>{El(d),$(1)}}),O&&e.createElement(me._,{label:"",className:ee.labelColor,tooltip:e.createElement("div",null,Ae.excludeNoMetadata)},e.createElement(Me.x,{showLabel:!0,value:st,onChange:()=>{bl(!st),$(1)}})))),e.createElement("div",{className:"gf-form"},e.createElement("h6",null,"Variables")),e.createElement("div",{className:"gf-form"},e.createElement(te.Ph,{inputId:"my-select",options:c,value:"",placeholder:Ae.variables,onChange:d=>{const D=d.value??"";s({...i,metric:D}),r()}})),e.createElement("h5",{className:`${ee.center} ${ee.topPadding}`},Rt," Results"),e.createElement("div",{className:`${ee.center} ${ee.bottomPadding}`},Nl()),y&&Pl(y).map((d,D)=>e.createElement(Be.U,{"aria-label":`open and close ${d.value} query starter card`,"data-testid":fe.metricCard,key:d.value,label:d.value,isOpen:U.includes(d.value),collapsible:!0,onToggle:()=>P(V=>V.includes(d.value)?V.filter(X=>X!==d.value):[...V,d.value])},e.createElement("div",{className:ee.cardsContainer},e.createElement(C.Z,{className:ee.card},e.createElement(C.Z.Description,null,d.description&&d.type?e.createElement(e.Fragment,null,"Type: ",e.createElement("span",{className:ee.metadata},d.type),e.createElement("br",null),"Description: ",e.createElement("span",{className:ee.metadata},d.description)):e.createElement("i",null,"No metadata available")),e.createElement(C.Z.Actions,null,e.createElement(_.zx,{size:"sm","aria-label":"use this metric button","data-testid":fe.useMetric,onClick:()=>{s({...i,metric:d.value}),(0,Ne.ff)("grafana_prom_metric_encycopedia_tracking",{metric:d.value,hasVariables:c.length>0,hasMetadata:O,totalMetricCount:y.length,fuzzySearchQuery:K,fullMetaSearch:je,selectedTypes:ze,letterSearch:Fe}),r()}},"Use this metric")))))),e.createElement("br",null),e.createElement("div",{className:"gf-form"},e.createElement(Ze.W,{width:20,className:"query-keyword"},"Select Page"),e.createElement(te.Ph,{"data-testid":fe.searchPage,options:xl(y,L).map(d=>({value:d,label:""+d})),value:I??1,placeholder:"select page",onChange:d=>{const D=d.value??1;$(D)}}),e.createElement(Ze.W,{width:20,className:"query-keyword"},"# results per page"),e.createElement(Te.I,{"data-testid":fe.resultsPerPage,value:L??10,placeholder:"results per page",onInput:d=>{const D=+d.currentTarget.value;isNaN(D)||oe(D)}})),e.createElement("br",null),e.createElement(_.zx,{"aria-label":"close metric encyclopedia modal",variant:"secondary",onClick:r},"Close"))};function pa(a,t){return function(n,r){if(n.value===r.value)return 0;if(t){if(n.type===void 0)return 1;if(r.type===void 0)return-1}return a?n.value<r.value?-1:1:n.value<r.value?1:-1}}const ha=a=>({cardsContainer:x.css`
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      justify-content: space-between;
    `,spacing:x.css`
      margin-bottom: ${a.spacing(1)};
    `,center:x.css`
      text-align: center;
      padding: 4px;
      width: 100%;
    `,topPadding:x.css`
      padding: 10px 0 0 0;
    `,bottomPadding:x.css`
      padding: 0 0 4px 0;
    `,card:x.css`
      width: 100%;
      display: flex;
      flex-direction: column;
    `,selAlpha:x.css`
      font-style: italic;
      cursor: pointer;
      color: #6e9fff;
    `,active:x.css`
      cursor: pointer;
    `,gray:x.css`
      color: grey;
    `,metadata:x.css`
      color: rgb(204, 204, 220);
    `,labelColor:x.css`
      color: #6e9fff;
    `,inlineSpinner:x.css`
      display: inline-block;
    `}),fe={metricModal:"metric-modal",searchMetric:"search-metric",searchWithMetadata:"search-with-metadata",selectType:"select-type",metricCard:"metric-card",useMetric:"use-metric",searchPage:"search-page",resultsPerPage:"results-per-page",setUseBackend:"set-use-backend"},ga=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];var Ye=o(68668),pt=o(8180),va=o(12530);const ht=e.memo(a=>{const{nestedQuery:t,index:n,datasource:r,onChange:s,onRemove:i,onRunQuery:c,showExplain:b}=a,m=(0,ae.wW)(ba);return e.createElement("div",{className:m.card},e.createElement("div",{className:m.header},e.createElement("div",{className:m.name},"Operator"),e.createElement(te.Ph,{width:"auto",options:fa,value:(0,Ie.E)(t.operator),onChange:h=>{s(n,{...t,operator:h.value})}}),e.createElement("div",{className:m.name},"Vector matches"),e.createElement("div",{className:m.vectorMatchWrapper},e.createElement(te.Ph,{width:"auto",value:t.vectorMatchesType||"on",allowCustomValue:!0,options:[{value:"on",label:"on"},{value:"ignoring",label:"ignoring"}],onChange:h=>{s(n,{...t,vectorMatchesType:h.value})}}),e.createElement(Ye.H,{className:m.vectorMatchInput,minWidth:20,defaultValue:t.vectorMatches,onCommitChange:h=>{s(n,{...t,vectorMatches:h.currentTarget.value,vectorMatchesType:t.vectorMatchesType||"on"})}})),e.createElement(A.FlexItem,{grow:1}),e.createElement(pt.h,{name:"times",size:"sm",onClick:()=>i(n)})),e.createElement("div",{className:m.body},e.createElement(A.EditorRows,null,e.createElement(qe,{showExplain:b,query:t.query,datasource:r,onRunQuery:c,onChange:h=>{s(n,{...t,query:h})}}))))}),fa=va.iQ.map(a=>({label:a.sign,value:a.sign}));ht.displayName="NestedQuery";const ba=a=>({card:(0,x.css)({label:"card",display:"flex",flexDirection:"column",gap:a.spacing(.5)}),header:(0,x.css)({label:"header",padding:a.spacing(.5,.5,.5,1),gap:a.spacing(1),display:"flex",alignItems:"center"}),name:(0,x.css)({label:"name",whiteSpace:"nowrap"}),body:(0,x.css)({label:"body",paddingLeft:a.spacing(2)}),vectorMatchInput:(0,x.css)({label:"vectorMatchInput",marginLeft:-1}),vectorMatchWrapper:(0,x.css)({label:"vectorMatchWrapper",display:"flex"})});function Ea(a){const{query:t,datasource:n,onChange:r,onRunQuery:s,showExplain:i}=a,c=t.binaryQueries??[],b=(h,y)=>{const g=[...c];g.splice(h,1,y),r({...t,binaryQueries:g})},m=h=>{const y=[...c.slice(0,h),...c.slice(h+1)];r({...t,binaryQueries:y})};return e.createElement(A.Stack,{direction:"column",gap:1},c.map((h,y)=>e.createElement(ht,{key:y.toString(),nestedQuery:h,index:y,onChange:b,datasource:n,onRemove:m,onRunQuery:s,showExplain:i})))}var ya=o(37285);const qe=e.memo(a=>{const{datasource:t,query:n,onChange:r,onRunQuery:s,data:i,showExplain:c}=a,[b,m]=(0,e.useState)(),[h,y]=(0,e.useState)(!1),g=I=>{r({...n,labels:I})},O=(0,ae.wW)(Sa),u=(0,e.useCallback)(async I=>{const $=t.getVariables(),K=await I;return[...$.map(R=>({label:R,value:R})),...K.map(R=>({label:R.value,value:R.value,title:R.description}))]},[t]),E=async I=>{if(!n.metric)return await t.languageProvider.fetchLabels(),t.languageProvider.getLabelKeys().map(H=>({value:H}));const $=n.labels.filter(H=>H!==I);$.push({label:"__name__",op:"=",value:n.metric});const K=p.Z.renderLabels($);let R;return t.hasLabelsMatchAPISupport()?R=await t.languageProvider.fetchSeriesLabelsMatch(K):R=await t.languageProvider.fetchSeriesLabels(K),Object.keys(R).filter(H=>!$.find(be=>be.label===H)).map(H=>({value:H}))},Q=(I,$)=>{const K={label:$??"__name__",op:"=~",value:(0,Je.Vl)(`.*${I}`)},R=n.labels.filter(ie=>ie.label!==K.label);R.push(K),n.metric&&R.push({label:"__name__",op:"=",value:n.metric});const H=R.map(ie=>({...ie,label:t.interpolateString(ie.label),value:t.interpolateString(ie.value)})),be=p.Z.renderLabels(H);let ge;return t.hasLabelsMatchAPISupport()?ge=F(K,be):ge=S(K,be),ge.then(ie=>(ie.length>xe&&ie.splice(0,ie.length-xe),ie))},S=(I,$)=>{if(!I.label)return Promise.resolve([]);const K=t.languageProvider.fetchSeries($),R=t.interpolateString(I.label);return K.then(H=>{const be=new Set;return H.forEach(ge=>{const ie=ge[R];be.add(ie)}),Array.from(be).map(ge=>({label:ge,value:ge}))})},F=(I,$)=>I.label?t.languageProvider.fetchSeriesValuesWithMatch(I.label,$).then(K=>K.map(R=>({value:R,label:R}))):Promise.resolve([]),U=async I=>{if(!I.label)return[];if(!n.metric)return(await t.languageProvider.getLabelValues(I.label)).map(H=>({value:H}));const $=n.labels.filter(H=>H!==I);$.push({label:"__name__",op:"=",value:n.metric});const K=$.map(H=>({...H,label:t.interpolateString(H.label),value:t.interpolateString(H.value)})),R=p.Z.renderLabels(K);return t.hasLabelsMatchAPISupport()?F(I,R):S(I,R)},P=(0,e.useCallback)(()=>u(Ca(t,n)),[t,n,u]),L={grammar:T.ZP,name:"promql"},oe=k.v.featureToggles.prometheusMetricEncyclopedia;return e.createElement(e.Fragment,null,e.createElement(A.EditorRow,null,oe?e.createElement(e.Fragment,null,e.createElement(_.zx,{className:O.button,variant:"secondary",size:"sm",onClick:()=>y(I=>!I)},"Metric Encyclopedia"),n.metric&&e.createElement(Bt.V,{name:n.metric,color:"#3D71D9",onClick:()=>{r({...n,metric:""})},title:"Click to remove metric",className:O.metricTag}),h&&e.createElement(ma,{datasource:t,isOpen:h,onClose:()=>y(!1),query:n,onChange:r})):e.createElement(Zt,{query:n,onChange:r,onGetMetrics:P,datasource:t,labelsFilters:n.labels}),e.createElement(aa,{getLabelValuesAutofillSuggestions:Q,labelsFilters:n.labels,onChange:g,onGetLabelNames:I=>u(E(I)),onGetLabelValues:I=>u(U(I))})),c&&e.createElement(kt.B,{stepNumber:1,title:e.createElement(N.U,{query:`${n.metric} ${p.Z.renderLabels(n.labels)}`,lang:L})},ya.A),e.createElement($t.B,null,e.createElement(Wt.P,{queryModeller:p.Z,datasource:t,query:n,onChange:r,onRunQuery:s,highlightedOp:b}),e.createElement(Kt.L,{datasource:t,query:n,onChange:r,data:i,queryModeller:p.Z,buildVisualQueryFromString:le._})),c&&e.createElement(Ut.V,{lang:L,query:n,stepNumber:2,queryModeller:p.Z,onMouseEnter:I=>m(I),onMouseLeave:()=>m(void 0)}),n.binaryQueries&&n.binaryQueries.length>0&&e.createElement(Ea,{query:n,datasource:t,onChange:r,onRunQuery:s,showExplain:c}))});async function Ca(a,t){a.languageProvider.metricsMetadata||await a.languageProvider.loadMetricsMetadata(),a.languageProvider.metricsMetadata||(a.languageProvider.metricsMetadata={});let n;if(t.labels.length>0){const r=p.Z.renderLabels(t.labels);n=(await a.languageProvider.getSeries(r,!0)).__name__??[]}else n=await a.languageProvider.getLabelValues("__name__")??[];return n.map(r=>({value:r,description:(0,He.UQ)(r,a.languageProvider.metricsMetadata)}))}qe.displayName="PromQueryBuilder";const Sa=a=>({button:x.css`
      height: auto;
    `,metricTag:x.css`
      margin: '10px 0 10px 0',
      backgroundColor: '#3D71D9',
    `});function xa({query:a}){return a?e.createElement(A.EditorRow,null,e.createElement(A.EditorFieldGroup,null,e.createElement(N.U,{query:a,lang:{grammar:T.ZP,name:"promql"}}))):null}function Da(a){const{query:t,onChange:n,onRunQuery:r,datasource:s,data:i,showExplain:c}=a,[b,m]=(0,e.useReducer)(gt.reducer,{expr:t.expr});(0,e.useEffect)(()=>{m(Pa(t.expr))},[t.expr]);const h=y=>{const g=p.Z.renderQuery(y);m(wa({visQuery:y,expr:g})),n({...a.query,expr:g})};return b.visQuery?e.createElement(e.Fragment,null,e.createElement(qe,{query:b.visQuery,datasource:s,onChange:h,onRunQuery:r,data:i,showExplain:c}),e.createElement(xa,{query:t.expr})):null}const gt=(0,Ve.oM)({name:"prom-builder-container",initialState:{expr:""},reducers:{visualQueryChange:(a,t)=>{a.expr=t.payload.expr,a.visQuery=t.payload.visQuery},exprChanged:(a,t)=>{if(!a.visQuery||a.expr!==t.payload){a.expr=t.payload;const n=(0,le._)(t.payload);a.visQuery=n.query}}}}),{visualQueryChange:wa,exprChanged:Pa}=gt.actions;var vt=o(2594),ft=o(54291),he=o(19426),Na=o(61860);function Ia({datasource:a,onChange:t,query:n,...r}){const[s,i]=(0,e.useState)(null),c=(0,ae.wW)(Ta),b=(0,ft.Z)(s);(0,e.useEffect)(()=>{a.exemplarsAvailable?n.instant&&!n.range?(i("Exemplars are not available for instant queries"),t(!1)):(i(null),b&&!s&&t(!0)):(i("Exemplars for this query are not available"),t(!1))},[a.exemplarsAvailable,n.instant,n.range,t,b,s]);const m=(0,x.cx)({[c.activeIcon]:!!n.exemplar},c.eyeIcon);return e.createElement(Ze.W,{width:"auto","data-testid":r["data-testid"]},e.createElement(Na.u,{content:s??""},e.createElement("div",{className:c.iconWrapper},"Exemplars",e.createElement(pt.h,{name:"eye",tooltip:n.exemplar?"Disable query with exemplars":"Enable query with exemplars",disabled:!!s,className:m,onClick:()=>{t(!n.exemplar)}}))))}function Ta(a){return{eyeIcon:x.css`
      margin-left: ${a.spacing(2)};
    `,activeIcon:x.css`
      color: ${a.colors.primary.main};
    `,iconWrapper:x.css`
      display: flex;
      align-items: center;
    `}}const Ma=(0,e.memo)(({query:a,datasource:t,onChange:n,onRunQuery:r})=>{const s=bt(!0),i=(0,ft.Z)(a),c=(0,e.useCallback)(g=>{(!(0,ye.isEqual)(a,i)||g!==a.exemplar)&&n({...a,exemplar:g})},[i,a,n]);function b(g){n({...a,interval:g})}function m(g){g.currentTarget.value!==a.interval&&b(g.currentTarget.value)}function h(g){g.key==="Enter"&&g.shiftKey&&r()}const y=Et(a,n);return e.createElement("div",{"aria-label":"Prometheus extra field",className:"gf-form-inline","data-testid":_e.extraFieldEditor},e.createElement("div",{"data-testid":_e.queryTypeField,className:(0,x.cx)("gf-form explore-input-margin",x.css`
              flex-wrap: nowrap;
            `),"aria-label":"Query type field"},e.createElement(he.c,{width:"auto"},"Query type"),e.createElement(vt.S,{options:s,value:a.range&&a.instant?"both":a.instant?"instant":"range",onChange:y})),e.createElement("div",{"data-testid":_e.stepField,className:(0,x.cx)("gf-form",x.css`
              flex-wrap: nowrap;
            `),"aria-label":"Step field"},e.createElement(he.c,{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)"},"Min step"),e.createElement("input",{type:"text",className:"gf-form-input width-4",placeholder:"auto",onChange:m,onKeyDown:h,value:a.interval??""})),e.createElement(Ia,{onChange:c,datasource:t,query:a}))});Ma.displayName="PromExploreExtraField";function bt(a){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 a&&t.push({value:"both",label:"Both",description:"Run an Instant query and a Range query"}),t}function Et(a,t){return n=>{t(n==="instant"?{...a,instant:!0,range:!1,exemplar:!1}:n==="range"?{...a,instant:!1,range:!0}:{...a,instant:!0,range:!0})}}const _e={extraFieldEditor:"prom-editor-extra-field",stepField:"prom-editor-extra-field-step",queryTypeField:"prom-editor-extra-field-query-type"};var Aa=o(38435);const et=[{label:"Auto",value:f.pD.Auto,description:"Only includes unique labels"},{label:"Verbose",value:f.pD.Verbose,description:"All label names and values"},{label:"Custom",value:f.pD.Custom,description:"Provide a naming template"}],yt=e.memo(({legendFormat:a,onChange:t,onRunQuery:n})=>{const r=Ct(a),s=(0,e.useRef)(null),i=b=>{let m=b.currentTarget.value;m.length===0&&(m=f.pD.Auto),m!==a&&(t(m),n())},c=b=>{switch(b.value){case f.pD.Auto:t(f.pD.Auto);break;case f.pD.Custom:t("{{label_name}}"),setTimeout(()=>{s.current?.focus(),s.current?.setSelectionRange(2,12,"forward")},10);break;case f.pD.Verbose:t("");break}n()};return e.createElement(A.EditorField,{label:"Legend",tooltip:"Series name override or template. Ex. {{hostname}} will be replaced with label value for hostname."},e.createElement(e.Fragment,null,r===f.pD.Custom&&e.createElement(Ye.H,{id:"legendFormat",minWidth:22,placeholder:"auto",defaultValue:a,onCommitChange:i,ref:s}),r!==f.pD.Custom&&e.createElement(te.Ph,{inputId:"legend.mode",isSearchable:!1,placeholder:"Select legend mode",options:et,width:22,onChange:c,value:et.find(b=>b.value===r)})))});yt.displayName="PromQueryLegendEditor";function Ct(a){return a===f.pD.Auto?f.pD.Auto:a==null||a===""?f.pD.Verbose:f.pD.Custom}function Oa(a){const t=Ct(a);return t!==f.pD.Custom?et.find(n=>n.value===t)?.label:a}const St=e.memo(({query:a,app:t,onChange:n,onRunQuery:r})=>{const s=u=>{n({...a,format:u.value}),r()},i=u=>{n({...a,interval:u.currentTarget.value}),r()},c=bt(t===G.zj.Explore||t===G.zj.PanelEditor),b=Et(a,n),m=u=>{const E=u.currentTarget.checked;n({...a,exemplar:E}),r()},h=u=>{n({...a,intervalFactor:u.value}),r()},y=tt.find(u=>u.value===a.format)||tt[0],g=Fa(a),O=c.find(u=>u.value===g).label;return e.createElement(A.EditorRow,null,e.createElement(Aa.d,{title:"Options",collapsedInfo:La(a,y.label,O,t)},e.createElement(yt,{legendFormat:a.legendFormat,onChange:u=>n({...a,legendFormat:u}),onRunQuery:r}),e.createElement(A.EditorField,{label:"Min step",tooltip:e.createElement(e.Fragment,null,"An additional lower limit for the step parameter of the Prometheus query and for the"," ",e.createElement("code",null,"$__interval")," and ",e.createElement("code",null,"$__rate_interval")," variables.")},e.createElement(Ye.H,{type:"text","aria-label":"Set lower limit for the step parameter",placeholder:"auto",minWidth:10,onCommitChange:i,defaultValue:a.interval})),e.createElement(A.EditorField,{label:"Format"},e.createElement(te.Ph,{value:y,allowCustomValue:!0,onChange:s,options:tt})),e.createElement(A.EditorField,{label:"Type"},e.createElement(vt.S,{options:c,value:g,onChange:b})),xt(a,t)&&e.createElement(A.EditorField,{label:"Exemplars"},e.createElement(A.EditorSwitch,{value:a.exemplar||!1,onChange:m})),a.intervalFactor&&a.intervalFactor>1&&e.createElement(A.EditorField,{label:"Resolution"},e.createElement(te.Ph,{"aria-label":"Select resolution",isSearchable:!1,options:Dt,onChange:h,value:Dt.find(u=>u.value===a.intervalFactor)}))))});function xt(a,t){return!(t===G.zj.UnifiedAlerting||!a.range)}function Fa(a){return a.range&&a.instant?"both":a.instant?"instant":"range"}function La(a,t,n,r){const s=[];return s.push(`Legend: ${Oa(a.legendFormat)}`),s.push(`Format: ${t}`),s.push(`Step: ${a.interval??"auto"}`),s.push(`Type: ${n}`),xt(a,r)&&(a.exemplar?s.push("Exemplars: true"):s.push("Exemplars: false")),s}St.displayName="PromQueryBuilderOptions";var Va=o(79969);const tt=[{label:"Time series",value:"time_series"},{label:"Table",value:"table"},{label:"Heatmap",value:"heatmap"}],Dt=(0,ye.map)([1,2,3,4,5,10],a=>({value:a,label:"1/"+a})),wt=e.memo(a=>{const{onChange:t,onRunQuery:n,data:r,app:s,onAddQuery:i,datasource:{defaultEditor:c},queries:b}=a,[m,h]=(0,e.useState)(!1),[y,g]=(0,e.useState)(!1),[O,u]=(0,e.useState)(!1),{flag:E,setFlag:Q}=(0,ve.P5)(ve.ar),S=Ke(a.query,s,c),F=S.editorMode,U=(0,e.useCallback)(oe=>{if((0,Ne.ff)("user_grafana_prometheus_editor_mode_clicked",{newEditor:oe,previousEditor:S.editorMode??"",newQuery:!S.expr,app:s??""}),oe===re.c.Builder&&(0,le._)(S.expr||"").errors.length){h(!0);return}Ce(S,oe,t)},[t,S,s]);(0,e.useEffect)(()=>{u(!1)},[r]);const P=oe=>{u(!0),t(oe)},L=oe=>{Q(oe.currentTarget.checked)};return e.createElement(e.Fragment,null,e.createElement(Re.s,{isOpen:m,title:"Query parsing",body:"There were errors while trying to parse the query. Continuing to visual builder may lose some parts of the query.",confirmText:"Continue",onConfirm:()=>{Ce(S,re.c.Builder,t),h(!1)},onDismiss:()=>h(!1)}),e.createElement(Y,{isOpen:y,onClose:()=>g(!1),query:S,queries:b,app:s,onChange:t,onAddQuery:i}),e.createElement(A.EditorHeader,null,e.createElement(_.zx,{"aria-label":ue.wl.components.QueryBuilder.queryPatterns,variant:"secondary",size:"sm",onClick:()=>g(oe=>!oe)},"Kick start your query"),e.createElement(pe.n,{label:"Explain",value:E,onChange:L}),e.createElement(A.FlexItem,{grow:1}),s!==G.zj.Explore&&s!==G.zj.Correlations&&e.createElement(_.zx,{variant:O?"primary":"secondary",size:"sm",onClick:n,icon:r?.state===Le.Gu.Loading?"fa fa-spinner":void 0,disabled:r?.state===Le.Gu.Loading},"Run queries"),e.createElement(ne.k,{mode:F,onChange:U})),e.createElement(A.Space,{v:.5}),e.createElement(A.EditorRows,null,F===re.c.Code&&e.createElement(Va.j,{...a,query:S,showExplain:E}),F===re.c.Builder&&e.createElement(Da,{query:S,datasource:a.datasource,onChange:P,onRunQuery:a.onRunQuery,data:r,showExplain:E}),e.createElement(St,{query:S,app:a.app,onChange:t,onRunQuery:n})))});wt.displayName="PromQueryEditorSelector";var ja=o(362);function za(a){const{datasource:t,query:n,range:r,data:s,onChange:i,onRunQuery:c}=a;return e.createElement(ja.ZP,{datasource:t,query:n,onRunQuery:c,onChange:i,history:[],range:r,data:s,"data-testid":Qa.editor})}const Qa={editor:"prom-editor-cloud-alerting"};function Ra(a){const{app:t}=a;switch(t){case G.zj.CloudAlerting:return e.createElement(za,{...a});default:return e.createElement(wt,{...a})}}const Xa=(0,e.memo)(Ra);var Ba=o(37308),ka=o(45253),Wa=o(12006),Ua=o(12580),$a=o(64260),at=o(47694),Pt=o(11543),Nt=(a=>(a.Public="AzureCloud",a.China="AzureChinaCloud",a.USGovernment="AzureUSGovernment",a.None="",a))(Nt||{});const Ka=[{value:"AzureCloud",label:"Azure"},{value:"AzureChinaCloud",label:"Azure China"},{value:"AzureUSGovernment",label:"Azure US Government"}];function Ha(a){switch(a.authType){case"msi":return!0;case"clientsecret":return!!(a.azureCloud&&a.tenantId&&a.clientId&&a.clientSecret)}}const Ja=Symbol("Concealed client secret");function ke(){return k.v.azure.cloud||Nt.Public}function Ga(a){if(a.secureJsonFields.azureClientSecret)return Ja;{const t=a.secureJsonData?.azureClientSecret;return typeof t=="string"&&t.length>0?t:void 0}}function Za(a){return!!a.jsonData.azureCredentials}function It(){return k.v.azure.managedIdentityEnabled?{authType:"msi"}:{authType:"clientsecret",azureCloud:ke()}}function Ya(a){const t=a.jsonData.azureCredentials;if(!t)return It();switch(t.authType){case"msi":return k.v.azure.managedIdentityEnabled?{authType:"msi"}:{authType:"clientsecret",azureCloud:ke()};case"clientsecret":return{authType:"clientsecret",azureCloud:t.azureCloud||ke(),tenantId:t.tenantId,clientId:t.clientId,clientSecret:Ga(a)}}}function qa(a,t){switch(t.authType){case"msi":if(!k.v.azure.managedIdentityEnabled)throw new Error("Managed Identity authentication is not enabled in Grafana config.");return a={...a,jsonData:{...a.jsonData,azureCredentials:{authType:"msi"}}},a;case"clientsecret":return a={...a,jsonData:{...a.jsonData,azureCredentials:{authType:"clientsecret",azureCloud:t.azureCloud||ke(),tenantId:t.tenantId,clientId:t.clientId}},secureJsonData:{...a.secureJsonData,azureClientSecret:typeof t.clientSecret=="string"&&t.clientSecret.length>0?t.clientSecret:void 0},secureJsonFields:{...a.secureJsonFields,azureClientSecret:typeof t.clientSecret=="symbol"}},a}}function _a(a){return{jsonData:{...a.jsonData,azureCredentials:It()}}}function el(a){return{jsonData:{...a.jsonData,azureAuth:void 0,azureCredentials:void 0,azureEndpointResourceId:void 0}}}var We=o(50869),lt=o(29418);const Tt=[{value:"msi",label:"Managed Identity"},{value:"clientsecret",label:"App Registration"}],tl=a=>{const{credentials:t,azureCloudOptions:n,onCredentialsChange:r,getSubscriptions:s,disabled:i}=a,c=Ha(t),[b,m]=(0,e.useState)([]),[h,y]=(0,e.useReducer)(P=>P+1,0);(0,e.useEffect)(()=>{if(!s||!c){g([]);return}let P=!1;return s().then(L=>{P||g(L,h)}),()=>{P=!0}},[h]);const g=(P,L=!1)=>{m(P),s&&(L&&!t.defaultSubscriptionId&&P.length>0?U(P[0]):t.defaultSubscriptionId&&(P.find(I=>I.value===t.defaultSubscriptionId)||U(void 0)))},O=P=>{if(r){m([]);const L={...t,authType:P.value||"msi",defaultSubscriptionId:void 0};r(L)}},u=P=>{if(r&&t.authType==="clientsecret"){m([]);const L={...t,azureCloud:P.value,defaultSubscriptionId:void 0};r(L)}},E=P=>{if(r&&t.authType==="clientsecret"){m([]);const L={...t,tenantId:P.target.value,defaultSubscriptionId:void 0};r(L)}},Q=P=>{if(r&&t.authType==="clientsecret"){m([]);const L={...t,clientId:P.target.value,defaultSubscriptionId:void 0};r(L)}},S=P=>{if(r&&t.authType==="clientsecret"){m([]);const L={...t,clientSecret:P.target.value,defaultSubscriptionId:void 0};r(L)}},F=()=>{if(r&&t.authType==="clientsecret"){m([]);const P={...t,clientSecret:"",defaultSubscriptionId:void 0};r(P)}},U=P=>{if(r){const L={...t,defaultSubscriptionId:P?.value};r(L)}};return e.createElement("div",{className:"gf-form-group"},a.managedIdentityEnabled&&e.createElement("div",{className:"gf-form-inline"},e.createElement("div",{className:"gf-form"},e.createElement(he.c,{className:"width-12",tooltip:"Choose the type of authentication to Azure services"},"Authentication"),e.createElement(lt.Ph,{className:"width-15",value:Tt.find(P=>P.value===t.authType),options:Tt,onChange:O,isDisabled:i}))),t.authType==="clientsecret"&&e.createElement(e.Fragment,null,n&&e.createElement("div",{className:"gf-form-inline"},e.createElement("div",{className:"gf-form"},e.createElement(he.c,{className:"width-12",tooltip:"Choose an Azure Cloud"},"Azure Cloud"),e.createElement(lt.Ph,{className:"width-15",value:n.find(P=>P.value===t.azureCloud),options:n,onChange:u,isDisabled:i}))),e.createElement("div",{className:"gf-form-inline"},e.createElement("div",{className:"gf-form"},e.createElement(he.c,{className:"width-12"},"Directory (tenant) ID"),e.createElement("div",{className:"width-15"},e.createElement(We.I,{className:"width-30",placeholder:"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",value:t.tenantId||"",onChange:E,disabled:i})))),e.createElement("div",{className:"gf-form-inline"},e.createElement("div",{className:"gf-form"},e.createElement(he.c,{className:"width-12"},"Application (client) ID"),e.createElement("div",{className:"width-15"},e.createElement(We.I,{className:"width-30",placeholder:"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",value:t.clientId||"",onChange:Q,disabled:i})))),typeof t.clientSecret=="symbol"?e.createElement("div",{className:"gf-form-inline"},e.createElement("div",{className:"gf-form"},e.createElement(he.c,{htmlFor:"azure-client-secret",className:"width-12"},"Client Secret"),e.createElement(We.I,{id:"azure-client-secret",className:"width-25",placeholder:"configured",disabled:!0})),!i&&e.createElement("div",{className:"gf-form"},e.createElement("div",{className:"max-width-30 gf-form-inline"},e.createElement(_.zx,{variant:"secondary",type:"button",onClick:F},"reset")))):e.createElement("div",{className:"gf-form-inline"},e.createElement("div",{className:"gf-form"},e.createElement(he.c,{className:"width-12"},"Client Secret"),e.createElement("div",{className:"width-15"},e.createElement(We.I,{className:"width-30",placeholder:"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",value:t.clientSecret||"",onChange:S,disabled:i}))))),s&&e.createElement(e.Fragment,null,e.createElement("div",{className:"gf-form-inline"},e.createElement("div",{className:"gf-form"},e.createElement(he.c,{className:"width-12"},"Default Subscription"),e.createElement("div",{className:"width-25"},e.createElement(lt.Ph,{value:t.defaultSubscriptionId?b.find(P=>P.value===t.defaultSubscriptionId):void 0,options:b,onChange:U,isDisabled:i})))),e.createElement("div",{className:"gf-form-inline"},e.createElement("div",{className:"gf-form"},e.createElement("div",{className:"max-width-30 gf-form-inline"},e.createElement(_.zx,{variant:"secondary",size:"sm",type:"button",onClick:y,disabled:!c},"Load Subscriptions"))))))},Il=null,al=a=>{const{dataSourceConfig:t,onChange:n}=a,[r]=(0,e.useState)(k.v.featureToggles.prometheusAzureOverrideAudience||!!t.jsonData.azureEndpointResourceId),[s,i]=(0,e.useState)(!!t.jsonData.azureEndpointResourceId),c=(0,e.useMemo)(()=>Ya(t),[t]),b=y=>{n(qa(t,y))},m=y=>{i(y.currentTarget.checked),y.currentTarget.checked||n({...t,jsonData:{...t.jsonData,azureEndpointResourceId:void 0}})},h=y=>{s&&n({...t,jsonData:{...t.jsonData,azureEndpointResourceId:y.currentTarget.value}})};return e.createElement(e.Fragment,null,e.createElement("h6",null,"Azure Authentication"),e.createElement(tl,{managedIdentityEnabled:k.v.azure.managedIdentityEnabled,credentials:c,azureCloudOptions:Ka,onCredentialsChange:b,disabled:t.readOnly}),r&&e.createElement(e.Fragment,null,e.createElement("h6",null,"Azure Configuration"),e.createElement("div",{className:"gf-form-group"},e.createElement(Pt.Z,null,e.createElement(me._,{labelWidth:26,label:"Override AAD audience",disabled:t.readOnly},e.createElement(Me.x,{value:s,onChange:m}))),s&&e.createElement(Pt.Z,null,e.createElement(me._,{labelWidth:26,label:"Resource ID",disabled:t.readOnly},e.createElement(Te.I,{className:"width-30",value:t.jsonData.azureEndpointResourceId||"",onChange:h}))))))},Tl=null;var ll=o(72097),nt=o.n(ll),Mt=o(5916),nl=o(54899),rl=o(14835),At=o(59481),sl=o(25e3),De=o(46063),ol=o(53117);function il({value:a,onChange:t,onDelete:n,disabled:r}){const[s,i]=(0,e.useState)(Boolean(a.datasourceUid));return e.createElement("div",{className:"gf-form-group"},e.createElement(me._,{label:"Internal link",labelWidth:24,disabled:r},e.createElement(e.Fragment,null,e.createElement(Me.x,{value:s,"aria-label":ue.wl.components.DataSource.Prometheus.configPage.internalLinkSwitch,onChange:c=>i(c.currentTarget.checked)}),!r&&e.createElement(_.zx,{variant:"destructive",title:"Remove link",icon:"times",onClick:c=>{c.preventDefault(),n()},className:x.css`
                margin-left: 8px;
              `}))),s?e.createElement(me._,{label:"Data source",labelWidth:24,tooltip:"The data source the exemplar is going to navigate to.",disabled:r},e.createElement(ol.q,{tracing:!0,current:a.datasourceUid,noDefault:!0,width:40,onChange:c=>t({...a,datasourceUid:c.uid,url:void 0})})):e.createElement(me._,{label:"URL",labelWidth:24,tooltip:"The URL of the trace backend the user would go to see its trace.",disabled:r},e.createElement(Te.I,{placeholder:"https://example.com/${__value.raw}",spellCheck:!1,width:40,value:a.url,onChange:c=>t({...a,datasourceUid:void 0,url:c.currentTarget.value})})),e.createElement(me._,{label:"URL Label",labelWidth:24,tooltip:"Use to override the button label on the exemplar traceID field.",disabled:r},e.createElement(Te.I,{placeholder:"Go to example.com",spellCheck:!1,width:40,value:a.urlDisplayLabel,onChange:c=>t({...a,urlDisplayLabel:c.currentTarget.value})})),e.createElement(me._,{label:"Label name",labelWidth:24,tooltip:"The name of the field in the labels object that should be used to get the traceID.",disabled:r},e.createElement(Te.I,{placeholder:"traceID",spellCheck:!1,width:40,value:a.name,onChange:c=>t({...a,name:c.currentTarget.value})})))}function cl({options:a,onChange:t,disabled:n}){return e.createElement(e.Fragment,null,e.createElement("h3",{className:"page-heading"},"Exemplars"),a&&a.map((r,s)=>e.createElement(il,{key:s,value:r,onChange:i=>{const c=[...a];c.splice(s,1,i),t(c)},onDelete:()=>{const i=[...a];i.splice(s,1),t(i)},disabled:n})),!n&&e.createElement(_.zx,{variant:"secondary","aria-label":ue.wl.components.DataSource.Prometheus.configPage.exemplarsAddButton,className:x.css`
            margin-bottom: 10px;
          `,icon:"plus",onClick:r=>{r.preventDefault();const s=[...a||[],{name:"traceID"}];t(s)}},"Add"))}const Ue={Prometheus:[{value:void 0,label:"Please select"},{value:"2.0.0",label:"< 2.14.x"},{value:"2.14.0",label:"2.14.x"},{value:"2.15.0",label:"2.15.x"},{value:"2.16.0",label:"2.16.x"},{value:"2.17.0",label:"2.17.x"},{value:"2.18.0",label:"2.18.x"},{value:"2.19.0",label:"2.19.x"},{value:"2.20.0",label:"2.20.x"},{value:"2.21.0",label:"2.21.x"},{value:"2.22.0",label:"2.22.x"},{value:"2.23.0",label:"2.23.x"},{value:"2.24.0",label:"2.24.x"},{value:"2.25.0",label:"2.25.x"},{value:"2.26.0",label:"2.26.x"},{value:"2.27.0",label:"2.27.x"},{value:"2.28.0",label:"2.28.x"},{value:"2.29.0",label:"2.29.x"},{value:"2.30.0",label:"2.30.x"},{value:"2.31.0",label:"2.31.x"},{value:"2.32.0",label:"2.32.x"},{value:"2.33.0",label:"2.33.x"},{value:"2.34.0",label:"2.34.x"},{value:"2.35.0",label:"2.35.x"},{value:"2.36.0",label:"2.36.x"},{value:"2.37.0",label:"2.37.x"},{value:"2.38.0",label:"2.38.x"},{value:"2.39.0",label:"2.39.x"},{value:"2.40.0",label:"2.40.x"},{value:"2.40.1",label:"> 2.40.x"}],Mimir:[{value:void 0,label:"Please select"},{value:"2.0.0",label:"2.0.x"},{value:"2.1.0",label:"2.1.x"},{value:"2.2.0",label:"2.2.x"},{value:"2.3.0",label:"2.3.x"},{value:"2.4.0",label:"> 2.3.x"}],Thanos:[{value:void 0,label:"Please select"},{value:"0.0.0",label:"< 0.16.x"},{value:"0.16.0",label:"0.16.x"},{value:"0.17.0",label:"0.17.x"},{value:"0.18.0",label:"0.18.x"},{value:"0.19.0",label:"0.19.x"},{value:"0.20.0",label:"0.20.x"},{value:"0.21.0",label:"0.21.x"},{value:"0.22.0",label:"0.22.x"},{value:"0.23.0",label:"0.23.x"},{value:"0.24.0",label:"0.24.x"},{value:"0.25.0",label:"0.25.x"},{value:"0.26.0",label:"0.26.x"},{value:"0.27.0",label:"0.27.x"},{value:"0.28.0",label:"0.28.x"},{value:"0.29.0",label:"> 0.28.x"}],Cortex:[{value:void 0,label:"Please select"},{value:"0.0.0",label:"< 1.0.0"},{value:"1.0.0",label:"1.0.0"},{value:"1.1.0",label:"1.1.x"},{value:"1.2.0",label:"1.2.x"},{value:"1.3.0",label:"1.3.x"},{value:"1.4.0",label:"1.4.x"},{value:"1.5.0",label:"1.5.x"},{value:"1.6.0",label:"1.6.x"},{value:"1.7.0",label:"1.7.x"},{value:"1.8.0",label:"1.8.x"},{value:"1.9.0",label:"1.9.x"},{value:"1.10.0",label:"1.10.x"},{value:"1.11.0",label:"1.11.x"},{value:"1.13.0",label:"1.13.x"},{value:"1.14.0",label:"> 1.13.x"}]},{Input:rt,FormField:Oe}=rl.LegacyForms,Ot=[{value:"POST",label:"POST"},{value:"GET",label:"GET"}],Ft=[{value:re.c.Builder,label:"Builder"},{value:re.c.Code,label:"Code"}],Lt=[{value:De.T8.Prometheus,label:De.T8.Prometheus},{value:De.T8.Cortex,label:De.T8.Cortex},{value:De.T8.Mimir,label:De.T8.Mimir},{value:De.T8.Thanos,label:De.T8.Thanos}],ul=(a,t)=>{if(!t||!Ue[t])return;const r=Ue[t]?.filter(i=>!!i.value&&nt().lte(i.value,a)).map(i=>i.value),s=r[r.length-1];if(s){const i=nt().diff(s,a);if(["patch","prepatch","prerelease",null].includes(i))return s}},Vt=a=>{console.warn("Error fetching version from buildinfo API, must manually select version!",a)},dl=(a,t,n)=>{n(a).then(r=>{(0,nl.i)().get(`/api/datasources/uid/${r.uid}/resources/version-detect`).then(s=>{const i=s.data?.version??"";if(i&&nt().valid(i)){const c=ul(i,r.jsonData.prometheusType);c&&n({...r,jsonData:{...r.jsonData,prometheusVersion:c}}).then(b=>{t(b)})}else Vt()})}).catch(r=>{Vt(r)})},ml=a=>{const{options:t,onOptionsChange:n}=a,r=(0,sl.qj)();return t.jsonData.httpMethod||(t.jsonData.httpMethod="POST"),e.createElement(e.Fragment,null,e.createElement("div",{className:"gf-form-group"},e.createElement("div",{className:"gf-form-inline"},e.createElement("div",{className:"gf-form"},e.createElement(Oe,{label:"Scrape interval",labelWidth:13,inputEl:e.createElement(rt,{className:"width-6",value:t.jsonData.timeInterval,spellCheck:!1,placeholder:"15s",onChange:Pe("timeInterval",t,n),validationEvents:jt,disabled:t.readOnly}),tooltip:"Set this to the typical scrape and evaluation interval configured in Prometheus. Defaults to 15s."}))),e.createElement("div",{className:"gf-form-inline"},e.createElement("div",{className:"gf-form"},e.createElement(Oe,{label:"Query timeout",labelWidth:13,inputEl:e.createElement(rt,{className:"width-6",value:t.jsonData.queryTimeout,onChange:Pe("queryTimeout",t,n),spellCheck:!1,placeholder:"60s",validationEvents:jt,disabled:t.readOnly}),tooltip:"Set the Prometheus query timeout."}))),e.createElement("div",{className:"gf-form"},e.createElement(he.c,{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."},"HTTP method"),e.createElement(te.Ph,{"aria-label":"Select HTTP method",options:Ot,value:Ot.find(s=>s.value===t.jsonData.httpMethod),onChange:Pe("httpMethod",t,n),className:"width-6",disabled:t.readOnly}))),e.createElement("h3",{className:"page-heading"},"Type and version"),!t.jsonData.prometheusType&&!t.jsonData.prometheusVersion&&t.readOnly&&e.createElement("div",{style:{marginBottom:"12px"}},"For more information on configuring prometheus type and version in data sources, see the"," ",e.createElement("a",{style:{textDecoration:"underline"},href:"https://grafana.com/docs/grafana/latest/administration/provisioning/"},"provisioning documentation"),"."),e.createElement("div",{className:"gf-form-group"},e.createElement("div",{className:"gf-form"},e.createElement("div",{className:"gf-form"},e.createElement(Oe,{label:"Prometheus type",labelWidth:13,inputEl:e.createElement(te.Ph,{"aria-label":"Prometheus type",options:Lt,value:Lt.find(s=>s.value===t.jsonData.prometheusType),onChange:Pe("prometheusType",{...t,jsonData:{...t.jsonData,prometheusVersion:void 0}},s=>(dl(s,n,r),n({...s,jsonData:{...s.jsonData,prometheusVersion:void 0}}))),width:20,disabled:t.readOnly}),tooltip:"Set this to the type of your prometheus database, e.g. Prometheus, Cortex, Mimir or Thanos. Changing this field will save your current settings, and attempt to detect the version."}))),e.createElement("div",{className:"gf-form"},t.jsonData.prometheusType&&e.createElement("div",{className:"gf-form"},e.createElement(Oe,{label:`${t.jsonData.prometheusType} version`,labelWidth:13,inputEl:e.createElement(te.Ph,{"aria-label":`${t.jsonData.prometheusType} type`,options:Ue[t.jsonData.prometheusType],value:Ue[t.jsonData.prometheusType]?.find(s=>s.value===t.jsonData.prometheusVersion),onChange:Pe("prometheusVersion",t,n),width:20,disabled:t.readOnly}),tooltip:`Use this to set the version of your ${t.jsonData.prometheusType} instance if it is not automatically configured.`})))),e.createElement("h3",{className:"page-heading"},"Misc"),e.createElement("div",{className:"gf-form-group"},e.createElement("div",{className:"gf-form"},e.createElement(me._,{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.",disabled:t.readOnly},e.createElement(Me.x,{value:t.jsonData.disableMetricsLookup??!1,onChange:(0,Mt.hz)(a,"disableMetricsLookup")}))),e.createElement("div",{className:"gf-form"},e.createElement(Oe,{label:"Default Editor",labelWidth:14,inputEl:e.createElement(te.Ph,{"aria-label":"Default Editor (Code or Builder)",options:Ft,value:Ft.find(s=>s.value===t.jsonData.defaultEditor),onChange:Pe("defaultEditor",t,n),width:20,disabled:t.readOnly}),tooltip:'Set default editor option (builder/code) for all users of this datasource. If no option was selected, the default editor will be the "builder". If they switch to other option rather than the specified with this setting on the panel we always show the selected editor for that user.'})),e.createElement("div",{className:"gf-form-inline"},e.createElement("div",{className:"gf-form max-width-30"},e.createElement(Oe,{label:"Custom query parameters",labelWidth:14,tooltip:"Add custom parameters to all Prometheus or Thanos queries.",inputEl:e.createElement(rt,{className:"width-25",value:t.jsonData.customQueryParameters,onChange:Pe("customQueryParameters",t,n),spellCheck:!1,placeholder:"Example: max_source_resolution=5m&timeout=10",disabled:t.readOnly})})))),e.createElement(cl,{options:t.jsonData.exemplarTraceIdDestinations,onChange:s=>(0,Mt.tp)({onOptionsChange:n,options:t},"exemplarTraceIdDestinations",s),disabled:t.readOnly}))},jt={[At.JU.onBlur]:[(0,At.FE)(/^$|^\d+(ms|[Mwdhmsy])$/,"Value is not valid, you can use number with time unit specifier: y, M, w, d, h, m, s")]},pl=a=>a?a.hasOwnProperty("currentTarget")?a.currentTarget.value:a.value:"",Pe=(a,t,n)=>r=>{n({...t,jsonData:{...t.jsonData,[a]:pl(r)}})},hl=a=>{const{options:t,onOptionsChange:n}=a,r=(0,e.useRef)(a.options.access==="direct"),s={azureAuthSupported:at.vc.azureAuthEnabled,getAzureAuthEnabled:i=>Za(i),setAzureAuthEnabled:(i,c)=>c?_a(i):el(i),azureSettingsUI:al};return e.createElement(e.Fragment,null,t.access==="direct"&&e.createElement(ka.b,{title:"Error",severity:"error"},"Browser access mode in the Prometheus datasource is no longer available. Switch to server access mode."),e.createElement(Wa.E,{defaultUrl:"http://localhost:9090",dataSourceConfig:t,showAccessOptions:r.current,onChange:n,sigV4AuthToggleEnabled:at.vc.sigV4AuthEnabled,azureAuthSettings:s,renderSigV4Editor:e.createElement(Ba.SIGV4ConnectionConfig,{...a})}),at.vc.featureToggles.secureSocksDatasourceProxy&&e.createElement(Ua.i,{options:t,onOptionsChange:n}),e.createElement($a.O,{options:t,onOptionsChange:n}),e.createElement(ml,{options:t,onOptionsChange:n}))};var gl=o(76303);const vl=new q.hf(gl.vQ).setQueryEditor(Xa).setConfigEditor(hl).setQueryEditorHelp(w)},58079:(Qe,j,o)=>{"use strict";o.d(j,{c:()=>q});var q=(e=>(e.Code="code",e.Builder="builder",e))(q||{})},77172:(Qe,j,o)=>{var q;q={value:!0};var e,J=o(68404),v=(e=J)&&typeof e=="object"&&"default"in e?e.default:e,w=o(40419),G=o(24034),ye=o(82897);const Le=["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"];var ue;(ue=j._e||(j._e={})).Keys="keys",ue.Credentials="credentials",ue.Default="default",ue.EC2IAMRole="ec2_iam_role",ue.ARN="arn";const A=[{label:"Workspace IAM Role",value:j._e.EC2IAMRole},{label:"AWS SDK Default",value:j._e.Default},{label:"Access & secret key",value:j._e.Keys},{label:"Credentials file",value:j._e.Credentials}],Ne=l=>({value:l,label:l}),Re=l=>{var p,C,N,T,z,M,le,B;const[Y,Z]=J.useState((l.standardRegions||Le).map(Ne)),{loadRegions:ne,onOptionsChange:pe,skipHeader:ve=!1,skipEndpoint:re=!1}=l,{labelWidth:ce=28,options:f}=l;let se=f.jsonData.profile;se===void 0&&(se=f.database);const Ce=window.grafanaBootData.settings,Se=J.useMemo(()=>{var k;return(k=Ce.awsAllowedAuthProviders)!==null&&k!==void 0?k:[j._e.Default,j._e.Keys,j._e.Credentials]},[Ce.awsAllowedAuthProviders]),Ke=(p=Ce.awsAssumeRoleEnabled)===null||p===void 0||p,Ve=A.find(k=>k.value===f.jsonData.authType);return J.useEffect(()=>{!Ve&&Se.length&&pe(Object.assign(Object.assign({},f),{jsonData:Object.assign(Object.assign({},f.jsonData),{authType:Se[0]})}))},[Ve,f,pe,Se]),J.useEffect(()=>{ne&&ne().then(k=>Z(k.map(Ne)))},[ne]),v.createElement(w.FieldSet,{label:ve?"":"Connection Details","data-testid":"connection-config"},v.createElement(w.InlineField,{label:"Authentication Provider",labelWidth:ce,tooltip:"Specify which AWS credentials chain to use."},v.createElement(w.Select,{"aria-label":"Authentication Provider",className:"width-30",value:Ve,options:A.filter(k=>Se.includes(k.value)),defaultValue:f.jsonData.authType,onChange:k=>{G.onUpdateDatasourceJsonDataOptionSelect(l,"authType")(k)},menuShouldPortal:!0})),f.jsonData.authType==="credentials"&&v.createElement(w.InlineField,{label:"Credentials Profile Name",labelWidth:ce,tooltip:"Credentials profile name, as specified in ~/.aws/credentials, leave blank for default."},v.createElement(w.Input,{"aria-label":"Credentials Profile Name",className:"width-30",placeholder:"default",value:se,onChange:G.onUpdateDatasourceJsonDataOption(l,"profile")})),f.jsonData.authType==="keys"&&v.createElement(v.Fragment,null,v.createElement(w.InlineField,{label:"Access Key ID",labelWidth:ce},!((C=l.options.secureJsonFields)===null||C===void 0)&&C.accessKey?v.createElement(w.ButtonGroup,{className:"width-30"},v.createElement(w.Input,{disabled:!0,placeholder:"Configured"}),v.createElement(w.ToolbarButton,{icon:"edit",tooltip:"Edit Access Key ID",type:"button",onClick:G.onUpdateDatasourceResetOption(l,"accessKey")})):v.createElement(w.Input,{"aria-label":"Access Key ID",className:"width-30",value:(T=(N=f.secureJsonData)===null||N===void 0?void 0:N.accessKey)!==null&&T!==void 0?T:"",onChange:G.onUpdateDatasourceSecureJsonDataOption(l,"accessKey")})),v.createElement(w.InlineField,{label:"Secret Access Key",labelWidth:ce},!((z=l.options.secureJsonFields)===null||z===void 0)&&z.secretKey?v.createElement(w.ButtonGroup,{className:"width-30"},v.createElement(w.Input,{disabled:!0,placeholder:"Configured"}),v.createElement(w.ToolbarButton,{icon:"edit",type:"button",tooltip:"Edit Secret Access Key",onClick:G.onUpdateDatasourceResetOption(l,"secretKey")})):v.createElement(w.Input,{"aria-label":"Secret Access Key",className:"width-30",value:(le=(M=f.secureJsonData)===null||M===void 0?void 0:M.secretKey)!==null&&le!==void 0?le:"",onChange:G.onUpdateDatasourceSecureJsonDataOption(l,"secretKey")}))),Ke&&v.createElement(v.Fragment,null,v.createElement(w.InlineField,{label:"Assume Role ARN",labelWidth:ce,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"},v.createElement(w.Input,{"aria-label":"Assume Role ARN",className:"width-30",placeholder:"arn:aws:iam:*",value:f.jsonData.assumeRoleArn||"",onChange:G.onUpdateDatasourceJsonDataOption(l,"assumeRoleArn")})),v.createElement(w.InlineField,{label:"External ID",labelWidth:ce,tooltip:"If you are assuming a role in another account, that has been created with an external ID, specify the external ID here."},v.createElement(w.Input,{"aria-label":"External ID",className:"width-30",placeholder:"External ID",value:f.jsonData.externalId||"",onChange:G.onUpdateDatasourceJsonDataOption(l,"externalId")}))),!re&&v.createElement(w.InlineField,{label:"Endpoint",labelWidth:ce,tooltip:"Optionally, specify a custom endpoint for the service"},v.createElement(w.Input,{"aria-label":"Endpoint",className:"width-30",placeholder:(B=l.defaultEndpoint)!==null&&B!==void 0?B:"https://{service}.{region}.amazonaws.com",value:f.jsonData.endpoint||"",onChange:G.onUpdateDatasourceJsonDataOption(l,"endpoint")})),v.createElement(w.InlineField,{label:"Default Region",labelWidth:ce,tooltip:"Specify the region, such as for US West (Oregon) use ` us-west-2 ` as the region."},v.createElement(w.Select,{"aria-label":"Default Region",className:"width-30",value:Y.find(k=>k.value===f.jsonData.defaultRegion),options:Y,defaultValue:f.jsonData.defaultRegion,allowCustomValue:!0,onChange:G.onUpdateDatasourceJsonDataOptionSelect(l,"defaultRegion"),formatCreateLabel:k=>"Use region: "+k,menuShouldPortal:!0})),l.children)};/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function _(l,p,C,N){return new(C||(C=Promise))(function(T,z){function M(Y){try{B(N.next(Y))}catch(Z){z(Z)}}function le(Y){try{B(N.throw(Y))}catch(Z){z(Z)}}function B(Y){var Z;Y.done?T(Y.value):(Z=Y.value,Z instanceof C?Z:new C(function(ne){ne(Z)})).then(M,le)}B((N=N.apply(l,p||[])).next())})}function x(l){const[p,C]=J.useState(l.value||l.default||null),[N,T]=J.useState(p?[p]:[]),[z,M]=J.useState(l.dependencies),[le,B]=J.useState(!1),[Y,Z]=J.useState(!1),ne=J.useMemo(()=>{const f=[{label:`default (${l.default})`,value:"__default",description:"Default value set in the data source"}];return l.value&&l.value!=="__default"&&f.push({label:l.value,value:l.value}),f},[l.default,l.value]),[pe,ve]=J.useState(l.default?ne:[]);J.useEffect(()=>{l.resources!==void 0&&T(l.resources)},[l.resources]),J.useEffect(()=>{const f=l.default?ne:[];N.length?(N.forEach(se=>{const Ce=typeof se=="string"?se:se.value;f.find(Se=>Se.value===Ce)||(typeof se=="string"?f.push({label:se,value:se}):f.push(se))}),ve(f)):ve([])},[N,ne,l.default]),J.useEffect(()=>{ye.isEqual(l.dependencies,z)||(Z(!1),C(null),l.onChange(null),M(l.dependencies))},[l,z]);const re=()=>_(this,void 0,void 0,function*(){if(!Y){l.saveOptions&&(yield l.saveOptions());try{const f=yield l.fetch();T(f)}finally{Z(!0)}}}),ce=()=>_(this,void 0,void 0,function*(){B(!0);try{yield re()}finally{B(!1)}});return v.createElement(w.InlineField,{label:l.label,labelWidth:l.labelWidth,tooltip:l.tooltip,hidden:l.hidden},v.createElement("div",{"data-testid":l["data-testid"],title:l.title},v.createElement(w.Select,Object.assign({},l,{"aria-label":l.label,options:pe,onChange:f=>{l.onChange(f),f.value&&C(f.value)},isLoading:le,className:l.className||"min-width-6",onOpenMenu:()=>l.fetch&&ce(),menuShouldPortal:!0}))))}var ae;(ae=j.rB||(j.rB={}))[ae.Previous=0]="Previous",ae[ae.Null=1]="Null",ae[ae.Value=2]="Value";const Xe=[{label:"Previous Value",value:j.rB.Previous},{label:"NULL",value:j.rB.Null},{label:"Value",value:j.rB.Value}];function Be(l){return typeof l=="string"?l:l.map(p=>function(C){return"'"+String(C).replace(/'/g,"''")+"'"}(p)).join(",")}q=function(l){var p,C,N;const{jsonData:T}=l.options,z={title:T.defaultRegion?"":"select a default region",labelWidth:(p=l.labelWidth)!==null&&p!==void 0?p:28,className:"width-30"},M=[l.options.jsonData.assumeRoleArn,l.options.jsonData.authType,l.options.jsonData.defaultRegion,l.options.jsonData.endpoint,l.options.jsonData.externalId,l.options.jsonData.profile,(C=l.options.secureJsonData)===null||C===void 0?void 0:C.accessKey,(N=l.options.secureJsonData)===null||N===void 0?void 0:N.secretKey].concat(l.dependencies);return v.createElement(x,Object.assign({label:l.label,"data-testid":l["data-testid"],onChange:l.onChange,fetch:l.fetch,value:l.value,saveOptions:l.saveOptions,dependencies:M,hidden:l.hidden,disabled:l.disabled||!T.defaultRegion,allowCustomValue:l.allowCustomValue,autoFocus:l.autoFocus,backspaceRemovesValue:l.backspaceRemovesValue,className:l.className,invalid:l.invalid,isClearable:l.isClearable,isMulti:l.isMulti,inputId:l.inputId,showAllSelectedWhenOpen:l.showAllSelectedWhenOpen,maxMenuHeight:l.maxMenuHeight,minMenuHeight:l.minMenuHeight,maxVisibleValues:l.maxVisibleValues,menuPlacement:l.menuPlacement,menuPosition:l.menuPosition,noOptionsMessage:l.noOptionsMessage,onBlur:l.onBlur,onCreateOption:l.onCreateOption,onInputChange:l.onInputChange,placeholder:l.placeholder,width:l.width,isOptionDisabled:l.isOptionDisabled},z))},j.ConnectionConfig=Re,q=function(l){var p,C,N;return v.createElement(v.Fragment,null,v.createElement(w.InlineField,{label:"Fill value",tooltip:"value to fill missing points"},v.createElement(w.Select,{"aria-label":"Fill value",options:Xe,value:(C=(p=l.query.fillMode)===null||p===void 0?void 0:p.mode)!==null&&C!==void 0?C:j.rB.Previous,onChange:({value:T})=>{var z;l.onChange(Object.assign(Object.assign({},l.query),{fillMode:Object.assign(Object.assign({},l.query.fillMode),{mode:T})})),(z=l.onRunQuery)===null||z===void 0||z.call(l)},className:"width-12",menuShouldPortal:!0})),((N=l.query.fillMode)===null||N===void 0?void 0:N.mode)===j.rB.Value&&v.createElement(w.InlineField,{label:"Value",labelWidth:11},v.createElement(w.Input,{type:"number","aria-label":"Value",value:l.query.fillMode.value,onChange:({currentTarget:T})=>l.onChange(Object.assign(Object.assign({},l.query),{fillMode:{mode:j.rB.Value,value:T.valueAsNumber}})),onBlur:()=>{var T;return(T=l.onRunQuery)===null||T===void 0?void 0:T.call(l)}})))},q=function(l){return v.createElement(w.InlineField,{label:"Format as",labelWidth:11},v.createElement(w.Select,{"aria-label":"Format as",options:l.options,value:l.query.format,onChange:p=>{var C;l.onChange(Object.assign(Object.assign({},l.query),{format:p.value||0})),(C=l.onRunQuery)===null||C===void 0||C.call(l)},className:"width-12",menuShouldPortal:!0}))},q=function(l){var p;return v.createElement(w.InlineField,{label:l.label,labelWidth:(p=l.labelWidth)!==null&&p!==void 0?p:28,tooltip:l.tooltip,hidden:l.hidden,disabled:l.disabled},v.createElement(w.Input,{"data-testid":l["data-testid"],className:"width-30",value:l.value,onChange:l.onChange,placeholder:l.placeholder,disabled:l.disabled}))},q=function(l){const{getSuggestions:p,query:C}=l,{rawSQL:N}=ye.defaults(l.query,{rawSQL:""}),T=J.useRef([]);return J.useEffect(()=>{T.current=p(C)},[p,C]),v.createElement(w.CodeEditor,Object.assign({language:l.language,value:N,onBlur:z=>{const M=Object.assign(Object.assign({},l.query),{rawSQL:z});l.onChange(M),l.onRunQuery()},showMiniMap:!1,showLineNumbers:!0,getSuggestions:()=>T.current,height:"240px"},l.editorProps))},q=x,j.SIGV4ConnectionConfig=l=>{var p,C,N,T;const{onOptionsChange:z,options:M}=l,le={onOptionsChange:B=>{var Y,Z,ne,pe;const ve=Object.assign(Object.assign({},M),{jsonData:Object.assign(Object.assign({},M.jsonData),{sigV4AuthType:B.jsonData.authType,sigV4Profile:B.jsonData.profile,sigV4AssumeRoleArn:B.jsonData.assumeRoleArn,sigV4ExternalId:B.jsonData.externalId,sigV4Region:B.jsonData.defaultRegion,sigV4Endpoint:B.jsonData.endpoint}),secureJsonFields:{sigV4AccessKey:(Y=B.secureJsonFields)===null||Y===void 0?void 0:Y.accessKey,sigV4SecretKey:(Z=B.secureJsonFields)===null||Z===void 0?void 0:Z.secretKey},secureJsonData:{sigV4AccessKey:(ne=B.secureJsonData)===null||ne===void 0?void 0:ne.accessKey,sigV4SecretKey:(pe=B.secureJsonData)===null||pe===void 0?void 0:pe.secretKey}});z(ve)},options:Object.assign(Object.assign({},M),{jsonData:Object.assign(Object.assign({},M.jsonData),{authType:M.jsonData.sigV4AuthType,profile:M.jsonData.sigV4Profile,assumeRoleArn:M.jsonData.sigV4AssumeRoleArn,externalId:M.jsonData.sigV4ExternalId,defaultRegion:M.jsonData.sigV4Region,endpoint:M.jsonData.sigV4Endpoint}),secureJsonFields:{accessKey:(p=M.secureJsonFields)===null||p===void 0?void 0:p.sigV4AccessKey,secretKey:(C=M.secureJsonFields)===null||C===void 0?void 0:C.sigV4SecretKey},secureJsonData:{accessKey:(N=M.secureJsonData)===null||N===void 0?void 0:N.sigV4AccessKey,secretKey:(T=M.secureJsonData)===null||T===void 0?void 0:T.sigV4SecretKey}})};return v.createElement(v.Fragment,null,v.createElement("div",{className:"gf-form"},v.createElement("h6",null,"SigV4 Auth Details")),v.createElement(Re,Object.assign({},le,{skipHeader:!0,skipEndpoint:!0})))},q=(l,p)=>{const C=l(),N=[];return C.getVariables().forEach(T=>{const z="$"+T.name;let M=C.replace(z);M===z&&(M=""),N.push({label:z,kind:w.CodeEditorSuggestionItemKind.Text,detail:"(Template Variable) "+M})}),p.concat(N)},q=function(l,p,C){const N=C();return Object.assign(Object.assign({},l),{rawSQL:N.replace(l.rawSQL,p,Be)})},q=A,q=function(l){return!!l.rawSQL},q=Le},37308:(Qe,j,o)=>{"use strict";Qe.exports=o(77172)}}]);

//# sourceMappingURL=prometheusPlugin.de34f45160987037cfa4.js.map