"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8890],{83720(I,E,a){a.d(E,{A:()=>W});var e=a(74848),P=a(96540),D=a(71468),m=a(70713),d=a(3202),_=a(63739),g=a(8392),c=a(32864),M=a(47454),i=a(7500),f=a(29675),O=a(96325),v=a(85836),p=a(99528),U=a(4148),T=a(46760),h=a(23421),B=a(26407);const L=(y,t)=>({dataSourceUid:t.uid}),A={loadDataSource:T.ak,loadDataSourceMeta:T.xI},K=(0,D.connect)(L,A);class x extends P.PureComponent{constructor(t){super(t),this.state={dailySummaries:[],from:"",to:""}}async componentDidMount(){const{dataSourceUid:t,loadDataSource:s,loadDataSourceMeta:l}=this.props;if(s(t).then(l),(0,c.a)("analytics")){let n=(0,d.KQ)().subtract(30,"days").format(h.QH),o=(0,d.KQ)().format(h.QH);const r=await(0,h.FW)(t,n,o);this.setState({dailySummaries:r,from:n,to:o})}}buildTimeRange(){const{from:t,to:s}=this.state,l=(0,d.KQ)(t),n=(0,d.KQ)(s).add(24,"hours");return{from:l,to:n,raw:{from:t,to:s}}}convertDailySummariesToDataFrame(t,s,l){const n=[],o=[];return t.forEach(r=>{n.push((0,d.KQ)(r.day,h.QH).valueOf());let u=r[s];s==="loadDuration"&&(u=r.queries?r.loadDuration/(r.queries*1e6):0),o.push(u)}),{name:s,fields:[{name:"Time",type:_.PU.time,config:{},values:n},{name:s,type:l,config:{},values:o}],length:t.length}}renderChart(t,s){const{dailySummaries:l}=this.state,{color:n,fieldType:o,showBars:r,timeRange:u,title:C,valueField:S,width:j}=t,R={series:[this.convertDailySummariesToDataFrame(l,S,o)],state:g.Gu.Done,timeRange:u},F={legend:{showLegend:!1,displayMode:i.lm.Hidden,calcs:[],placement:"bottom"},tooltip:{mode:i.$N.Multi,sort:i.xB.Descending}},Q={defaults:{color:{mode:"fixed",fixedColor:n},custom:{showPoints:i.yL.Never,drawStyle:r?i.GR.Bars:i.GR.Line,fillOpacity:r?50:0}},overrides:[]};return(0,e.jsx)("div",{className:s.graphContainer,children:(0,e.jsx)(O.NR,{title:C,width:j,height:220,displayMode:"transparent",loadingState:R.state,children:(N,H)=>(0,e.jsx)(M.m,{title:C,width:N,height:H,pluginId:"timeseries",data:R,fieldConfig:Q,options:F})})})}renderContent(){const{theme:t}=this.props,s=(0,B.k)(t),{dailySummaries:l}=this.state,n=this.buildTimeRange();return l?.length>0?(0,e.jsx)(m.default,{disableHeight:!0,children:({width:o})=>{const r=[{title:"Queries last 30 days",valueField:"queries",fieldType:_.PU.number,width:o,timeRange:n,color:"green",showBars:!0,showLines:!1},{title:"Errors last 30 days",valueField:"errors",fieldType:_.PU.number,width:o,timeRange:n,color:t.colors.error.border,showBars:!0,showLines:!1},{title:"Average load duration last 30 days (ms)",valueField:"loadDuration",fieldType:_.PU.number,width:o,timeRange:n,color:t.colors.primary.border,showBars:!0,showLines:!1}];return(0,e.jsx)("main",{style:{width:o},children:r.map(u=>this.renderChart(u,s))})}}):(0,e.jsx)("span",{children:"No available data for this data source."})}render(){return(0,c.a)("analytics.writers")&&!(0,c.a)("analytics")?(0,e.jsx)(v.w,{title:"Feature not available with an expired license",url:"https://grafana.com/docs/grafana/latest/enterprise/license-expiration/",urlTitle:"Read more on license expiration",children:(0,e.jsx)("span",{children:"Data source insights are not available with an expired license. Data will continue to be collected but you need to update your license to see this page."})}):(0,e.jsxs)(e.Fragment,{children:[(0,U.z5)()&&(0,e.jsx)(p.Iz,{featureId:"data-source-insights",eventVariant:"trial",featureName:"data source usage insights",text:"Enable data source usage insights for free during your trial of Grafana Pro."}),this.renderContent()]})}}const W=K((0,f.cV)(x))},2721(I,E,a){a.r(E),a.d(E,{DataSourceInsightsPage:()=>c,default:()=>M});var e=a(74848),P=a(54148),D=a(54122),m=a(12636),d=a(96326),_=a(61491),g=a(83720);const c=()=>{const{uid:i=""}=(0,P.g)(),f=(0,d.$m)("insights"),O=(0,_.useSelector)(p=>p.navIndex),v=(0,m.tc)(O,`datasource-insights-${i}`,f);return(0,e.jsx)(D.Y,{navId:"datasources",pageNav:v.main,children:(0,e.jsx)(D.Y.Contents,{children:(0,e.jsx)(g.A,{uid:i})})})},M=c}}]);

//# sourceMappingURL=DataSourceInsightsPage.93c77946ea7770a0f2f5.js.map