/*! For license information please see 7379.40eb8461084ddb7791b3.js.LICENSE.txt */ (self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7379],{54834:(e,t,a)=>{"use strict";a.d(t,{a:()=>r});a(68404);var l=a(69783),n=a(45916);function r(e){let{query:t,onChange:a,onRunQuery:r}=e;return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(l.TextArea,{name:"Query",className:"slate-query-field",value:t,rows:10,placeholder:"Enter a Cloud Monitoring MQL query (Run with Shift+Enter)",onBlur:r,onChange:e=>a(e.currentTarget.value),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||e.ctrlKey)&&(e.preventDefault(),r())}})})}},80425:(e,t,a)=>{"use strict";a.d(t,{a1:()=>E,wi:()=>m});var l,n=a(68404),r=a(2986),i=a(25576),o=a(69783),s=a(22002),c=a(49224),u=a(45916);const d=e=>{let{refId:t,onChange:a,graphPeriod:n,variableOptionGroup:r}=e;return(0,u.jsx)(u.Fragment,{children:(0,u.jsxs)(c.x5,{label:"Graph period",htmlFor:`${t}-graph-period`,tooltip:(0,u.jsxs)(u.Fragment,{children:["Set ",l||(l=(0,u.jsx)("code",{children:"graph_period"}))," which forces a preferred period between points. Automatically set to the current interval if left blank."]}),children:[(0,u.jsx)(o.Switch,{"data-testid":`${t}-switch-graph-period`,value:"disabled"!==n,onChange:e=>a(e.currentTarget.checked?"":"disabled")}),(0,u.jsx)(c.$d,{inputId:`${t}-graph-period`,templateVariableOptions:r.options,current:n,onChange:a,selectWidth:s.Lh,disabled:"disabled"===n,aligmentPeriods:s.Ry})]})})};var p=a(54834);const h={labels:{}},m=e=>({editorMode:i.je.Visual,projectName:e.getDefaultProject(),metricType:"",metricKind:i.lH.GAUGE,valueType:"",crossSeriesReducer:"REDUCE_MEAN",alignmentPeriod:"cloud-monitoring-auto",perSeriesAligner:i.CS.ALIGN_MEAN,groupBys:[],filters:[],aliasBy:"",query:"",preprocessor:i.mG.None});function v(e){let{refId:t,query:a,datasource:l,onChange:o,onRunQuery:s,customMetaData:m,variableOptionGroup:v}=e;const[E,g]=(0,n.useState)(h),{projectName:I,metricType:T,groupBys:f,editorMode:y,crossSeriesReducer:b}=a;(0,n.useEffect)((()=>{I&&T&&l.getLabels(T,t,I).then((e=>g((t=>Object.assign({},t,{labels:e})))))}),[l,f,T,I,t,b]);const N=(0,n.useCallback)((e=>{o(Object.assign({},a,e)),s()}),[o,s,a]),O=(0,n.useCallback)((e=>{let{valueType:t,metricKind:l,type:n}=e;const o=l===i.lH.GAUGE||t===i.$h.DISTRIBUTION?i.mG.None:i.mG.Rate,{perSeriesAligner:s}=(0,r.ID)(t,l,E.perSeriesAligner,o);N(Object.assign({},a,{perSeriesAligner:s,metricType:n,valueType:t,metricKind:l,preprocessor:o}))}),[N,a,E]);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.IK,{refId:t,templateVariableOptions:v.options,projectName:I,datasource:l,onChange:e=>{N(Object.assign({},a,{projectName:e}))}}),y===i.je.Visual&&(0,u.jsx)(c.sL,{refId:t,labels:E.labels,variableOptionGroup:v,customMetaData:m,onMetricTypeChange:O,onChange:N,datasource:l,query:a}),y===i.je.MQL&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(p.a,{onChange:e=>o(Object.assign({},a,{query:e})),onRunQuery:s,query:a.query}),(0,u.jsx)(d,{onChange:e=>o(Object.assign({},a,{graphPeriod:e})),graphPeriod:a.graphPeriod,refId:t,variableOptionGroup:v})]}),(0,u.jsx)(c.BQ,{refId:t,value:a.aliasBy,onChange:e=>{N(Object.assign({},a,{aliasBy:e}))}})]})}const E=n.memo(v)},47379:(e,t,a)=>{"use strict";a.d(t,{W:()=>m});var l=a(36636),n=a(68404),r=a(43215),i=a(69783),o=a(22002),s=a(25576),c=a(80425),u=a(18809),d=a(49224),p=a(45916);const h=["hide","refId","datasource","key","queryType","maxLines","metric"];class m extends n.PureComponent{async UNSAFE_componentWillMount(){const{datasource:e,query:t}=this.props;if(!this.props.query.hasOwnProperty("metricQuery")){const e=function(e,t){if(null==e)return{};var a,l,n={},r=Object.keys(e);for(l=0;l=0||(n[a]=e[a]);return n}(this.props.query,h);this.props.query.metricQuery=e}this.props.query.hasOwnProperty("queryType")||(this.props.query.queryType=s.xL.METRICS),await e.ensureGCEDefaultProject(),t.metricQuery.projectName||(this.props.query.metricQuery.projectName=e.getDefaultProject())}onQueryChange(e,t){this.props.onChange(Object.assign({},this.props.query,{[e]:t})),this.props.onRunQuery()}render(){var e,t,a;const{datasource:n,query:h,onRunQuery:m,onChange:v}=this.props,E=Object.assign({},(0,c.wi)(n),h.metricQuery),g=Object.assign({},(0,u.w)(n),h.sloQuery),I=h.queryType||s.xL.METRICS,T=null!==(e=this.props.data)&&void 0!==e&&e.series.length?null===(t=this.props.data)||void 0===t?void 0:t.series[0].meta:{},f=null!==(a=null==T?void 0:T.custom)&&void 0!==a?a:{},y={label:"Template Variables",expanded:!1,options:n.getVariables().map(r.toOption)};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(d.x5,{label:"Query type",fillComponent:h.queryType!==s.xL.SLO&&(0,p.jsx)(i.Button,{variant:"secondary",className:l.css` margin-left: auto; `,icon:"edit",onClick:()=>this.onQueryChange("metricQuery",Object.assign({},E,{editorMode:E.editorMode===s.je.MQL?s.je.Visual:s.je.MQL})),children:E.editorMode===s.je.MQL?"Switch to builder":"Edit MQL"}),htmlFor:`${h.refId}-query-type`,children:(0,p.jsx)(i.Select,{width:o.Lh,value:I,options:o.XI,onChange:e=>{let{value:t}=e;v(Object.assign({},h,{sloQuery:g,queryType:t})),m()},inputId:`${h.refId}-query-type`})}),I===s.xL.METRICS&&(0,p.jsx)(d.a1,{refId:h.refId,variableOptionGroup:y,customMetaData:f,onChange:e=>{this.props.onChange(Object.assign({},this.props.query,{metricQuery:e}))},onRunQuery:m,datasource:n,query:E}),I===s.xL.SLO&&(0,p.jsx)(d.D6,{refId:h.refId,variableOptionGroup:y,customMetaData:f,onChange:e=>this.onQueryChange("sloQuery",e),onRunQuery:m,datasource:n,query:g})]})}}},18809:(e,t,a)=>{"use strict";a.d(t,{D:()=>h,w:()=>p});var l=a(68404),n=a(49224),r=a(22002),i=a(25576),o=a(69783),s=a(45916);const c=e=>{let{refId:t,query:a,templateVariableOptions:i,onChange:c,datasource:u}=e;const[d,p]=(0,l.useState)([]),{projectName:h}=a;return(0,l.useEffect)((()=>{h&&u.getSLOServices(h).then((e=>{p([{label:"Template Variables",options:i},...e])}))}),[u,h,i]),(0,s.jsx)(n.x5,{label:"Service",htmlFor:`${t}-slo-service`,children:(0,s.jsx)(o.Select,{inputId:`${t}-slo-service`,width:r.Lh,allowCustomValue:!0,value:(null==a?void 0:a.serviceId)&&{value:null==a?void 0:a.serviceId,label:(null==a?void 0:a.serviceName)||(null==a?void 0:a.serviceId)},placeholder:"Select service",options:d,onChange:e=>{let{value:t="",label:l=""}=e;return c(Object.assign({},a,{serviceId:t,serviceName:l,sloId:""}))}})})},u=e=>{let{refId:t,query:a,templateVariableOptions:i,onChange:c,datasource:u}=e;const[d,p]=(0,l.useState)([]),{projectName:h,serviceId:m}=a;return(0,l.useEffect)((()=>{h&&m&&u.getServiceLevelObjectives(h,m).then((e=>{p([{label:"Template Variables",options:i},...e])}))}),[u,h,m,i]),(0,s.jsx)(n.x5,{label:"SLO",htmlFor:`${t}-slo`,children:(0,s.jsx)(o.Select,{inputId:`${t}-slo`,width:r.Lh,allowCustomValue:!0,value:(null==a?void 0:a.sloId)&&{value:null==a?void 0:a.sloId,label:(null==a?void 0:a.sloName)||(null==a?void 0:a.sloId)},placeholder:"Select SLO",options:d,onChange:async e=>{let{value:t="",label:l=""}=e;const n=(await u.getServiceLevelObjectives(h,m)).find((e=>{let{value:a}=e;return a===u.templateSrv.replace(t)}));c(Object.assign({},a,{sloId:t,sloName:l,goal:null==n?void 0:n.goal}))}})})},d=e=>{let{refId:t,query:a,templateVariableOptions:l,onChange:i,datasource:c}=e;return(0,s.jsx)(n.x5,{label:"Selector",htmlFor:`${t}-slo-selector`,children:(0,s.jsx)(o.Select,{inputId:`${t}-slo-selector`,width:r.Lh,allowCustomValue:!0,value:[...r.IR,...l].find((e=>{var t;return null!==(t=e.value===(null==a?void 0:a.selectorName))&&void 0!==t?t:""})),options:[{label:"Template Variables",options:l},...r.IR],onChange:e=>{let{value:t}=e;return i(Object.assign({},a,{selectorName:null!=t?t:""}))}})})},p=e=>({projectName:e.getDefaultProject(),alignmentPeriod:"cloud-monitoring-auto",perSeriesAligner:i.CS.ALIGN_MEAN,aliasBy:"",selectorName:"select_slo_health",serviceId:"",serviceName:"",sloId:"",sloName:""});function h(e){let{refId:t,query:a,datasource:l,onChange:i,variableOptionGroup:o,customMetaData:p}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.IK,{refId:t,templateVariableOptions:o.options,projectName:a.projectName,datasource:l,onChange:e=>i(Object.assign({},a,{projectName:e}))}),(0,s.jsx)(c,{refId:t,datasource:l,templateVariableOptions:o.options,query:a,onChange:i}),(0,s.jsx)(u,{refId:t,datasource:l,templateVariableOptions:o.options,query:a,onChange:i}),(0,s.jsx)(d,{refId:t,datasource:l,templateVariableOptions:o.options,query:a,onChange:i}),(0,s.jsxs)(n.x5,{label:"Alignment period",htmlFor:`${t}-alignment-period`,children:[(0,s.jsx)(n.$d,{inputId:`${t}-alignment-period`,templateVariableOptions:o.options,selectWidth:r.Lh,current:a.alignmentPeriod,onChange:e=>i(Object.assign({},a,{alignmentPeriod:e})),aligmentPeriods:r.dD}),(0,s.jsx)(n.nS,{datasource:l,customMetaData:p})]}),(0,s.jsx)(n.BQ,{refId:t,value:a.aliasBy,onChange:e=>i(Object.assign({},a,{aliasBy:e}))})]})}},49224:(e,t,a)=>{"use strict";a.d(t,{Pe:()=>C,BQ:()=>A,v2:()=>m,XY:()=>L,nS:()=>x,zI:()=>O,X9:()=>h,pj:()=>b,a1:()=>D.a1,C3:()=>u,$d:()=>V,Av:()=>k,IK:()=>o,EC:()=>B,x5:()=>M,D6:()=>U.D,Th:()=>R,sL:()=>H});var l=a(68404),n=a(69783),r=a(22002),i=a(45916);function o(e){let{refId:t,projectName:a,datasource:o,onChange:s,templateVariableOptions:c}=e;const[u,d]=(0,l.useState)([]);(0,l.useEffect)((()=>{o.getProjects().then((e=>d(e)))}),[o]);const p=(0,l.useMemo)((()=>[u,{label:"Template Variables",options:c},...u]),[u,c]);return(0,i.jsx)(M,{label:"Project",htmlFor:`${t}-project`,children:(0,i.jsx)(n.Select,{width:r.Lh,allowCustomValue:!0,formatCreateLabel:e=>`Use project: ${e}`,onChange:e=>{let{value:t}=e;return s(t)},options:p,value:{value:a,label:a},placeholder:"Select Project",inputId:`${t}-project`})})}var s=a(36636),c=a(82897);function u(e){const[t,a]=(0,l.useState)({metricDescriptors:[],metrics:[],services:[],service:"",metric:"",projectName:null}),o=(0,n.useTheme2)(),s=(0,n.getSelectStyles)(o),u=(0,n.useStyles2)(d),{services:p,service:h,metrics:m,metricDescriptors:v}=t,{metricType:E,templateVariableOptions:g,projectName:I,templateSrv:T,datasource:f,onChange:y,children:b}=e,N=(0,l.useCallback)(((e,t)=>e.find((e=>e.type===T.replace(t)))),[T]);(0,l.useEffect)((()=>{(async()=>{if(I){const e=await f.getMetricTypes(I),t=L(e),l=(e=>{const t=N(e,E);return t?e.filter((e=>e.service===t.service)).map((e=>({service:e.service,value:e.type,label:e.displayName,component:function(){return(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:u,children:e.type}),(0,i.jsx)("div",{className:s.optionDescription,children:e.description})]})}}))):[]})(e),n=l.length>0?l[0].service:"",r=N(e,E);a((a=>Object.assign({},a,{metricDescriptors:e,services:t,metrics:l,service:n,metricDescriptor:r})))}})()}),[f,N,E,I,u,s.optionDescription]);const O=function(e){let{value:l}=e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=N(t.metricDescriptors,l);a(Object.assign({},t,{metricDescriptor:r},n)),y(Object.assign({},r,{type:l}))},L=e=>{const t=e.map((e=>({value:e.service,label:(0,c.startCase)(e.serviceShortName)})));return t.length>0?(0,c.uniqBy)(t,(e=>e.value)):[]};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(M,{children:[(0,i.jsx)(B,{labelWidth:r.XC,label:"Service",htmlFor:`${e.refId}-service`,children:(0,i.jsx)(n.Select,{width:r.Lh,onChange:e=>{let{value:l}=e;const n=v.filter((e=>e.service===T.replace(l))).map((e=>({service:e.service,value:e.type,label:e.displayName,description:e.description})));n.length>0&&!n.some((e=>e.value===T.replace(E)))?O(n[0],{service:l,metrics:n}):a(Object.assign({},t,{service:l,metrics:n}))},value:[...p,...g].find((e=>e.value===h)),options:[{label:"Template Variables",options:g},...p],placeholder:"Select Services",inputId:`${e.refId}-service`})}),(0,i.jsx)(B,{label:"Metric name",labelWidth:r.qN,htmlFor:`${e.refId}-select-metric`,children:(0,i.jsx)(n.Select,{width:r.Lh,onChange:O,value:[...m,...g].find((e=>e.value===E)),options:[{label:"Template Variables",options:g},...m],placeholder:"Select Metric",inputId:`${e.refId}-select-metric`})})]}),b(t.metricDescriptor)]})}const d=e=>s.css` label: grafana-select-option-description; font-weight: normal; font-style: italic; color: ${e.colors.text.secondary}; `;var p=a(2986);const h=e=>{var t,a;let{refId:o,labels:s=[],query:c,onChange:u,variableOptionGroup:d,metricDescriptor:h}=e;const m=(0,l.useMemo)((()=>[d,...(0,p.gY)([...s,...r.$e])]),[s,d]);return(0,i.jsxs)(M,{label:"Group by",tooltip:"You can reduce the amount of data returned for a metric by combining different time series. To combine multiple time series, you can specify a grouping and a function. Grouping is done on the basis of labels. The grouping function is used to combine the time series in the group into a single time series.",htmlFor:`${o}-group-by`,children:[(0,i.jsx)(n.MultiSelect,{inputId:`${o}-group-by`,width:r.d7,placeholder:"Choose label",options:m,value:null!==(t=c.groupBys)&&void 0!==t?t:[],onChange:e=>{u(Object.assign({},c,{groupBys:e.map((e=>e.value))}))}}),(0,i.jsx)(C,{metricDescriptor:h,templateVariableOptions:d.options,crossSeriesReducer:c.crossSeriesReducer,groupBys:null!==(a=c.groupBys)&&void 0!==a?a:[],onChange:e=>u(Object.assign({},c,{crossSeriesReducer:e})),refId:o})]})},m=e=>{let{refId:t,templateVariableOptions:a,onChange:l,query:n,customMetaData:o,datasource:s}=e;return(0,i.jsxs)(M,{label:"Alignment function",tooltip:"The process of alignment consists of collecting all data points received in a fixed length of time, applying a function to combine those data points, and assigning a timestamp to the result.",fillComponent:(0,i.jsx)(x,{datasource:s,customMetaData:o}),htmlFor:`${t}-alignment-function`,children:[(0,i.jsx)(L,{inputId:`${t}-alignment-function`,templateVariableOptions:a,query:n,onChange:l}),(0,i.jsx)(B,{label:"Alignment period",htmlFor:`${t}-alignment-period`,children:(0,i.jsx)(V,{inputId:`${t}-alignment-period`,selectWidth:r.Lh,templateVariableOptions:a,current:n.alignmentPeriod,onChange:e=>l(Object.assign({},n,{alignmentPeriod:e})),aligmentPeriods:r.dD})})]})};var v=a(43215);const E=["value","isOpen","invalid"],g=["value"];function I(e,t){if(null==e)return{};var a,l,n={},r=Object.keys(e);for(l=0;l=0||(n[a]=e[a]);return n}const T=["=","!=","=~","!=~"],f=l.forwardRef(((e,t)=>{let a=I(e,E);return(0,i.jsx)(n.Button,Object.assign({},a,{ref:t,variant:"secondary",icon:"plus","aria-label":"Add filter"}))}));f.displayName="FilterButton";const y=l.forwardRef(((e,t)=>{let{value:a}=e,l=I(e,g);return(0,i.jsx)(n.Button,Object.assign({},l,{ref:t,variant:"secondary",children:(0,i.jsx)("span",{className:"query-segment-operator",children:null==a?void 0:a.label})}))}));y.displayName="OperatorButton";const b=e=>{var t;let{labels:a={},filters:o,onChange:s,variableOptionGroup:u}=e;const d=(0,l.useMemo)((()=>(0,p.mi)(o)),[o]),h=(0,l.useMemo)((()=>[u,...(0,p.gY)(Object.keys(a))]),[a,u]),m=(0,l.useCallback)((e=>{const t=(0,c.flatten)(e.map((e=>{let{key:t,operator:a,value:l,condition:n}=e;return[t,a,l,n]})));return t.slice(0,t.length-1)}),[]),E=()=>(0,i.jsx)(n.Select,{allowCustomValue:!0,options:[u,...(0,p.gY)(Object.keys(a))],onChange:e=>{let{value:t=""}=e;return s(m([...d,{key:t,operator:"=",condition:"AND",value:""}]))},menuPlacement:"bottom",renderControl:f});return(0,i.jsx)(M,{label:"Filter",tooltip:"To reduce the amount of data charted, apply a filter. A filter has three components: a label, a comparison, and a value. The comparison can be an equality, inequality, or regular expression.",noFillEnd:d.length>1,children:(0,i.jsxs)(n.VerticalGroup,{spacing:"xs",width:"auto",children:[d.map(((e,l)=>{let{key:o,operator:c,value:p,condition:g}=e;h.some((e=>e.options?h.some((e=>e.label===o)):e.label===o))||h.push({label:o,value:o});const I=a.hasOwnProperty(o)?[u,...a[o].map(v.toOption)]:[u];return I.some((e=>e.label===p))||I.push({label:p,value:p}),(0,i.jsxs)(n.HorizontalGroup,{spacing:"xs",width:"auto",children:[(0,i.jsx)(n.Select,{"aria-label":"Filter label key",width:r.Lh,allowCustomValue:!0,formatCreateLabel:e=>`Use label key: ${e}`,value:o,options:h,onChange:e=>{let{value:t=""}=e;s(m(d.map(((e,a)=>a===l?{key:t,operator:c,condition:g,value:""}:e))))}}),(0,i.jsx)(n.Select,{value:c,options:T.map(v.toOption),onChange:e=>{let{value:t="="}=e;return s(m(d.map(((e,a)=>a===l?Object.assign({},e,{operator:t}):e))))},menuPlacement:"bottom",renderControl:y}),(0,i.jsx)(n.Select,{"aria-label":"Filter label value",width:r.Lh,formatCreateLabel:e=>`Use label value: ${e}`,allowCustomValue:!0,value:p,placeholder:"add filter value",options:I,onChange:e=>{let{value:t=""}=e;return s(m(d.map(((e,a)=>a===l?Object.assign({},e,{value:t}):e))))}}),(0,i.jsx)(n.Button,{variant:"secondary",size:"md",icon:"trash-alt","aria-label":"Remove",onClick:()=>s(m(d.filter(((e,t)=>t!==l))))}),l+1===d.length&&Object.values(d).every((e=>{let{value:t}=e;return t}))&&(t||(t=(0,i.jsx)(E,{})))]},l)})),!d.length&&(0,i.jsx)(E,{})]})})};var N;const O=()=>N||(N=(0,i.jsx)("div",{className:"gf-form grafana-info-box alert-info",children:(0,i.jsxs)("div",{children:[(0,i.jsx)("h5",{children:"Annotation Query Format"}),(0,i.jsxs)("p",{children:["An annotation is an event that is overlaid on top of graphs. Annotation rendering is expensive so it is important to limit the number of rows returned."," "]}),(0,i.jsx)("p",{children:"The Title and Text fields support templating and can use data returned from the query. For example, the Title field could have the following text:"}),(0,i.jsxs)("code",{children:["{{metric.type}}"," has value: ","{{metric.value}}"]}),(0,i.jsxs)("p",{children:["Example Result: ",(0,i.jsx)("code",{children:"monitoring.googleapis.com/uptime_check/http_status has this value: 502"})]}),(0,i.jsx)("label",{children:"Patterns:"}),(0,i.jsxs)("p",{children:[(0,i.jsx)("code",{children:"{{metric.value}}"})," = value of the metric/point"]}),(0,i.jsxs)("p",{children:[(0,i.jsx)("code",{children:"{{metric.type}}"})," = metric type e.g. compute.googleapis.com/instance/cpu/usage_time"]}),(0,i.jsxs)("p",{children:[(0,i.jsx)("code",{children:"{{metric.name}}"})," = name part of metric e.g. instance/cpu/usage_time"]}),(0,i.jsxs)("p",{children:[(0,i.jsx)("code",{children:"{{metric.service}}"})," = service part of metric e.g. compute"]}),(0,i.jsxs)("p",{children:[(0,i.jsx)("code",{children:"{{metric.label.label_name}}"})," = Metric label metadata e.g. metric.label.instance_name"]}),(0,i.jsxs)("p",{children:[(0,i.jsx)("code",{children:"{{resource.label.label_name}}"})," = Resource label metadata e.g. resource.label.zone"]})]})})),L=e=>{let{inputId:t,query:a,templateVariableOptions:o,onChange:s}=e;const{valueType:c,metricKind:u,perSeriesAligner:d,preprocessor:h}=a,{perSeriesAligner:m,alignOptions:v}=(0,l.useMemo)((()=>(0,p.ID)(c,u,d,h)),[c,u,d,h]);return(0,i.jsx)(n.Select,{width:r.Lh,onChange:e=>{let{value:t}=e;return s(Object.assign({},a,{perSeriesAligner:t}))},value:[...v,...o].find((e=>e.value===m)),options:[{label:"Template Variables",options:o},{label:"Alignment options",expanded:!0,options:v}],placeholder:"Select Alignment",inputId:t})},x=e=>{let{customMetaData:t,datasource:a}=e;const{perSeriesAligner:n,alignmentPeriod:o}=t,s=(0,l.useMemo)((()=>{var e;if(!o||!n)return"";const t=r.Eu.find((e=>e.value===a.templateSrv.replace(n))),l=parseInt(null!=o?o:"".replace(/[^0-9]/g,""),10);return`${v.rangeUtil.secondsToHms(l)} interval (${null!==(e=null==t?void 0:t.text)&&void 0!==e?e:""})`}),[a,n,o]);return(0,i.jsx)("label",{children:s})},A=e=>{let{refId:t,value:a="",onChange:o}=e;const[s,u]=(0,l.useState)(null!=a?a:""),d=(0,c.debounce)(o,1e3);return o=e=>{u(e.target.value),d(e.target.value)},(0,i.jsx)(M,{label:"Alias by",htmlFor:`${t}-alias-by`,children:(0,i.jsx)(n.Input,{id:`${t}-alias-by`,width:r.d7,value:s,onChange:o})})},C=e=>{const t=j(e),a=G(t,e);return(0,i.jsx)(B,{labelWidth:18,label:"Group by function","data-testid":"cloud-monitoring-aggregation",htmlFor:`${e.refId}-group-by-function`,children:(0,i.jsx)(n.Select,{width:16,onChange:t=>{let{value:a}=t;return e.onChange(a)},value:a,options:[{label:"Template Variables",options:e.templateVariableOptions},{label:"Aggregations",expanded:!0,options:t}],placeholder:"Select Reducer",inputId:`${e.refId}-group-by-function`})})},j=e=>{let{metricDescriptor:t}=e;const a=null==t?void 0:t.valueType,n=null==t?void 0:t.metricKind;return(0,l.useMemo)((()=>a&&n?(0,p.A_)(a,n).map((e=>Object.assign({},e,{label:e.text}))):[]),[a,n])},G=(e,t)=>(0,l.useMemo)((()=>[...e,...t.templateVariableOptions].find((e=>e.value===t.crossSeriesReducer))),[e,t.crossSeriesReducer,t.templateVariableOptions]);var D=a(80425),U=a(18809);a(54834);const _=["children","label","tooltip","fillComponent","noFillEnd","labelWidth","htmlFor"],S=["children","label","tooltip","labelWidth"];function $(e,t){if(null==e)return{};var a,l,n={},r=Object.keys(e);for(l=0;l=0||(n[a]=e[a]);return n}const R=e=>{let{label:t,onChange:a,value:l,options:r,allowCustomValue:o=!1}=e;return(0,i.jsx)(n.InlineField,{label:t,labelWidth:20,children:(0,i.jsx)(n.Select,{width:25,allowCustomValue:o,value:l,onChange:e=>{let{value:t}=e;return a(t)},options:r})})},M=e=>{let{children:t,label:a,tooltip:l,fillComponent:o,noFillEnd:c=!1,labelWidth:u=r.XC,htmlFor:d}=e,p=$(e,_);return(0,i.jsxs)("div",Object.assign({className:"gf-form"},p,{children:[a&&(0,i.jsx)(n.InlineLabel,{width:u,tooltip:l,htmlFor:d,children:a}),(0,i.jsx)("div",{className:s.css` margin-right: 4px; `,children:(0,i.jsx)(n.HorizontalGroup,{spacing:"xs",width:"auto",children:t})}),(0,i.jsx)("div",{className:"gf-form--grow",children:c||(0,i.jsx)("div",{className:"gf-form-label gf-form-label--grow",children:o})})]}))},B=e=>{let{children:t,label:a,tooltip:l,labelWidth:o=r.qN}=e,s=$(e,S);return(0,i.jsxs)(i.Fragment,{children:[a&&(0,i.jsx)(n.InlineLabel,Object.assign({width:o,tooltip:l},s,{children:a})),t]})};function P(e){let{refId:t,query:a,labels:l,datasource:n,onChange:r,onMetricTypeChange:o,customMetaData:s,variableOptionGroup:c}=e;return(0,i.jsx)(u,{refId:t,templateSrv:n.templateSrv,projectName:a.projectName,metricType:a.metricType,templateVariableOptions:c.options,datasource:n,onChange:o,children:e=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(b,{labels:l,filters:a.filters,onChange:e=>r(Object.assign({},a,{filters:e})),variableOptionGroup:c}),(0,i.jsx)(k,{metricDescriptor:e,query:a,onChange:r}),(0,i.jsx)(h,{refId:t,labels:Object.keys(l),query:a,onChange:r,variableOptionGroup:c,metricDescriptor:e}),(0,i.jsx)(m,{refId:t,datasource:n,templateVariableOptions:c.options,query:a,customMetaData:s,onChange:r})]})})}const H=l.memo(P);function V(e){let{inputId:t,templateVariableOptions:a,onChange:r,current:o,selectWidth:s,disabled:c,aligmentPeriods:u}=e;const d=(0,l.useMemo)((()=>u.map((e=>Object.assign({},e,{label:e.text})))),[u]),p=(0,l.useMemo)((()=>d.filter((e=>!e.hidden))),[d]);return(0,i.jsx)(n.Select,{width:s,onChange:e=>{let{value:t}=e;return r(t)},value:[...d,...a].find((e=>e.value===o)),options:[{label:"Template Variables",options:a},{label:"Aggregations",expanded:!0,options:p}],placeholder:"Select Period",inputId:t,disabled:c,allowCustomValue:!0})}var w=a(25576);const F={label:"None",value:w.mG.None},k=e=>{var t;let{query:a,metricDescriptor:l,onChange:r}=e;const o=K(l);return(0,i.jsx)(M,{label:"Pre-processing",tooltip:"Preprocessing options are displayed when the selected metric has a metric kind of delta or cumulative. The specific options available are determined by the metic's value type. If you select 'Rate', data points are aligned and converted to a rate per time series. If you select 'Delta', data points are aligned by their delta (difference) per time series",children:(0,i.jsx)(n.RadioButtonGroup,{onChange:e=>{const{valueType:t,metricKind:l,perSeriesAligner:n}=a,{perSeriesAligner:i}=(0,p.ID)(t,l,n,e);r(Object.assign({},a,{preprocessor:e,perSeriesAligner:i}))},value:null!==(t=a.preprocessor)&&void 0!==t?t:w.mG.None,options:o})})},K=e=>{const t=null==e?void 0:e.metricKind,a=null==e?void 0:e.valueType;return(0,l.useMemo)((()=>{if(!t||t===w.lH.GAUGE||a===w.$h.DISTRIBUTION)return[F];const e=[F,{label:"Rate",value:w.mG.Rate,description:"Data points are aligned and converted to a rate per time series"}];return t===w.lH.CUMULATIVE?[...e,{label:"Delta",value:w.mG.Delta,description:"Data points are aligned by their delta (difference) per time series"}]:e}),[t,a])}},22002:(e,t,a)=>{"use strict";a.d(t,{$e:()=>h,Eu:()=>c,IR:()=>m,Lh:()=>s,Ry:()=>p,XC:()=>i,XI:()=>v,d7:()=>r,dD:()=>d,lx:()=>u,qN:()=>o});var l=a(28153),n=a(25576);const r=71,i=19,o=14,s=28,c=(l.GoogleAuthType.JWT,l.GoogleAuthType.GCE,[{text:"none",value:"ALIGN_NONE",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY,n.$h.DISTRIBUTION,n.$h.STRING,n.$h.VALUE_TYPE_UNSPECIFIED,n.$h.BOOL],metricKinds:[n.lH.GAUGE]},{text:"delta",value:"ALIGN_DELTA",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY,n.$h.DISTRIBUTION],metricKinds:[n.lH.CUMULATIVE,n.lH.DELTA]},{text:"rate",value:"ALIGN_RATE",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY],metricKinds:[n.lH.CUMULATIVE,n.lH.DELTA]},{text:"interpolate",value:"ALIGN_INTERPOLATE",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY],metricKinds:[n.lH.GAUGE]},{text:"next older",value:"ALIGN_NEXT_OLDER",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY,n.$h.DISTRIBUTION,n.$h.STRING,n.$h.VALUE_TYPE_UNSPECIFIED,n.$h.BOOL],metricKinds:[n.lH.GAUGE]},{text:"min",value:"ALIGN_MIN",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY],metricKinds:[n.lH.GAUGE,n.lH.DELTA]},{text:"max",value:"ALIGN_MAX",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY],metricKinds:[n.lH.GAUGE,n.lH.DELTA]},{text:"mean",value:"ALIGN_MEAN",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY],metricKinds:[n.lH.GAUGE,n.lH.DELTA]},{text:"count",value:"ALIGN_COUNT",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY,n.$h.BOOL],metricKinds:[n.lH.GAUGE,n.lH.DELTA]},{text:"sum",value:"ALIGN_SUM",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY,n.$h.DISTRIBUTION],metricKinds:[n.lH.GAUGE,n.lH.DELTA]},{text:"stddev",value:"ALIGN_STDDEV",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY],metricKinds:[n.lH.GAUGE,n.lH.DELTA]},{text:"count true",value:"ALIGN_COUNT_TRUE",valueTypes:[n.$h.BOOL],metricKinds:[n.lH.GAUGE]},{text:"count false",value:"ALIGN_COUNT_FALSE",valueTypes:[n.$h.BOOL],metricKinds:[n.lH.GAUGE]},{text:"fraction true",value:"ALIGN_FRACTION_TRUE",valueTypes:[n.$h.BOOL],metricKinds:[n.lH.GAUGE]},{text:"percentile 99",value:"ALIGN_PERCENTILE_99",valueTypes:[n.$h.DISTRIBUTION],metricKinds:[n.lH.GAUGE,n.lH.DELTA]},{text:"percentile 95",value:"ALIGN_PERCENTILE_95",valueTypes:[n.$h.DISTRIBUTION],metricKinds:[n.lH.GAUGE,n.lH.DELTA]},{text:"percentile 50",value:"ALIGN_PERCENTILE_50",valueTypes:[n.$h.DISTRIBUTION],metricKinds:[n.lH.GAUGE,n.lH.DELTA]},{text:"percentile 05",value:"ALIGN_PERCENTILE_05",valueTypes:[n.$h.DISTRIBUTION],metricKinds:[n.lH.GAUGE,n.lH.DELTA]},{text:"percent change",value:"ALIGN_PERCENT_CHANGE",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY],metricKinds:[n.lH.GAUGE,n.lH.DELTA]}]),u=[{text:"none",value:"REDUCE_NONE",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY,n.$h.DISTRIBUTION,n.$h.BOOL,n.$h.STRING],metricKinds:[n.lH.GAUGE,n.lH.DELTA,n.lH.CUMULATIVE,n.lH.METRIC_KIND_UNSPECIFIED]},{text:"mean",value:"REDUCE_MEAN",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY,n.$h.DISTRIBUTION],metricKinds:[n.lH.GAUGE,n.lH.DELTA,n.lH.CUMULATIVE]},{text:"min",value:"REDUCE_MIN",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY],metricKinds:[n.lH.GAUGE,n.lH.DELTA,n.lH.CUMULATIVE,n.lH.METRIC_KIND_UNSPECIFIED]},{text:"max",value:"REDUCE_MAX",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY],metricKinds:[n.lH.GAUGE,n.lH.DELTA,n.lH.CUMULATIVE,n.lH.METRIC_KIND_UNSPECIFIED]},{text:"sum",value:"REDUCE_SUM",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY,n.$h.DISTRIBUTION],metricKinds:[n.lH.GAUGE,n.lH.DELTA,n.lH.CUMULATIVE,n.lH.METRIC_KIND_UNSPECIFIED]},{text:"std. dev.",value:"REDUCE_STDDEV",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY,n.$h.DISTRIBUTION],metricKinds:[n.lH.GAUGE,n.lH.DELTA,n.lH.CUMULATIVE,n.lH.METRIC_KIND_UNSPECIFIED]},{text:"count",value:"REDUCE_COUNT",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY,n.$h.DISTRIBUTION,n.$h.BOOL,n.$h.STRING],metricKinds:[n.lH.GAUGE,n.lH.DELTA,n.lH.CUMULATIVE]},{text:"count true",value:"REDUCE_COUNT_TRUE",valueTypes:[n.$h.BOOL],metricKinds:[n.lH.GAUGE,n.lH.DELTA]},{text:"count false",value:"REDUCE_COUNT_FALSE",valueTypes:[n.$h.BOOL],metricKinds:[n.lH.GAUGE,n.lH.DELTA]},{text:"99th percentile",value:"REDUCE_PERCENTILE_99",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY,n.$h.DISTRIBUTION],metricKinds:[n.lH.GAUGE,n.lH.DELTA,n.lH.CUMULATIVE]},{text:"95th percentile",value:"REDUCE_PERCENTILE_95",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY,n.$h.DISTRIBUTION],metricKinds:[n.lH.GAUGE,n.lH.DELTA,n.lH.CUMULATIVE]},{text:"50th percentile",value:"REDUCE_PERCENTILE_50",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY,n.$h.DISTRIBUTION],metricKinds:[n.lH.GAUGE,n.lH.DELTA,n.lH.CUMULATIVE]},{text:"5th percentile",value:"REDUCE_PERCENTILE_05",valueTypes:[n.$h.INT64,n.$h.DOUBLE,n.$h.MONEY,n.$h.DISTRIBUTION],metricKinds:[n.lH.GAUGE,n.lH.DELTA,n.lH.CUMULATIVE]}],d=[{text:"grafana auto",value:"grafana-auto"},{text:"stackdriver auto",value:"stackdriver-auto",hidden:!0},{text:"cloud monitoring auto",value:"cloud-monitoring-auto"},{text:"1m",value:"+60s"},{text:"2m",value:"+120s"},{text:"5m",value:"+300s"},{text:"10m",value:"+600s"},{text:"30m",value:"+1800s"},{text:"1h",value:"+3600s"},{text:"3h",value:"+7200s"},{text:"6h",value:"+21600s"},{text:"1d",value:"+86400s"},{text:"3d",value:"+259200s"},{text:"1w",value:"+604800s"}],p=[{text:"auto",value:"auto"},{text:"1m",value:"1m"},{text:"2m",value:"2m"},{text:"5m",value:"5m"},{text:"10m",value:"10m"},{text:"30m",value:"30m"},{text:"1h",value:"1h"},{text:"3h",value:"3h"},{text:"6h",value:"6h"},{text:"1d",value:"1d"},{text:"3d",value:"3d"},{text:"1w",value:"1w"}],h=["metadata.system_labels.cloud_account","metadata.system_labels.name","metadata.system_labels.region","metadata.system_labels.state","metadata.system_labels.instance_group","metadata.system_labels.node_name","metadata.system_labels.service_name","metadata.system_labels.top_level_controller_type","metadata.system_labels.top_level_controller_name","metadata.system_labels.container_image"],m=[{label:"SLI Value",value:"select_slo_health"},{label:"SLO Compliance",value:"select_slo_compliance"},{label:"SLO Error Budget Remaining",value:"select_slo_budget_fraction"}],v=[{label:"Metrics",value:n.xL.METRICS},{label:"Service Level Objectives (SLO)",value:n.xL.SLO}]},2986:(e,t,a)=>{"use strict";a.d(t,{A_:()=>p,FL:()=>u,ID:()=>m,Qd:()=>h,Qf:()=>c,gY:()=>v,mi:()=>E,oU:()=>d,qA:()=>s});var l=a(82897),n=a(90923),r=a(22002),i=a(25576);const o=(0,n.getTemplateSrv)(),s=e=>(0,l.uniqBy)(e,"service"),c=(e,t)=>e.filter((e=>e.service===t)),u=(e,t,a,l)=>{const n=c(e,l).map((e=>({value:e.type,name:e.displayName}))),r=n.some((e=>e.value===a)),i=n.length?n[0].value:"";return{metricTypes:n,selectedMetricType:r?t:i}},d=(e,t,a)=>(a&&a===i.mG.Rate&&(t=i.lH.GAUGE),e?r.Eu.filter((a=>-1!==a.valueTypes.indexOf(e)&&-1!==a.metricKinds.indexOf(t))):[]),p=(e,t)=>t?r.lx.filter((a=>-1!==a.valueTypes.indexOf(e)&&-1!==a.metricKinds.indexOf(t))):[],h=async(e,t,a)=>{const l=await e.getLabels(t,"handleLabelKeysQuery",a);return[...Object.keys(l),...r.$e]},m=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i.$h.DOUBLE,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.lH.GAUGE,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i.CS.ALIGN_MEAN,l=arguments.length>3?arguments[3]:void 0;const n=d(e,t,l).map((e=>Object.assign({},e,{label:e.text})));return n.some((e=>e.value===o.replace(a)))||(a=n.length>0?n[0].value:i.CS.ALIGN_MEAN),{alignOptions:n,perSeriesAligner:a}},v=e=>{const t=e.reduce(((e,t)=>{const a=t.split(".").map(l.startCase),n=(2===a.length?a:(0,l.initial)(a)).join(" "),r={value:t,label:t};return e[n]?e[n]=[...e[n],r]:e[n]=[r],e}),{});return Object.entries(t).map((e=>{let[t,a]=e;return{label:t,options:a,expanded:!0}}),[])},E=e=>(0,l.chunk)(e,4).map((e=>{let[t,a,l,n="AND"]=e;return{key:t,operator:a,value:l,condition:n}}))},25576:(e,t,a)=>{"use strict";a.d(t,{$h:()=>c,Bp:()=>n,CS:()=>u,je:()=>i,lH:()=>s,mG:()=>o,xL:()=>r});var l=a(28153);l.GoogleAuthType.JWT,l.GoogleAuthType.GCE;let n,r,i,o,s,c,u;!function(e){e.Projects="projects",e.Services="services",e.DefaultProject="defaultProject",e.MetricTypes="metricTypes",e.LabelKeys="labelKeys",e.LabelValues="labelValues",e.ResourceTypes="resourceTypes",e.Aggregations="aggregations",e.Aligners="aligners",e.AlignmentPeriods="alignmentPeriods",e.Selectors="selectors",e.SLOServices="sloServices",e.SLO="slo"}(n||(n={})),function(e){e.METRICS="metrics",e.SLO="slo"}(r||(r={})),function(e){e.Visual="visual",e.MQL="mql"}(i||(i={})),function(e){e.None="none",e.Rate="rate",e.Delta="delta"}(o||(o={})),function(e){e.METRIC_KIND_UNSPECIFIED="METRIC_KIND_UNSPECIFIED",e.GAUGE="GAUGE",e.DELTA="DELTA",e.CUMULATIVE="CUMULATIVE"}(s||(s={})),function(e){e.VALUE_TYPE_UNSPECIFIED="VALUE_TYPE_UNSPECIFIED",e.BOOL="BOOL",e.INT64="INT64",e.DOUBLE="DOUBLE",e.STRING="STRING",e.DISTRIBUTION="DISTRIBUTION",e.MONEY="MONEY"}(c||(c={})),function(e){e.ALIGN_DELTA="ALIGN_DELTA",e.ALIGN_RATE="ALIGN_RATE",e.ALIGN_INTERPOLATE="ALIGN_INTERPOLATE",e.ALIGN_NEXT_OLDER="ALIGN_NEXT_OLDER",e.ALIGN_MIN="ALIGN_MIN",e.ALIGN_MAX="ALIGN_MAX",e.ALIGN_MEAN="ALIGN_MEAN",e.ALIGN_COUNT="ALIGN_COUNT",e.ALIGN_SUM="ALIGN_SUM",e.ALIGN_STDDEV="ALIGN_STDDEV",e.ALIGN_COUNT_TRUE="ALIGN_COUNT_TRUE",e.ALIGN_COUNT_FALSE="ALIGN_COUNT_FALSE",e.ALIGN_FRACTION_TRUE="ALIGN_FRACTION_TRUE",e.ALIGN_PERCENTILE_99="ALIGN_PERCENTILE_99",e.ALIGN_PERCENTILE_95="ALIGN_PERCENTILE_95",e.ALIGN_PERCENTILE_50="ALIGN_PERCENTILE_50",e.ALIGN_PERCENTILE_05="ALIGN_PERCENTILE_05",e.ALIGN_PERCENT_CHANGE="ALIGN_PERCENT_CHANGE",e.ALIGN_NONE="ALIGN_NONE"}(u||(u={}))},15925:(e,t,a)=>{var l=a(43215),n=a(69783),r=a(68404),i=a(82897);var o=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(r),s=function(){return s=Object.assign||function(e){for(var t,a=1,l=arguments.length;a0)&&!(l=r.next()).done;)i.push(l.value)}catch(e){n={error:e}}finally{try{l&&!l.done&&(a=r.return)&&a.call(r)}finally{if(n)throw n.error}}return i}var u,d=["private_key","token_uri","client_email","project_id"],p=function(e){var t=e.onChange,a=c(r.useState(),2),l=a[0],i=a[1],s=c(r.useState(null),2),u=s[0],d=s[1],p=n.useTheme2(),m=r.useCallback((function(e){i(null),d(!0)}),[d]),v=r.useCallback((function(e){d(null),i(null)}),[d]),E=r.useCallback((function(e){if(""!==e.trim()){var a=void 0;try{a=JSON.parse(e)}catch(e){i("Invalid JWT token")}var l=h(a);l.isValid?t({privateKey:a.private_key,tokenUri:a.token_uri,clientEmail:a.client_email,projectId:a.project_id}):i(l.error)}}),[i,t]);return o.default.createElement(o.default.Fragment,null,o.default.createElement(n.Field,{label:"JWT token",invalid:Boolean(l),description:u?"Paste JWT token below":"Upload or paste Google JWT token",error:l},o.default.createElement(o.default.Fragment,null,!0!==u&&o.default.createElement("div",{"data-testid":"Configuration drop zone"},o.default.createElement(n.FileDropzone,{options:{multiple:!1,accept:"application/json"},readAs:"readAsText",onLoad:function(e){E(e),d(!1)}},o.default.createElement("p",{style:{margin:0,fontSize:""+p.typography.h4.fontSize,textAlign:"center"}},"Drop the Google JWT file here",o.default.createElement("br",null),o.default.createElement("br",null),o.default.createElement(n.LinkButton,{fill:"outline"},"Click to browse files")))),u&&o.default.createElement(n.TextArea,{"data-testid":"Configuration text area",autoFocus:!0,invalid:Boolean(l),placeholder:"Paste Google JWT token here",onBlur:function(e){return E(e.currentTarget.value)},rows:12}))),!u&&o.default.createElement(n.Field,null,o.default.createElement(n.Button,{"data-testid":"Paste JWT button",type:"button",fill:"outline",style:{color:""+p.colors.primary.text},onClick:m},"Paste JWT Token")),u&&l&&o.default.createElement(n.Field,null,o.default.createElement(n.Button,{type:"button",fill:"outline",style:{color:""+p.colors.primary.text},onClick:v},"Upload JWT Token")))},h=function(e){if(!i.isObject(e))return{isValid:!1,error:"Invalid JWT token"};var t=d.filter((function(t){return!e[t]}));return t.length>0?{isValid:!1,error:"Missing keys: "+t.join(", ")}:{isValid:!0}},m=function(e){var t=e.options,a=e.onReset,l=e.onChange;return o.default.createElement("div",{"data-testid":"JWT form"},o.default.createElement(n.Field,{label:"Project ID"},o.default.createElement(n.Input,{id:"defaultProject",width:60,value:t.defaultProject||"",onChange:l("defaultProject")})),o.default.createElement(n.Field,{label:"Client email"},o.default.createElement(n.Input,{width:60,id:"clientEmail",value:t.clientEmail||"",onChange:l("clientEmail")})),o.default.createElement(n.Field,{label:"Token URI"},o.default.createElement(n.Input,{width:60,id:"tokenUri",value:t.tokenUri||"",onChange:l("tokenUri")})),o.default.createElement(n.Field,{label:"Private key",disabled:!0},o.default.createElement(n.Input,{width:60,id:"privateKey",readOnly:!0,placeholder:"Private key configured",addonAfter:o.default.createElement(n.Tooltip,{content:"Click to clear the uploaded JWT token and upload a new one"},o.default.createElement(n.Button,{"data-testid":"Reset JWT button",icon:"sync",size:"xs",onClick:function(){return a(null)},fill:"outline"},"Reset token"))})))};t.GoogleAuthType=void 0,(u=t.GoogleAuthType||(t.GoogleAuthType={})).JWT="jwt",u.GCE="gce";var v=[{label:"Google JWT File",value:t.GoogleAuthType.JWT,ariaLabel:"JWT button"},{label:"GCE Default Service Account",value:t.GoogleAuthType.GCE,ariaLabel:"GCE button"}];t.ConnectionConfig=function(e){var a=e.options,r=e.onOptionsChange,i=a.jsonData,c=a.secureJsonFields,u=a.secureJsonData;i.authenticationType||(i.authenticationType=t.GoogleAuthType.JWT);var d=i.authenticationType===t.GoogleAuthType.JWT||void 0===i.authenticationType,h=Boolean(c&&c.privateKey&&i.clientEmail&&i.defaultProject&&i.tokenUri);return o.default.createElement(o.default.Fragment,null,o.default.createElement(n.FieldSet,{label:"Authentication"},o.default.createElement(n.Field,{label:"Authentication type"},o.default.createElement(n.RadioButtonGroup,{options:v,value:i.authenticationType||t.GoogleAuthType.JWT,onChange:function(e){r(s(s({},a),{jsonData:s(s({},a.jsonData),{authenticationType:e})}))}}))),d&&o.default.createElement(n.FieldSet,{label:"JWT Key Details"},h?o.default.createElement(m,{options:a.jsonData,onReset:function(e){var t=s({},u),l=e?s(s({},a.jsonData),e):s({},a.jsonData);delete l.clientEmail,delete l.defaultProject,delete l.tokenUri,delete t.privateKey,r(s(s({},a),{secureJsonData:t,jsonData:l}))},onChange:function(t){return l.onUpdateDatasourceJsonDataOption(e,t)}}):o.default.createElement(p,{onChange:function(e){r(s(s({},a),{secureJsonFields:s(s({},c),{privateKey:!0}),secureJsonData:s(s({},u),{privateKey:e.privateKey}),jsonData:s(s({},i),{clientEmail:e.clientEmail,defaultProject:e.projectId,tokenUri:e.tokenUri})}))}})," "),o.default.createElement("div",{className:"grafana-info-box",style:{marginTop:"16px"},"data-testid":"Configuration help box"},o.default.createElement("p",null,"Don’t know how to get a service account key file or create a service account? Read more"," ",o.default.createElement("a",{className:"external-link",target:"_blank",rel:"noopener noreferrer",href:"https://grafana.com/docs/grafana/latest/datasources/google-cloud-monitoring/google-authentication/"},"in the documentation."))),!d&&o.default.createElement(n.Alert,{title:"",severity:"info"},"Verify GCE default service account by clicking Save & Test"))}},28153:(e,t,a)=>{"use strict";e.exports=a(15925)}}]); //# sourceMappingURL=7379.40eb8461084ddb7791b3.js.map