"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[1893],{23703(X,d,e){e.r(d),e.d(d,{WriteTargetConfig:()=>D,WriteTargetConfigUnconnected:()=>u,default:()=>S});var t=e(74848),M=e(22803),n=e(96540),O=e(49785),h=e(71468),i=e(32899),s=e(92745),m=e(78282),C=e(30703),T=e(45861),E=e(37386),v=e(63527),W=e(63142),l=e(45229),P=e(13791),L=e(84057),A=e(76792),g=e(80612),I=e(7009);function U(a){return{navModel:(0,L.tc)(a.navIndex,"recordedQueries"),prometheusWriteTarget:(0,I.S)(a.recordedQueries)}}const B={getPrometheusWriteTarget:g.Nd},K=(0,h.connect)(U,B),u=({navModel:a,prometheusWriteTarget:r,getPrometheusWriteTarget:o})=>{const[_,f]=(0,n.useState)(),[x,j]=(0,n.useState)(r?.remote_write_path),y=(0,W.of)(p),{register:N,handleSubmit:Q}=(0,O.mN)({defaultValues:r});(0,n.useEffect)(()=>{o()},[o]),(0,n.useEffect)(()=>{(async()=>{if(r){const V=await(0,m.l)().getInstanceSettings(r.data_source_uid);f(V)}})()},[r]);const Y=c=>{R(_?.uid,c.remote_write_path)},F=(0,t.jsxs)("span",{children:[(0,s.t)("recorded-queries.write-target-config-unconnected.select-data-source-label","Select the data source where metrics will be written"),(0,t.jsx)("a",{href:"https://grafana.com/docs/grafana/latest/enterprise/recorded-queries/#remote-write-target",className:y.docsLink,target:"_blank",rel:"noreferrer",children:(0,t.jsx)(C.I,{name:"info-circle"})})]});return(0,t.jsx)(P.Y,{navModel:a,children:(0,t.jsx)(P.Y.Contents,{children:(0,t.jsxs)("form",{onSubmit:Q(Y),style:{maxWidth:"600px"},children:[(0,t.jsx)(E.D,{label:F,children:(0,t.jsx)(A.sk,{onChange:f,current:_?.name,placeholder:(0,s.t)("recorded-queries.write-target-config-unconnected.placeholder-select-a-data-source","Select a data source"),type:"prometheus",noDefault:!0,alerting:!0,inputId:"data-source-picker"})}),(0,t.jsx)(E.D,{label:(0,s.t)("recorded-queries.write-target-config-unconnected.label-remote-write-path","Remote write path"),children:(0,t.jsx)(v.p,{...N("remote_write_path"),onChange:c=>j(c.currentTarget.value),placeholder:"/api/v1/write",id:"remote-write-path"})}),(0,t.jsx)(T.$n,{disabled:!x||!_,type:"submit",children:(0,t.jsx)(s.x6,{i18nKey:"recorded-queries.write-target-config-unconnected.save",children:"Save"})})]},r?.data_source_uid)})})};function R(a,r){(0,g.Of)({data_source_uid:a,remote_write_path:r}).then(()=>{l.A.emit(i.r1.alertSuccess,["Prometheus remote write target created"])}).catch(o=>{l.A.emit(i.r1.alertError,[o.data.message])})}const p=a=>({docsLink:(0,M.css)({marginLeft:a.spacing(1)})}),D=K(u),S=D}}]);

//# sourceMappingURL=WriteTargetConfig.394f0b541ee502d4801b.js.map