12 |
- "use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3168],{63773:(t,e,i)=>{i.d(e,{O:()=>n});var r=i(43215),s=i(90923);const a={http:80,https:443,ftp:21};class n{constructor(){this.absUrl=this.wrapInDeprecationWarning(this.absUrl),this.hash=this.wrapInDeprecationWarning(this.hash),this.host=this.wrapInDeprecationWarning(this.host),this.path=this.wrapInDeprecationWarning(this.path),this.port=this.wrapInDeprecationWarning(this.port,"window.location"),this.protocol=this.wrapInDeprecationWarning(this.protocol,"window.location"),this.replace=this.wrapInDeprecationWarning(this.replace),this.search=this.wrapInDeprecationWarning(this.search),this.state=this.wrapInDeprecationWarning(this.state),this.url=this.wrapInDeprecationWarning(this.url)}wrapInDeprecationWarning(t,e){let i=this;return function(){return(0,r.deprecationWarning)("$location",t.name,e||"locationService"),t.apply(i,arguments)}}absUrl(){return`${window.location.origin}${this.url()}`}hash(t){if((0,s.navigationLogger)("AngularLocationWrapper",!1,"Angular compat layer: hash"),t)throw new Error("AngularLocationWrapper method not implemented.");return s.locationService.getLocation().hash.slice(1)}host(){return new URL(window.location.href).hostname}path(t){(0,s.navigationLogger)("AngularLocationWrapper",!1,"Angular compat layer: path");const e=s.locationService.getLocation();if(null!=t){let i=String(t);i=i.startsWith("/")?i:`/${i}`;const r=new URL(`${window.location.origin}${i}`);return s.locationService.push({pathname:r.pathname,search:r.search.length>0?r.search:e.search,hash:r.hash.length>0?r.hash:e.hash}),this}return null===t?(s.locationService.push("/"),this):e.pathname}port(){const t=new URL(window.location.href);return parseInt(t.port,10)||a[t.protocol]||null}protocol(){return new URL(window.location.href).protocol.slice(0,-1)}replace(){throw new Error("AngularLocationWrapper method not implemented.")}search(t,e){if((0,s.navigationLogger)("AngularLocationWrapper",!1,"Angular compat layer: search"),!t)return s.locationService.getSearchObject();if(t&&arguments.length>1)return s.locationService.partial({[t]:e}),this;if(t){let e;e="object"==typeof t?Object.assign({},t):(0,s.locationSearchToObject)(t);for(const t of Object.keys(e))null!==e[t]&&void 0!==e[t]||delete e[t];const i=r.urlUtil.renderUrl(s.locationService.getLocation().pathname,e);s.locationService.push(i)}return this}state(t){throw(0,s.navigationLogger)("AngularLocationWrapper",!1,"Angular compat layer: state"),new Error("AngularLocationWrapper method not implemented.")}url(t){if((0,s.navigationLogger)("AngularLocationWrapper",!1,"Angular compat layer: url"),void 0!==t)return t.startsWith("#")?s.locationService.push(Object.assign({},s.locationService.getLocation(),{hash:t})):t.startsWith("?")?s.locationService.push(Object.assign({},s.locationService.getLocation(),{search:t})):0===t.trim().length?s.locationService.push("/"):s.locationService.push(t),s.locationService;const e=s.locationService.getLocation();return`${e.pathname}${e.search}${e.hash}`}}},15866:(t,e,i)=>{i.d(e,{k:()=>l});var r=i(82897),s=i(43215),a=i(91082),n=i(60301);function o(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class l extends a.q{constructor(t,e){super(t,e),o(this,"contextSrv",void 0),o(this,"datasourceSrv",void 0),o(this,"timeSrv",void 0),o(this,"templateSrv",void 0),o(this,"interval",void 0),o(this,"intervalMs",void 0),o(this,"resolution",void 0),o(this,"timeInfo",void 0),o(this,"skipDataOnInit",!1),o(this,"dataList",[]),o(this,"querySubscription",void 0),o(this,"useDataFrames",!1),o(this,"panelData",void 0),o(this,"panelDataObserver",{next:t=>{if(this.panelData=t,t.state===s.LoadingState.Error&&(this.loading=!1,this.processDataError(t.error)),t.state===s.LoadingState.Loading)return this.loading=!0,void this.angularDirtyCheck();if(t.request){const{timeInfo:e}=t.request;e&&(this.timeInfo=e)}if(t.timeRange&&(this.range=t.timeRange),this.useDataFrames)this.handleDataFrames(t.series);else{const e=t.series.map((t=>(0,s.toLegacyResponseData)(t)));this.handleQueryResult({data:e})}this.angularDirtyCheck()}}),this.contextSrv=e.get("contextSrv"),this.datasourceSrv=e.get("datasourceSrv"),this.timeSrv=e.get("timeSrv"),this.templateSrv=e.get("templateSrv"),this.panel.datasource=this.panel.datasource||null,this.events.on(s.PanelEvents.refresh,this.onMetricsPanelRefresh.bind(this)),this.events.on(s.PanelEvents.panelTeardown,this.onPanelTearDown.bind(this)),this.events.on(s.PanelEvents.componentDidMount,this.onMetricsPanelMounted.bind(this))}onMetricsPanelMounted(){const t=this.panel.getQueryRunner();this.querySubscription=t.getData({withTransforms:!0,withFieldConfig:!0}).subscribe(this.panelDataObserver)}onPanelTearDown(){this.querySubscription&&(this.querySubscription.unsubscribe(),this.querySubscription=null)}onMetricsPanelRefresh(){if(!this.otherPanelInFullscreenMode()){if(this.panel.snapshotData){this.updateTimeRange();let t=this.panel.snapshotData;return(0,r.isArray)(t)||(t=t.data),this.panelData={state:s.LoadingState.Done,series:t,timeRange:this.range},this.$timeout((()=>{this.events.emit(s.PanelEvents.dataSnapshotLoad,t)}))}return delete this.error,this.loading=!0,this.datasourceSrv.get(this.panel.datasource,this.panel.scopedVars).then(this.issueQueries.bind(this)).catch((t=>{this.processDataError(t)}))}}processDataError(t){t.cancelled?console.log("Panel request cancelled",t):(this.error=t.message||"Request Error",t.data&&(t.data.message?this.error=t.data.message:t.data.error&&(this.error=t.data.error)),this.angularDirtyCheck())}angularDirtyCheck(){this.$scope.$root.$$phase||this.$scope.$digest()}updateTimeRange(t){this.datasource=t||this.datasource,this.range=this.timeSrv.timeRange();const e=(0,n.W1)(this.panel,this.range);this.timeInfo=e.timeInfo,this.range=e.timeRange}issueQueries(t){this.updateTimeRange(t),this.datasource=t;const e=this.panel;return e.getQueryRunner().run({datasource:e.datasource,queries:e.targets,panelId:e.id,dashboardId:this.dashboard.id,timezone:this.dashboard.getTimezone(),timeInfo:this.timeInfo,timeRange:this.range,maxDataPoints:e.maxDataPoints||this.width,minInterval:e.interval,scopedVars:e.scopedVars,cacheTimeout:e.cacheTimeout,transformations:e.transformations})}handleDataFrames(t){this.loading=!1,this.dashboard&&this.dashboard.snapshot&&(this.panel.snapshotData=t.map((t=>(0,s.toDataFrameDTO)(t))));try{this.events.emit(s.PanelEvents.dataFramesReceived,t)}catch(t){this.processDataError(t)}}handleQueryResult(t){this.loading=!1,this.dashboard.snapshot&&(this.panel.snapshotData=t.data),t&&t.data||(console.log("Data source query result invalid, missing data field:",t),t={data:[]});try{this.events.emit(s.PanelEvents.dataReceived,t.data)}catch(t){this.processDataError(t)}}}},91082:(t,e,i)=>{i.d(e,{q:()=>h});var r=i(82897),s=i(43215),a=i(63773),n=i(78837),o=i(98163);function l(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class h{constructor(t,e){var i,r;l(this,"panel",void 0),l(this,"error",void 0),l(this,"pluginName",""),l(this,"pluginId",""),l(this,"editorTabs",void 0),l(this,"$scope",void 0),l(this,"$injector",void 0),l(this,"$timeout",void 0),l(this,"editModeInitiated",!1),l(this,"containerHeight",void 0),l(this,"events",void 0),l(this,"loading",!1),l(this,"timing",void 0),l(this,"$location",void 0),l(this,"onPluginTypeChange",(t=>{})),this.panel=null!==(i=this.panel)&&void 0!==i?i:t.$parent.panel,this.dashboard=null!==(r=this.dashboard)&&void 0!==r?r:t.$parent.dashboard,this.$injector=e,this.$scope=t,this.$timeout=e.get("$timeout"),this.editorTabs=[],this.$location=new a.O,this.events=new s.EventBusSrv,this.timing={};const o=n.ZP.panels[this.panel.type];o&&(this.pluginId=o.id,this.pluginName=o.name),t.$on(s.PanelEvents.componentDidMount.name,(()=>this.panelDidMount()))}panelDidMount(){this.events.emit(s.PanelEvents.componentDidMount),this.events.emit(s.PanelEvents.initialized),this.dashboard.panelInitialized(this.panel)}renderingCompleted(){o.rv.renderingCompleted()}refresh(){this.panel.refresh()}publishAppEvent(t,e){this.$scope.$root.appEvent(t,e)}initEditMode(){this.editModeInitiated||(this.editModeInitiated=!0,this.events.emit(s.PanelEvents.editModeInitialized))}addEditorTab(t,e,i,s){const a={title:t,directiveFn:e,icon:s};(0,r.isString)(e)&&(a.directiveFn=()=>({templateUrl:e})),i?this.editorTabs.splice(i,0,a):this.editorTabs.push(a)}getExtendedMenu(){const t=[];return this.events.emit(s.PanelEvents.initPanelActions,t),t}async getAdditionalMenuItems(){return[]}otherPanelInFullscreenMode(){return this.dashboard.otherPanelInFullscreen(this.panel)}render(t){this.events.emit(s.PanelEvents.render,t)}}},88643:(t,e,i)=>{i.d(e,{G:()=>a});var r=i(82897);function s(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class a{constructor(t,e){var i,a,n,o,l;s(this,"target",void 0),s(this,"datasource",void 0),s(this,"panelCtrl",void 0),s(this,"panel",void 0),s(this,"hasRawMode",void 0),s(this,"error",void 0),s(this,"isLastQuery",void 0),this.$scope=t,this.$injector=e,this.panelCtrl=null!==(i=this.panelCtrl)&&void 0!==i?i:t.ctrl.panelCtrl,this.target=null!==(a=this.target)&&void 0!==a?a:t.ctrl.target,this.datasource=null!==(n=this.datasource)&&void 0!==n?n:t.ctrl.datasource,this.panel=null!==(o=null===(l=this.panelCtrl)||void 0===l?void 0:l.panel)&&void 0!==o?o:t.ctrl.panelCtrl.panel,this.isLastQuery=(0,r.indexOf)(this.panel.targets,this.target)===this.panel.targets.length-1}refresh(){this.panelCtrl.refresh()}}},29078:(t,e,i)=>{i.r(e),i.d(e,{plugin:()=>O});var r,s=i(43215),a=(i(68404),i(69783)),n=i(68366),o=i(45916);const{Select:l,Input:h}=a.LegacyForms,c=[{label:"<=2.1",value:1},{label:"==2.2",value:2},{label:"==2.3",value:3}],g=[{label:"second",value:1},{label:"millisecond",value:2}],u=t=>{var e,i,s;const{onChange:u,value:m}=t,v=(0,n.L)();return(0,o.jsxs)(o.Fragment,{children:[r||(r=(0,o.jsx)("h5",{children:"OpenTSDB settings"})),(0,o.jsxs)("div",{className:"gf-form",children:[(0,o.jsx)(a.InlineFormLabel,{width:7,htmlFor:`select-version-${v}`,children:"Version"}),(0,o.jsx)(l,{inputId:`select-version-${v}`,options:c,value:null!==(e=c.find((t=>t.value===m.jsonData.tsdbVersion)))&&void 0!==e?e:c[0],onChange:d("tsdbVersion",m,u)})]}),(0,o.jsxs)("div",{className:"gf-form",children:[(0,o.jsx)(a.InlineFormLabel,{width:7,htmlFor:`select-resolution-${v}`,children:"Resolution"}),(0,o.jsx)(l,{inputId:`select-resolution-${v}`,options:g,value:null!==(i=g.find((t=>t.value===m.jsonData.tsdbResolution)))&&void 0!==i?i:g[0],onChange:d("tsdbResolution",m,u)})]}),(0,o.jsxs)("div",{className:"gf-form",children:[(0,o.jsx)(a.InlineFormLabel,{width:7,htmlFor:`lookup-input-${v}`,children:"Lookup limit"}),(0,o.jsx)(h,{id:`lookup-input-${v}`,type:"number",value:null!==(s=m.jsonData.lookupLimit)&&void 0!==s?s:1e3,onChange:p("lookupLimit",m,u)})]})]})},d=(t,e,i)=>r=>{i(Object.assign({},e,{jsonData:Object.assign({},e.jsonData,{[t]:r.value})}))},p=(t,e,i)=>r=>{i(Object.assign({},e,{jsonData:Object.assign({},e.jsonData,{[t]:r.currentTarget.value})}))};var m=i(93964),v=i.n(m),f=i(82897),y=i(2937),b=i(58788),T=i(76913),w=i(10010),S=i(90923),D=i(7166);function P(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class F extends s.DataSourceApi{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(0,D.J)();super(t),P(this,"type",void 0),P(this,"url",void 0),P(this,"name",void 0),P(this,"withCredentials",void 0),P(this,"basicAuth",void 0),P(this,"tsdbVersion",void 0),P(this,"tsdbResolution",void 0),P(this,"lookupLimit",void 0),P(this,"tagKeys",void 0),P(this,"aggregatorsPromise",void 0),P(this,"filterTypesPromise",void 0),this.templateSrv=e,this.type="opentsdb",this.url=t.url,this.name=t.name,this.withCredentials=t.withCredentials,this.basicAuth=t.basicAuth,t.jsonData=t.jsonData||{},this.tsdbVersion=t.jsonData.tsdbVersion||1,this.tsdbResolution=t.jsonData.tsdbResolution||1,this.lookupLimit=t.jsonData.lookupLimit||1e3,this.tagKeys={},this.aggregatorsPromise=null,this.filterTypesPromise=null}query(t){const e=this.convertToTSDBTime(t.range.raw.from,!1,t.timezone),i=this.convertToTSDBTime(t.range.raw.to,!0,t.timezone),r=[];(0,f.each)(t.targets,(e=>{e.metric&&r.push(this.convertTargetToQuery(e,t,this.tsdbVersion))}));const s=(0,f.compact)(r);if((0,f.isEmpty)(s))return(0,y.of)({data:[]});const a={};return(0,f.each)(s,(t=>{t.filters&&t.filters.length>0?(0,f.each)(t.filters,(t=>{a[t.tagk]=!0})):(0,f.each)(t.tags,((t,e)=>{a[e]=!0}))})),t.targets=(0,f.filter)(t.targets,(t=>!0!==t.hide)),this.performTimeSeriesQuery(s,e,i).pipe((0,T.K)((t=>{var e,i;throw(null==t||null===(e=t.data)||void 0===e||null===(i=e.error)||void 0===i?void 0:i.message)||"Error performing time series query."})),(0,w.U)((e=>{const i=this.mapMetricsToTargets(e.data,t,this.tsdbVersion);return{data:(0,f.map)(e.data,((e,r)=>(-1===(r=i[r])&&(r=0),this._saveTagKeys(e),this.transformMetricData(e,a,t.targets[r],t,this.tsdbResolution))))}})))}annotationQuery(t){const e=this.convertToTSDBTime(t.rangeRaw.from,!1,t.timezone),i=this.convertToTSDBTime(t.rangeRaw.to,!0,t.timezone),r=[],s=[];r.push({aggregator:"sum",metric:t.annotation.target});const a=(0,f.compact)(r);return(0,b.n)(this.performTimeSeriesQuery(a,e,i).pipe((0,w.U)((e=>{if(e.data[0]){let i=e.data[0].annotations;t.annotation.isGlobal&&(i=e.data[0].globalAnnotations),i&&(0,f.each)(i,(e=>{const i={text:e.description,time:1e3*Math.floor(e.startTime),annotation:t.annotation};s.push(i)}))}return s}))))}targetContainsTemplate(t){if(t.filters&&t.filters.length>0)for(let e=0;e<t.filters.length;e++)if(this.templateSrv.containsTemplate(t.filters[e].filter))return!0;if(t.tags&&Object.keys(t.tags).length>0)for(const e in t.tags)if(this.templateSrv.containsTemplate(t.tags[e]))return!0;return!1}performTimeSeriesQuery(t,e,i){let r=!1;2===this.tsdbResolution&&(r=!0);const s={start:e,queries:t,msResolution:r,globalAnnotations:!0};3===this.tsdbVersion&&(s.showQuery=!0),i&&(s.end=i);const a={method:"POST",url:this.url+"/api/query",data:s};return this._addCredentialOptions(a),(0,S.getBackendSrv)().fetch(a)}suggestTagKeys(t){return Promise.resolve(this.tagKeys[t]||[])}_saveTagKeys(t){const e=Object.keys(t.tags);(0,f.each)(t.aggregateTags,(t=>{e.push(t)})),this.tagKeys[t.metric]=e}_performSuggestQuery(t,e){return this._get("/api/suggest",{type:e,q:t,max:this.lookupLimit}).pipe((0,w.U)((t=>t.data)))}_performMetricKeyValueLookup(t,e){if(!t||!e)return(0,y.of)([]);const i=e.split(",").map((t=>t.trim())),r=i[0];let s=r+"=*";i.length>1&&(s+=","+i.splice(1).join(","));const a=t+"{"+s+"}";return this._get("/api/search/lookup",{m:a,limit:this.lookupLimit}).pipe((0,w.U)((t=>{t=t.data.results;const e=[];return(0,f.each)(t,(t=>{-1===e.indexOf(t.tags[r])&&e.push(t.tags[r])})),e})))}_performMetricKeyLookup(t){return t?this._get("/api/search/lookup",{m:t,limit:1e3}).pipe((0,w.U)((t=>{t=t.data.results;const e=[];return(0,f.each)(t,(t=>{(0,f.each)(t.tags,((t,i)=>{-1===e.indexOf(i)&&e.push(i)}))})),e}))):(0,y.of)([])}_get(t,e){const i={method:"GET",url:this.url+t,params:e};return this._addCredentialOptions(i),(0,S.getBackendSrv)().fetch(i)}_addCredentialOptions(t){(this.basicAuth||this.withCredentials)&&(t.withCredentials=!0),this.basicAuth&&(t.headers={Authorization:this.basicAuth})}metricFindQuery(t){if(!t)return Promise.resolve([]);let e;try{e=this.templateSrv.replace(t,{},"distributed")}catch(t){return Promise.reject(t)}const i=t=>(0,f.map)(t,(t=>({text:t}))),r=e.match(/metrics\((.*)\)/);if(r)return(0,b.n)(this._performSuggestQuery(r[1],"metrics").pipe((0,w.U)(i)));const s=e.match(/tag_names\((.*)\)/);if(s)return(0,b.n)(this._performMetricKeyLookup(s[1]).pipe((0,w.U)(i)));const a=e.match(/tag_values\((.*?),\s?(.*)\)/);if(a)return(0,b.n)(this._performMetricKeyValueLookup(a[1],a[2]).pipe((0,w.U)(i)));const n=e.match(/suggest_tagk\((.*)\)/);if(n)return(0,b.n)(this._performSuggestQuery(n[1],"tagk").pipe((0,w.U)(i)));const o=e.match(/suggest_tagv\((.*)\)/);return o?(0,b.n)(this._performSuggestQuery(o[1],"tagv").pipe((0,w.U)(i))):Promise.resolve([])}testDatasource(){return(0,b.n)(this._performSuggestQuery("cpu","metrics").pipe((0,w.U)((()=>({status:"success",message:"Data source is working"})))))}getAggregators(){return this.aggregatorsPromise||(this.aggregatorsPromise=(0,b.n)(this._get("/api/aggregators").pipe((0,w.U)((t=>t.data&&(0,f.isArray)(t.data)?t.data.sort():[]))))),this.aggregatorsPromise}getFilterTypes(){return this.filterTypesPromise||(this.filterTypesPromise=(0,b.n)(this._get("/api/config/filters").pipe((0,w.U)((t=>t.data?Object.keys(t.data).sort():[]))))),this.filterTypesPromise}transformMetricData(t,e,i,r,s){const a=this.createMetricLabel(t,i,e,r),n=[];return(0,f.each)(t.dps,((t,e)=>{2===s?n.push([t,1*e]):n.push([t,1e3*e])})),{target:a,datapoints:n}}createMetricLabel(t,e,i,r){if(e.alias){const i=(0,f.clone)(r.scopedVars||{});return(0,f.each)(t.tags,((t,e)=>{i["tag_"+e]={value:t}})),this.templateSrv.replace(e.alias,i)}let s=t.metric;const a=[];return(0,f.isEmpty)(t.tags)||(0,f.each)((0,f.toPairs)(t.tags),(t=>{(0,f.has)(i,t[0])&&a.push(t[0]+"="+t[1])})),(0,f.isEmpty)(a)||(s+="{"+a.join(", ")+"}"),s}convertTargetToQuery(t,e,i){if(!t.metric||t.hide)return null;const r={metric:this.templateSrv.replace(t.metric,e.scopedVars,"pipe"),aggregator:"avg"};if(t.aggregator&&(r.aggregator=this.templateSrv.replace(t.aggregator)),t.shouldComputeRate&&(r.rate=!0,r.rateOptions={counter:!!t.isCounter},t.counterMax&&t.counterMax.length&&(r.rateOptions.counterMax=parseInt(t.counterMax,10)),t.counterResetValue&&t.counterResetValue.length&&(r.rateOptions.resetValue=parseInt(t.counterResetValue,10)),i>=2&&(r.rateOptions.dropResets=!(r.rateOptions.counterMax||r.rateOptions.ResetValue&&0!==r.rateOptions.ResetValue))),!t.disableDownsampling){let i=this.templateSrv.replace(t.downsampleInterval||e.interval);i.match(/\.[0-9]+s/)&&(i=1e3*parseFloat(i)+"ms"),r.downsample=i+"-"+t.downsampleAggregator,t.downsampleFillPolicy&&"none"!==t.downsampleFillPolicy&&(r.downsample+="-"+t.downsampleFillPolicy)}if(t.filters&&t.filters.length>0){if(r.filters=v().copy(t.filters),r.filters)for(const t in r.filters)r.filters[t].filter=this.templateSrv.replace(r.filters[t].filter,e.scopedVars,"pipe")}else if(r.tags=v().copy(t.tags),r.tags)for(const t in r.tags)r.tags[t]=this.templateSrv.replace(r.tags[t],e.scopedVars,"pipe");return t.explicitTags&&(r.explicitTags=!0),r}mapMetricsToTargets(t,e,i){let r,s;return(0,f.map)(t,(t=>3===i?t.query.index:(0,f.findIndex)(e.targets,(i=>i.filters&&i.filters.length>0?i.metric===t.metric:i.metric===t.metric&&(0,f.every)(i.tags,((i,a)=>(r=this.templateSrv.replace(i,e.scopedVars,"pipe"),s=r.split("|"),(0,f.includes)(s,t.tags[a])||"*"===r)))))))}interpolateVariablesInQueries(t,e){return t.length?t.map((t=>Object.assign({},t,{metric:this.templateSrv.replace(t.metric,e)}))):t}convertToTSDBTime(t,e,i){return"now"===t?null:(t=s.dateMath.parse(t,e,i)).valueOf()}}var j,M,C,I=i(60974);function L(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class x extends I.QueryCtrl{constructor(t,e){super(t,e),L(this,"aggregators",void 0),L(this,"fillPolicies",void 0),L(this,"filterTypes",void 0),L(this,"tsdbVersion",void 0),L(this,"aggregator",void 0),L(this,"downsampleInterval",void 0),L(this,"downsampleAggregator",void 0),L(this,"downsampleFillPolicy",void 0),L(this,"errors",void 0),L(this,"suggestMetrics",void 0),L(this,"suggestTagKeys",void 0),L(this,"suggestTagValues",void 0),L(this,"addTagMode",!1),L(this,"addFilterMode",!1),this.errors=this.validateTarget(),this.aggregators=["avg","sum","min","max","dev","zimsum","mimmin","mimmax"],this.fillPolicies=["none","nan","null","zero"],this.filterTypes=["wildcard","iliteral_or","not_iliteral_or","not_literal_or","iwildcard","literal_or","regexp"],this.tsdbVersion=this.datasource.tsdbVersion,this.target.aggregator||(this.target.aggregator="sum"),this.target.downsampleAggregator||(this.target.downsampleAggregator="avg"),this.target.downsampleFillPolicy||(this.target.downsampleFillPolicy="none"),this.datasource.getAggregators().then((t=>{0!==t.length&&(this.aggregators=t)})),this.datasource.getFilterTypes().then((t=>{0!==t.length&&(this.filterTypes=t)})),this.suggestMetrics=(t,e)=>{this.datasource.metricFindQuery("metrics("+t+")").then(this.getTextValues).then(e)},this.suggestTagKeys=(t,e)=>{this.datasource.suggestTagKeys(this.target.metric).then(e)},this.suggestTagValues=(t,e)=>{this.datasource.metricFindQuery("suggest_tagv("+t+")").then(this.getTextValues).then(e)}}targetBlur(){this.errors=this.validateTarget(),this.refresh()}getTextValues(t){return(0,f.map)(t,(t=>s.textUtil.escapeHtml(t.text)))}addTag(){this.target.filters&&this.target.filters.length>0&&(this.errors.tags="Please remove filters to use tags, tags and filters are mutually exclusive."),this.addTagMode?(this.target.tags||(this.target.tags={}),this.errors=this.validateTarget(),this.errors.tags||(this.target.tags[this.target.currentTagKey]=this.target.currentTagValue,this.target.currentTagKey="",this.target.currentTagValue="",this.targetBlur()),this.addTagMode=!1):this.addTagMode=!0}removeTag(t){delete this.target.tags[t],this.targetBlur()}editTag(t,e){this.removeTag(t),this.target.currentTagKey=t,this.target.currentTagValue=e,this.addTag()}closeAddTagMode(){this.addTagMode=!1}addFilter(){if(this.target.tags&&(0,f.size)(this.target.tags)>0&&(this.errors.filters="Please remove tags to use filters, tags and filters are mutually exclusive."),this.addFilterMode){if(this.target.filters||(this.target.filters=[]),this.target.currentFilterType||(this.target.currentFilterType="iliteral_or"),this.target.currentFilterGroupBy||(this.target.currentFilterGroupBy=!1),this.errors=this.validateTarget(),!this.errors.filters){const t={type:this.target.currentFilterType,tagk:this.target.currentFilterKey,filter:this.target.currentFilterValue,groupBy:this.target.currentFilterGroupBy};this.target.filters.push(t),this.target.currentFilterType="literal_or",this.target.currentFilterKey="",this.target.currentFilterValue="",this.target.currentFilterGroupBy=!1,this.targetBlur()}this.addFilterMode=!1}else this.addFilterMode=!0}removeFilter(t){this.target.filters.splice(t,1),this.targetBlur()}editFilter(t,e){this.removeFilter(e),this.target.currentFilterKey=t.tagk,this.target.currentFilterValue=t.filter,this.target.currentFilterType=t.type,this.target.currentFilterGroupBy=t.groupBy,this.addFilter()}closeAddFilterMode(){this.addFilterMode=!1}validateTarget(){const t={};if(this.target.shouldDownsample)try{this.target.downsampleInterval?s.rangeUtil.describeInterval(this.target.downsampleInterval):t.downsampleInterval="You must supply a downsample interval (e.g. '1m' or '1h')."}catch(e){t.downsampleInterval=e.message}return this.target.tags&&(0,f.has)(this.target.tags,this.target.currentTagKey)&&(t.tags="Duplicate tag key '"+this.target.currentTagKey+"'."),t}}x.$inject=["$scope","$injector"],L(x,"templateUrl","partials/query.editor.html");class k{}C="partials/annotations.editor.html",(M="templateUrl")in(j=k)?Object.defineProperty(j,M,{value:C,enumerable:!0,configurable:!0,writable:!0}):j[M]=C;const O=new s.DataSourcePlugin(F).setQueryCtrl(x).setConfigEditor((t=>{const{options:e,onOptionsChange:i}=t;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.DataSourceHttpSettings,{defaultUrl:"http://localhost:4242",dataSourceConfig:e,onChange:i}),(0,o.jsx)(u,{value:e,onChange:i})]})})).setAnnotationQueryCtrl(k)},60974:(t,e,i)=>{i.r(e),i.d(e,{MetricsPanelCtrl:()=>h,PanelCtrl:()=>l,QueryCtrl:()=>c,loadPluginCss:()=>s.loadPluginCss});var r=i(43215),s=i(90923),a=i(15866),n=i(91082),o=i(88643);const l=(0,r.makeClassES5Compatible)(n.q),h=(0,r.makeClassES5Compatible)(a.k),c=(0,r.makeClassES5Compatible)(o.G)}}]);
- //# sourceMappingURL=opentsdbPlugin.6e86fcc83f088cb80285.js.map
|