"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[890],{5562:(V,O,a)=>{a.d(O,{i:()=>y});var f=a(42844),l=a(27702),t=a(66310);const y=({hideLine:g=!1})=>{const M=(0,t.wW)(C);return g?l.createElement("hr",{className:M.dividerHideLine}):l.createElement("hr",{className:M.divider})},C=g=>({divider:(0,f.css)`
    margin: ${g.spacing(4,0)};
  `,dividerHideLine:(0,f.css)`
    border: none;
    margin: ${g.spacing(3,0)};
  `})},29126:(V,O,a)=>{a.d(O,{I:()=>P});var f=a(42844),l=a(27702),t=a(17312),y=a(78102),C=a(66310),g=a(71107),M=a(48024),W=a(42074),x=a(47449);function K({options:E,onOptionsChange:D}){const N=(0,C.wW)(U);return l.createElement("div",{className:N.container},l.createElement(g.Z,{className:N.row},l.createElement(M._,{tooltip:"Displays the node graph above the trace view. Default: disabled",label:"Enable node graph",labelWidth:26},l.createElement(W.x,{id:"enableNodeGraph",value:E.jsonData.nodeGraph?.enabled,onChange:b=>(0,t.tp)({onOptionsChange:D,options:E},"nodeGraph",{...E.jsonData.nodeGraph,enabled:b.currentTarget.checked})}))))}const P=({options:E,onOptionsChange:D})=>l.createElement(y._,{title:"Node graph",description:l.createElement(x.W,{description:"Show or hide the node graph visualization.",suffix:`${E.type}/#node-graph`,feature:"the node graph"})},l.createElement(K,{options:E,onOptionsChange:D})),U=E=>({infoText:(0,f.css)`
    label: infoText;
    padding-bottom: ${E.spacing(2)};
    color: ${E.colors.text.secondary};
  `,container:(0,f.css)`
    label: container;
    width: 100%;
  `,row:(0,f.css)`
    label: row;
    align-items: baseline;
  `})},35977:(V,O,a)=>{a.d(O,{Y:()=>b});var f=a(42844),l=a(27702),t=a(17312),y=a(19010),C=a(66310),g=a(71107),M=a(48024),W=a(66670),x=a(1128),K=a(53229),P=a(47449),U=a(71654),E=a(19059),D=a(51778);function N({options:s,onOptionsChange:d}){const z=(0,C.wW)(H);return l.createElement("div",{className:(0,f.css)({width:"100%"})},l.createElement(g.Z,{className:z.row},l.createElement(M._,{tooltip:"The Prometheus data source the trace is going to navigate to",label:"Data source",labelWidth:26},l.createElement(K.q,{inputId:"trace-to-metrics-data-source-picker",pluginId:"prometheus",current:s.jsonData.tracesToMetrics?.datasourceUid,noDefault:!0,width:40,onChange:T=>(0,t.tp)({onOptionsChange:d,options:s},"tracesToMetrics",{...s.jsonData.tracesToMetrics,datasourceUid:T.uid})})),s.jsonData.tracesToMetrics?.datasourceUid?l.createElement(W.zx,{type:"button",variant:"secondary",size:"sm",fill:"text",onClick:()=>{(0,t.tp)({onOptionsChange:d,options:s},"tracesToMetrics",{...s.jsonData.tracesToMetrics,datasourceUid:void 0})}},"Clear"):null),l.createElement(g.Z,null,l.createElement(U.w,{label:(0,D.mH)("start"),tooltip:(0,D.rr)("start"),value:s.jsonData.tracesToMetrics?.spanStartTimeShift||"",onChange:T=>{(0,t.tp)({onOptionsChange:d,options:s},"tracesToMetrics",{...s.jsonData.tracesToMetrics,spanStartTimeShift:T})},isInvalidError:D.Ny})),l.createElement(g.Z,null,l.createElement(U.w,{label:(0,D.mH)("end"),tooltip:(0,D.rr)("end"),value:s.jsonData.tracesToMetrics?.spanEndTimeShift||"",onChange:T=>{(0,t.tp)({onOptionsChange:d,options:s},"tracesToMetrics",{...s.jsonData.tracesToMetrics,spanEndTimeShift:T})},isInvalidError:D.Ny})),l.createElement(g.Z,null,l.createElement(M._,{tooltip:"Tags that will be used in the metrics query",label:"Tags",labelWidth:26},l.createElement(E.a,{values:s.jsonData.tracesToMetrics?.tags??[],onChange:T=>(0,t.tp)({onOptionsChange:d,options:s},"tracesToMetrics",{...s.jsonData.tracesToMetrics,tags:T})}))),s.jsonData.tracesToMetrics?.queries?.map((T,A)=>l.createElement("div",{key:A,className:z.queryRow},l.createElement(M._,{label:"Link Label",labelWidth:26,tooltip:"Descriptive label for the linked query"},l.createElement(x.I,{label:"Link Label",type:"text",allowFullScreen:!0,value:T.name,width:40,onChange:L=>{let R=s.jsonData.tracesToMetrics?.queries.slice()??[];R[A].name=L.currentTarget.value,(0,t.tp)({onOptionsChange:d,options:s},"tracesToMetrics",{...s.jsonData.tracesToMetrics,queries:R})}})),l.createElement(M._,{label:"Query",labelWidth:10,tooltip:"The Prometheus query that will run when navigating from a trace to metrics. Interpolate tags using the `$__tags` keyword",grow:!0},l.createElement(x.I,{label:"Query",type:"text",allowFullScreen:!0,value:T.query,onChange:L=>{let R=s.jsonData.tracesToMetrics?.queries.slice()??[];R[A].query=L.currentTarget.value,(0,t.tp)({onOptionsChange:d,options:s},"tracesToMetrics",{...s.jsonData.tracesToMetrics,queries:R})}})),l.createElement(W.zx,{variant:"destructive",title:"Remove query",icon:"times",type:"button",onClick:()=>{let L=s.jsonData.tracesToMetrics?.queries.slice();L?.splice(A,1),(0,t.tp)({onOptionsChange:d,options:s},"tracesToMetrics",{...s.jsonData.tracesToMetrics,queries:L})}}))),l.createElement(W.zx,{variant:"secondary",title:"Add query",icon:"plus",type:"button",onClick:()=>{(0,t.tp)({onOptionsChange:d,options:s},"tracesToMetrics",{...s.jsonData.tracesToMetrics,queries:[...s.jsonData.tracesToMetrics?.queries??[],{query:""}]})}},"Add query"))}const b=({options:s,onOptionsChange:d})=>l.createElement(y.K,{title:"Trace to metrics",description:l.createElement(P.W,{description:"Navigate from a trace span to the selected data source's metrics.",suffix:`${s.type}/#trace-to-metrics`,feature:"trace to metrics"}),isCollapsible:!0,isInitiallyOpen:!0},l.createElement(N,{options:s,onOptionsChange:d})),H=s=>({infoText:(0,f.css)`
    padding-bottom: ${s.spacing(2)};
    color: ${s.colors.text.secondary};
  `,row:(0,f.css)`
    label: row;
    align-items: baseline;
  `,queryRow:(0,f.css)`
    label: queryRow;
    display: flex;
    flex-flow: wrap;
  `})},9203:(V,O,a)=>{a.r(O),a.d(O,{plugin:()=>Le});var f=a(68246),l=a(42844),t=a(27702),y=a(66310);function C(){const n=(0,y.wW)(g);return t.createElement(t.Fragment,null,t.createElement("h2",{id:"jaeger-cheat-sheet"},"Jaeger Cheat Sheet"),t.createElement("p",null,"This cheat sheet provides a quick overview of the query types that are available. For more details about the Jaeger data source, check out"," ",t.createElement("a",{href:"https://grafana.com/docs/grafana/latest/datasources/jaeger",target:"_blank",rel:"noreferrer",className:n.anchorTag},"the documentation"),"."),t.createElement("hr",null),t.createElement("ul",{className:n.unorderedList},t.createElement("li",null,"Search - filter traces by service name. Addtionally, you can filter by tags or min/max duration, as well as limit the number of traces that are returned."),t.createElement("li",null,"TraceID - if you have a trace ID, simply enter the trace ID to see the trace."),t.createElement("li",null,"JSON File - you can upload a JSON file that contains a single trace to visualize it. If the file has multiple traces then the first trace is used for visualization. An example of a valid JSON file can be found in"," ",t.createElement("a",{href:"https://grafana.com/docs/grafana/latest/datasources/jaeger/#upload-json-trace-file",target:"_blank",rel:"noreferrer",className:n.anchorTag},"this section")," ","of the documentation.")))}const g=n=>({anchorTag:(0,l.css)`
    color: ${n.colors.text.link};
  `,unorderedList:(0,l.css)`
    list-style-type: none;
  `});var M=a(77195),W=a(19010),x=a(34667),K=a(49257),P=a(5562),U=a(29126),E=a(51778),D=a(35977),N=a(32042);const b=({options:n,onOptionsChange:e})=>{const r=(0,y.wW)(H);return t.createElement("div",{className:r.container},t.createElement(M.j,{dataSourceName:"Jaeger",docsLink:"https://grafana.com/docs/grafana/latest/datasources/jaeger",hasRequiredFields:!1}),t.createElement(P.i,null),t.createElement(K.E,{defaultUrl:"http://localhost:16686",dataSourceConfig:n,showAccessOptions:!1,onChange:e,secureSocksDSProxyEnabled:x.config.secureSocksDSProxyEnabled}),t.createElement(E.dw,{options:n,onOptionsChange:e}),t.createElement(P.i,null),x.config.featureToggles.traceToMetrics?t.createElement(t.Fragment,null,t.createElement(D.Y,{options:n,onOptionsChange:e}),t.createElement(P.i,null)):null,t.createElement(W.K,{title:"Additional settings",description:"Additional settings are optional settings that can be configured for more control over your data source.",isCollapsible:!0,isInitiallyOpen:!1},t.createElement(U.I,{options:n,onOptionsChange:e}),t.createElement(P.i,{hideLine:!0}),t.createElement(N.vc,{options:n,onOptionsChange:e})))},H=n=>({container:(0,l.css)`
    label: container;
    margin-bottom: ${n.spacing(2)};
    max-width: 900px;
  `});var s=a(71107),d=a(48024),z=a(9857),T=a(13741),A=a(79399),L=a(64022),R=a(40705),se=a(66670),w=a(81078),F=a(39317),le=a(37221),k=a(28580),Q=a(1128),oe=a(33877),ie=a(73807),ce=a(84749),ue=a(69442),q=a.n(ue);function de(n){if(!n)return"";const e=q().parse(n);return Object.keys(e).forEach(r=>{const o=e[r];typeof o!="string"&&(e[r]=String(o))}),JSON.stringify(e)}function me(n){if(!n)return"";try{return q().stringify(JSON.parse(n))}catch{return n}}const _="e.g. 1.2s, 100ms, 500us",ee="All",ve={label:ee,value:void 0};function fe({datasource:n,query:e,onChange:r}){const[o,u]=(0,t.useState)(),[i,m]=(0,t.useState)(),[p,B]=(0,t.useState)({services:!1,operations:!1}),S=(0,t.useCallback)(async(c,v,J="")=>{B(h=>({...h,[v]:!0}));try{const h=await n.metadataRequest(c);return h?h.sort().map($=>({label:$,value:$})).filter($=>$.value?(0,le.C)($.value,J).found:!1):[{label:`No ${v} found`,value:`No ${v} found`}]}catch(h){return h instanceof Error&&(0,ce.WI)((0,oe.$l)((0,ie.t_)("Error",h))),[]}finally{B(h=>({...h,[v]:!1}))}},[n]);return(0,t.useEffect)(()=>{(async()=>{const v=await S("/api/services","services");e.service&&(0,F.J)().containsTemplate(e.service)&&v.push((0,w.E)(e.service)),u(v)})()},[n,S,e.service]),(0,t.useEffect)(()=>{const c=async()=>{const v=await S(`/api/services/${encodeURIComponent((0,F.J)().replace(e.service))}/operations`,"operations");e.operation&&(0,F.J)().containsTemplate(e.operation)&&v.push((0,w.E)(e.operation)),m([ve,...v])};e.service&&c()},[n,e.service,S,e.operation]),t.createElement("div",{className:(0,l.css)({maxWidth:"500px"})},t.createElement(s.Z,null,t.createElement(d._,{label:"Service Name",labelWidth:14,grow:!0},t.createElement(k.Ph,{inputId:"service",options:o,onOpenMenu:()=>S("/api/services","services"),isLoading:p.services,value:o?.find(c=>c?.value===e.service)||void 0,placeholder:"Select a service",onChange:c=>r({...e,service:c?.value,operation:e.service!==c?.value?void 0:e.operation}),menuPlacement:"bottom",isClearable:!0,"aria-label":"select-service-name",allowCustomValue:!0}))),t.createElement(s.Z,null,t.createElement(d._,{label:"Operation Name",labelWidth:14,grow:!0,disabled:!e.service},t.createElement(k.Ph,{inputId:"operation",options:i,onOpenMenu:()=>S(`/api/services/${encodeURIComponent((0,F.J)().replace(e.service))}/operations`,"operations"),isLoading:p.operations,value:i?.find(c=>c.value===e.operation)||null,placeholder:"Select an operation",onChange:c=>r({...e,operation:c?.value||void 0}),menuPlacement:"bottom",isClearable:!0,"aria-label":"select-operation-name",allowCustomValue:!0}))),t.createElement(s.Z,null,t.createElement(d._,{label:"Tags",labelWidth:14,grow:!0,tooltip:"Values should be in logfmt."},t.createElement(Q.I,{id:"tags",value:me(e.tags),placeholder:"http.status_code=200 error=true",onChange:c=>r({...e,tags:c.currentTarget.value})}))),t.createElement(s.Z,null,t.createElement(d._,{label:"Min Duration",labelWidth:14,grow:!0},t.createElement(Q.I,{id:"minDuration",name:"minDuration",value:e.minDuration||"",placeholder:_,onChange:c=>r({...e,minDuration:c.currentTarget.value})}))),t.createElement(s.Z,null,t.createElement(d._,{label:"Max Duration",labelWidth:14,grow:!0},t.createElement(Q.I,{id:"maxDuration",name:"maxDuration",value:e.maxDuration||"",placeholder:_,onChange:c=>r({...e,maxDuration:c.currentTarget.value})}))),t.createElement(s.Z,null,t.createElement(d._,{label:"Limit",labelWidth:14,grow:!0,tooltip:"Maximum number of returned results"},t.createElement(Q.I,{id:"limit",name:"limit",value:e.limit||"",type:"number",onChange:c=>r({...e,limit:c.currentTarget.value?parseInt(c.currentTarget.value,10):void 0})}))))}const Ce=null;function ge({datasource:n,query:e,onChange:r,onRunQuery:o}){const[u,i]=(0,t.useState)(!1),m=(0,y.l4)(),p=(0,y.wW)(Ee),B=c=>{const v={...e,query:c};r(v)},S=()=>{switch(e.queryType){case"search":return t.createElement(fe,{datasource:n,query:e,onChange:r});default:return t.createElement(s.Z,null,t.createElement(d._,{label:"Trace ID",labelWidth:14,grow:!0},t.createElement(z.q,{query:e.query,onChange:B,onRunQuery:o,placeholder:"Enter a Trace ID (run with Shift+Enter)",portalOrigin:"jaeger"})))}};return t.createElement(t.Fragment,null,t.createElement(T.u,{title:"Upload trace",isOpen:u,onDismiss:()=>i(!1)},t.createElement("div",{className:(0,l.css)({padding:m.spacing(2)})},t.createElement(A.Yo,{options:{multiple:!1},onLoad:c=>{n.uploadedJson=c,r({...e,queryType:"upload"}),i(!1),o()}}))),t.createElement("div",{className:p.container},t.createElement(s.Z,null,t.createElement(d._,{label:"Query type",grow:!0},t.createElement(L.Lh,{spacing:"sm",align:"center",justify:"space-between"},t.createElement(R.S,{options:[{value:"search",label:"Search"},{value:void 0,label:"TraceID"}],value:e.queryType,onChange:c=>r({...e,queryType:c}),size:"md"}),t.createElement(se.zx,{variant:"secondary",size:"sm",onClick:()=>{i(!0)}},"Import trace")))),S()))}const Ee=()=>({container:(0,l.css)`
    width: 100%;
  `});var G=a(89949),te=a(78209),j=a(45383),Y=a(39343),pe=a(56469),he=a(1726),De=a(72164),Te=a(29241),Me=a(73289),Se=a(26631),ye=a(26858),I=a(12503),Z=a(43500);function ae(n){const{nodes:e,edges:r}=Ie(n),[o,u]=(0,Z.np)();for(const i of e)o.add(i);for(const i of r)u.add(i);return[o,u]}function Ie(n){const e=[],r=[],o=Oe(n.spans),u=(0,Z.nO)(i=>{if(i>=n.spans.length)return;const m=n.spans[i];return{span:m,id:m.spanID,parentIds:m.references?.filter(p=>p.refType==="CHILD_OF").map(p=>p.spanID)||[]}});for(const i of n.spans){const m=n.processes[i.processID],p=u[i.spanID].children.map(J=>{const h=u[J].span;return[h.startTime,h.startTime+h.duration]}),B=(0,Z.et)(p),S=i.duration-B,c=(0,Z.fy)(i.duration/1e3,o/1e3,S/1e3);e.push({[I.z.id]:i.spanID,[I.z.title]:m?.serviceName??"",[I.z.subTitle]:i.operationName,[I.z.mainStat]:c.main,[I.z.secondaryStat]:c.secondary,[I.z.color]:S/o});const v=i.references?.find(J=>J.refType==="CHILD_OF")?.spanID;v&&u[v].span&&r.push({[I.z.id]:v+"--"+i.spanID,[I.z.target]:i.spanID,[I.z.source]:v})}return{nodes:e,edges:r}}function Oe(n){let e=0,r=1/0;for(const o of n)o.startTime<r&&(r=o.startTime),o.startTime+o.duration>e&&(e=o.startTime+o.duration);return e-r}var X=a(10315);class Pe extends f.MF{constructor(e,r=(0,ye.$t)(),o=(0,F.J)()){super(e),this.instanceSettings=e,this.timeSrv=r,this.templateSrv=o,this.uploadedJson=null,this.nodeGraph=e.jsonData.nodeGraph}async metadataRequest(e,r){return(await(0,te.n)(this._request(e,r,{hideFromInspector:!0}))).data.data}isSearchFormValid(e){return!!e.service}query(e){const r=e.targets[0];if(!r)return(0,j.of)({data:[ne]});if(r.queryType==="search"&&!this.isSearchFormValid(r))return(0,j.of)({error:{message:"You must select a service."},data:[]});if(r.queryType!=="search"&&r.query)return this._request(`/api/traces/${encodeURIComponent(this.templateSrv.replace(r.query,e.scopedVars))}`).pipe((0,Y.U)(i=>{const m=i?.data?.data?.[0];if(!m)return{data:[ne]};let p=[(0,X.xM)(m)];return this.nodeGraph?.enabled&&p.push(...ae(m)),{data:p}}));if(r.queryType==="upload"){if(!this.uploadedJson)return(0,j.of)({data:[]});try{const i=JSON.parse(this.uploadedJson).data[0];let m=[(0,X.xM)(i)];return this.nodeGraph?.enabled&&m.push(...ae(i)),(0,j.of)({data:m})}catch{return(0,j.of)({error:{message:"The JSON file uploaded is not in a valid Jaeger format"},data:[]})}}let o=(0,G.pick)(this.applyVariables(r,e.scopedVars),["service","operation","tags","minDuration","maxDuration","limit"]),u=(0,G.pickBy)(o,G.identity);return u.operation===ee&&(u=(0,G.omit)(u,"operation")),u.tags&&(u={...u,tags:de(u.tags.toString())}),this._request("/api/traces",{...u,...this.getTimeRange(),lookback:"custom"}).pipe((0,Y.U)(i=>({data:[(0,X.Wp)(i.data.data,this.instanceSettings)]})))}interpolateVariablesInQueries(e,r){return!e||e.length===0?[]:e.map(o=>({...o,datasource:this.getRef(),...this.applyVariables(o,r)}))}applyVariables(e,r){let o={...e};return e.tags&&this.templateSrv.containsTemplate(e.tags)&&(o={...e,tags:this.templateSrv.replace(e.tags,r)}),{...o,service:this.templateSrv.replace(e.service??"",r),operation:this.templateSrv.replace(e.operation??"",r),minDuration:this.templateSrv.replace(e.minDuration??"",r),maxDuration:this.templateSrv.replace(e.maxDuration??"",r)}}async testDatasource(){return(0,te.n)(this._request("/api/services").pipe((0,Y.U)(e=>(e?.data?.data||[]).length>0?{status:"success",message:"Data source connected and services found."}:{status:"error",message:"Data source connected, but no services received. Verify that Jaeger is configured properly."}),(0,pe.K)(e=>{let r="Jaeger: ";return e.statusText?r+=e.statusText:r+="Cannot connect to Jaeger",e.status&&(r+=`. ${e.status}`),e.data&&e.data.message?r+=`. ${e.data.message}`:e.data&&(r+=`. ${JSON.stringify(e.data)}`),(0,j.of)({status:"error",message:r})})))}getTimeRange(){const e=this.timeSrv.timeRange();return{start:re(e.from,!1),end:re(e.to,!0)}}getQueryDisplayText(e){return e.query||""}_request(e,r,o){const u=r?(0,Se.tW)(r):"",i=`${this.instanceSettings.url}${e}${u.length?`?${u}`:""}`,m={...o,url:i};return(0,Me.i)().fetch(m)}}function re(n,e){return typeof n=="string"&&(n=he.parse(n,e)),n.valueOf()*1e3}const ne=new De.v({fields:[{name:"trace",type:Te.fS.trace,values:[]}],meta:{preferredVisualisationType:"trace",custom:{traceFormat:"jaeger"}}}),Le=new f.hf(Pe).setConfigEditor(b).setQueryEditor(ge).setQueryEditorHelp(C)}}]);

//# sourceMappingURL=jaegerPlugin.62491827cac9a866e581.js.map