text: (window.webpackJsonp=window.webpackJsonp||[]).push([[58],{sl8e:function(e,t,r){"use strict";r.r(t);var a=r("LvDl"),n=r.n(a),i=r("Obii"),o=r("7Cbv"),s=r("iZOS");function u(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}var l=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.series=t.series,this.alias=t.alias,this.annotation=t.annotation,this.meta=t.meta,this.refId=t.refId}var t,r,a;return t=e,(r=[{key:"getTimeSeries",value:function(){var e,t,r=this,a=[];return 0===this.series.length?a:(n.a.each(this.series,(function(i){var o=i.columns.length,s=n.a.map(i.tags,(function(e,t){return t+": "+e}));for(t=1;t<o;t++){var u=i.name,l=i.columns[t];"value"!==l&&(u=u+"."+l),r.alias?u=r._getSeriesName(i,t):i.tags&&(u=u+" {"+s.join(", ")+"}");var c=[];if(i.values)for(e=0;e<i.values.length;e++)c[e]=[i.values[e][t],i.values[e][0]];a.push({target:u,datapoints:c,meta:r.meta,refId:r.refId})}})),a)}},{key:"_getSeriesName",value:function(e,t){var r=e.name.split(".");return this.alias.replace(/\$(\w+)|\[\[([\s\S]+?)\]\]/g,(function(a,n,i){var o=n||i,s=parseInt(o,10);if("m"===o||"measurement"===o)return e.name;if("col"===o)return e.columns[t];if(!isNaN(s))return r[s];if(0!==o.indexOf("tag_"))return a;var u=o.replace("tag_","");return e.tags?e.tags[u]:a}))}},{key:"getAnnotations",value:function(){var e=this,t=[];return n.a.each(this.series,(function(r){var a=null,i=null,o=[],s=null;n.a.each(r.columns,(function(t,r){"time"!==t?"sequence_number"!==t&&(t!==e.annotation.titleColumn?n.a.includes((e.annotation.tagsColumn||"").replace(" ","").split(","),t)?o.push(r):t!==e.annotation.textColumn?a||s===r||(a=r):s=r:a=r):i=r})),n.a.each(r.values,(function(r){var u={annotation:e.annotation,time:+new Date(r[i]),title:r[a],tags:n.a.flatten(o.filter((function(e){return r[e]})).map((function(e){return r[e].split(",")}))),text:r[s]};t.push(u)}))})),t}},{key:"getTable",value:function(){var e,t,r=new s.a;return r.refId=this.refId,r.meta=this.meta,0===this.series.length?r:(n.a.each(this.series,(function(a,o){if(0===o)for(t=0,"time"===a.columns[0]&&(r.columns.push({text:"Time",type:i.FieldType.time}),t++),n.a.each(n.a.keys(a.tags),(function(e){r.columns.push({text:e})}));t<a.columns.length;t++)r.columns.push({text:a.columns[t]});if(a.values)for(e=0;e<a.values.length;e++){var s=a.values[e],u=[s[0]];if(a.tags)for(var l in a.tags)a.tags.hasOwnProperty(l)&&u.push(a.tags[l]);for(t=1;t<s.length;t++)u.push(s[t]);r.rows.push(u)}})),r)}}])&&u(t.prototype,r),a&&u(t,a),e}(),c=r("QNPh"),p=[],m={Aggregations:[],Selectors:[],Transformations:[],Predictors:[],Math:[],Aliasing:[],Fields:[]};function f(e){var t=p[e.type];if(!t)throw{message:"Could not find query part "+e.type};return new c.a(e,t)}function d(e){p[e.type]=new c.b(e),e.category.push(p[e.type])}var g=[];function h(e,t){return"*"===e.params[0]?"*":'"'+e.params[0]+'"'}function y(e,t){for(var r=0;r<e.length;r++){var a=e[r];if(a.def.category===m.Aggregations){if(a.def.type===t.def.type)return;if("count"===a.def.type&&"distinct"===t.def.type)break;if("distinct"===a.def.type){var n=e.length>=r+2;if("count"!==t.def.type&&n)e[r+1].def.category===m.Aggregations&&e.splice(r+1,1);else if("count"===t.def.type)return void(n&&"count"===e[r+1].def.type||e.splice(r+1,0,t))}return void(e[r]=t)}if(a.def.category===m.Selectors)return void(e[r]=t)}e.splice(1,0,t)}function v(e,t){var r;for(r=0;r<e.length;r++){var a=e[r];if(a.def.category===m.Math||a.def.category===m.Aliasing)break}e.splice(r,0,t)}d({type:"field",addStrategy:function(e,t,r){var a=n.a.map(e,(function(e){return f({type:e.def.type,params:n.a.clone(e.params)})}));r.selectModels.push(a)},category:m.Fields,params:[{type:"field",dynamicLookup:!0}],defaultParams:["value"],renderer:h}),d({type:"count",addStrategy:y,category:m.Aggregations,params:[],defaultParams:[],renderer:c.c}),d({type:"distinct",addStrategy:y,category:m.Aggregations,params:[],defaultParams:[],renderer:c.c}),d({type:"integral",addStrategy:y,category:m.Aggregations,params:[],defaultParams:[],renderer:c.c}),d({type:"mean",addStrategy:y,category:m.Aggregations,params:[],defaultParams:[],renderer:c.c}),d({type:"median",addStrategy:y,category:m.Aggregations,params:[],defaultParams:[],renderer:c.c}),d({type:"mode",addStrategy:y,category:m.Aggregations,params:[],defaultParams:[],renderer:c.c}),d({type:"sum",addStrategy:y,category:m.Aggregations,params:[],defaultParams:[],renderer:c.c}),d({type:"derivative",addStrategy:v,category:m.Transformations,params:[{name:"duration",type:"interval",options:["1s","10s","1m","5m","10m","15m","1h"]}],defaultParams:["10s"],renderer:c.c}),d({type:"spread",addStrategy:v,category:m.Transformations,params:[],defaultParams:[],renderer:c.c}),d({type:"non_negative_derivative",addStrategy:v,category:m.Transformations,params:[{name:"duration",type:"interval",options:["1s","10s","1m","5m","10m","15m","1h"]}],defaultParams:["10s"],renderer:c.c}),d({type:"difference",addStrategy:v,category:m.Transformations,params:[],defaultParams:[],renderer:c.c}),d({type:"non_negative_difference",addStrategy:v,category:m.Transformations,params:[],defaultParams:[],renderer:c.c}),d({type:"moving_average",addStrategy:v,category:m.Transformations,params:[{name:"window",type:"int",options:[5,10,20,30,40]}],defaultParams:[10],renderer:c.c}),d({type:"cumulative_sum",addStrategy:v,category:m.Transformations,params:[],defaultParams:[],renderer:c.c}),d({type:"stddev",addStrategy:v,category:m.Transformations,params:[],defaultParams:[],renderer:c.c}),d({type:"time",category:g,params:[{name:"interval",type:"time",options:["$__interval","1s","10s","1m","5m","10m","15m","1h"]}],defaultParams:["$__interval"],renderer:c.c}),d({type:"fill",category:g,params:[{name:"fill",type:"string",options:["none","null","0","previous","linear"]}],defaultParams:["null"],renderer:c.c}),d({type:"elapsed",addStrategy:v,category:m.Transformations,params:[{name:"duration",type:"interval",options:["1s","10s","1m","5m","10m","15m","1h"]}],defaultParams:["10s"],renderer:c.c}),d({type:"holt_winters",addStrategy:v,category:m.Predictors,params:[{name:"number",type:"int",options:[5,10,20,30,40]},{name:"season",type:"int",options:[0,1,2,5,10]}],defaultParams:[10,2],renderer:c.c}),d({type:"holt_winters_with_fit",addStrategy:v,category:m.Predictors,params:[{name:"number",type:"int",options:[5,10,20,30,40]},{name:"season",type:"int",options:[0,1,2,5,10]}],defaultParams:[10,2],renderer:c.c}),d({type:"bottom",addStrategy:y,category:m.Selectors,params:[{name:"count",type:"int"}],defaultParams:[3],renderer:c.c}),d({type:"first",addStrategy:y,category:m.Selectors,params:[],defaultParams:[],renderer:c.c}),d({type:"last",addStrategy:y,category:m.Selectors,params:[],defaultParams:[],renderer:c.c}),d({type:"max",addStrategy:y,category:m.Selectors,params:[],defaultParams:[],renderer:c.c}),d({type:"min",addStrategy:y,category:m.Selectors,params:[],defaultParams:[],renderer:c.c}),d({type:"percentile",addStrategy:y,category:m.Selectors,params:[{name:"nth",type:"int"}],defaultParams:[95],renderer:c.c}),d({type:"top",addStrategy:y,category:m.Selectors,params:[{name:"count",type:"int"}],defaultParams:[3],renderer:c.c}),d({type:"tag",category:g,params:[{name:"tag",type:"string",dynamicLookup:!0}],defaultParams:["tag"],renderer:h}),d({type:"math",addStrategy:function(e,t){var r=e.length;if(r>0){if("math"===e[r-1].def.type)return void(e[r-1]=t);if(r>1&&"math"===e[r-2].def.type)return void(e[r-2]=t);if("alias"===e[r-1].def.type)return void e.splice(r-1,0,t)}e.push(t)},category:m.Math,params:[{name:"expr",type:"string"}],defaultParams:[" / 100"],renderer:c.d}),d({type:"alias",addStrategy:function(e,t){var r=e.length;r>0&&"alias"===e[r-1].def.type?e[r-1]=t:e.push(t)},category:m.Aliasing,params:[{name:"name",type:"string",quote:"double"}],defaultParams:["alias"],renderMode:"suffix",renderer:function(e,t){return t+' AS "'+e.params[0]+'"'}});var b={create:f,getCategories:function(){return m},replaceAggregationAdd:y},S=r("PbtU");function w(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}var E=function(){function e(t,r,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.target=t,this.templateSrv=r,this.scopedVars=a,t.policy=t.policy||"default",t.resultFormat=t.resultFormat||"time_series",t.orderByTime=t.orderByTime||"ASC",t.tags=t.tags||[],t.groupBy=t.groupBy||[{type:"time",params:["$__interval"]},{type:"fill",params:["null"]}],t.select=t.select||[[{type:"field",params:["value"]},{type:"mean",params:[]}]],this.updateProjection()}var t,r,a;return e.$inject=["target","templateSrv","scopedVars"],t=e,(r=[{key:"updateProjection",value:function(){this.selectModels=n.a.map(this.target.select,(function(e){return n.a.map(e,b.create)})),this.groupByParts=n.a.map(this.target.groupBy,b.create)}},{key:"updatePersistedParts",value:function(){this.target.select=n.a.map(this.selectModels,(function(e){return n.a.map(e,(function(e){return{type:e.def.type,params:e.params}}))}))}},{key:"hasGroupByTime",value:function(){return n.a.find(this.target.groupBy,(function(e){return"time"===e.type}))}},{key:"hasFill",value:function(){return n.a.find(this.target.groupBy,(function(e){return"fill"===e.type}))}},{key:"addGroupBy",value:function(e){var t=e.match(/^(\w+)\((.*)\)$/);if(t&&this.target.groupBy){var r=t[1],a=t[2],n=b.create({type:r,params:[a]}),i=this.target.groupBy.length;0===i?this.target.groupBy.push(n.part):"time"===r?this.target.groupBy.splice(0,0,n.part):"tag"===r&&"fill"===this.target.groupBy[i-1].type?this.target.groupBy.splice(i-1,0,n.part):this.target.groupBy.push(n.part),this.updateProjection()}}},{key:"removeGroupByPart",value:function(e,t){var r=b.getCategories();"time"===e.def.type&&(this.target.groupBy=n.a.filter(this.target.groupBy,(function(e){return"fill"!==e.type})),this.target.select=n.a.map(this.target.select,(function(e){return n.a.filter(e,(function(e){var t=b.create(e);return t.def.category!==r.Aggregations&&t.def.category!==r.Selectors}))}))),this.target.groupBy.splice(t,1),this.updateProjection()}},{key:"removeSelect",value:function(e){this.target.select.splice(e,1),this.updateProjection()}},{key:"removeSelectPart",value:function(e,t){if("field"===t.def.type){if(this.selectModels.length>1){var r=n.a.indexOf(this.selectModels,e);this.selectModels.splice(r,1)}}else{var a=n.a.indexOf(e,t);e.splice(a,1)}this.updatePersistedParts()}},{key:"addSelectPart",value:function(e,t){var r=b.create({type:t});r.def.addStrategy(e,r,this),this.updatePersistedParts()}},{key:"renderTagCondition",value:function(e,t,r){var a="",n=e.operator,i=e.value;return t>0&&(a=(e.condition||"AND")+" "),n||(n=/^\/.*\/$/.test(i)?"=~":"="),"=~"!==n&&"!~"!==n?(r&&(i=this.templateSrv.replace(i,this.scopedVars)),">"!==n&&"<"!==n&&(i="'"+i.replace(/\\/g,"\\\\").replace(/\'/g,"\\'")+"'")):r&&(i=this.templateSrv.replace(i,this.scopedVars,"regex")),a+'"'+e.key+'" '+n+" "+i}},{key:"getMeasurementAndPolicy",value:function(e){var t=this.target.policy,r=this.target.measurement||"measurement";return r.match("^/.*/$")?e&&(r=this.templateSrv.replace(r,this.scopedVars,"regex")):r='"'+r+'"',(t="default"!==t?'"'+this.target.policy+'".':"")+r}},{key:"interpolateQueryStr",value:function(e,t,r){return t.multi||t.includeAll?"string"==typeof e?S.a.regexEscape(e):"("+n.a.map(e,S.a.regexEscape).join("|")+")":e}},{key:"render",value:function(e){var t=this,r=this.target;if(r.rawQuery)return e?this.templateSrv.replace(r.query,this.scopedVars,this.interpolateQueryStr):r.query;var a,i,o="SELECT ";for(a=0;a<this.selectModels.length;a++){var s=this.selectModels[a],u="";for(i=0;i<s.length;i++)u=s[i].render(u);a>0&&(o+=", "),o+=u}o+=" FROM "+this.getMeasurementAndPolicy(e)+" WHERE ";var l=n.a.map(r.tags,(function(r,a){return t.renderTagCondition(r,a,e)}));l.length>0&&(o+="("+l.join(" ")+") AND "),o+="$timeFilter";var c="";for(a=0;a<this.groupByParts.length;a++){var p=this.groupByParts[a];a>0&&(c+="fill"===p.def.type?" ":", "),c+=p.render("")}return c.length&&(o+=" GROUP BY "+c),r.fill&&(o+=" fill("+r.fill+")"),"DESC"===r.orderByTime&&(o+=" ORDER BY time DESC"),r.limit&&(o+=" LIMIT "+r.limit),r.slimit&&(o+=" SLIMIT "+r.slimit),r.tz&&(o+=" tz('"+r.tz+"')"),o}},{key:"renderAdhocFilters",value:function(e){var t=this;return n.a.map(e,(function(e,r){return t.renderTagCondition(e,r,!0)})).join(" ")}}])&&w(t.prototype,r),a&&w(t,a),e}();function O(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}var x=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,r,a;return t=e,(r=[{key:"parse",value:function(e,t){if(!t||0===t.results.length)return[];var r=t.results[0];if(!r.series)return[];var a=e.toLowerCase(),i=a.indexOf("show field keys")>=0||a.indexOf("show retention policies")>=0,o={};return n.a.each(r.series,(function(e){n.a.each(e.values,(function(e){n.a.isArray(e)?i?P(o,e[0]):void 0!==e[1]?P(o,e[1]):P(o,e[0]):P(o,e)}))})),n.a.map(o,(function(e){return{text:e.toString()}}))}}])&&O(t.prototype,r),a&&O(t,a),e}();function P(e,t){e[t]=t}function k(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}var T,j=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.target=t,this.database=r}var t,r,a;return t=e,(r=[{key:"buildExploreQuery",value:function(e,t,r){var a,i,o="";if("TAG_KEYS"===e)o="SHOW TAG KEYS",a=this.target.measurement,i=this.target.policy;else if("TAG_VALUES"===e)o="SHOW TAG VALUES",a=this.target.measurement,i=this.target.policy;else if("MEASUREMENTS"===e)o="SHOW MEASUREMENTS",r&&(o+=" WITH MEASUREMENT =~ /"+S.a.regexEscape(r)+"/");else{if("FIELDS"===e)return a=this.target.measurement,i=this.target.policy,a.match("^/.*/")||(a='"'+a+'"',i&&"default"!==i&&(a=(i='"'+i+'"')+"."+a)),"SHOW FIELD KEYS FROM "+a;if("RETENTION POLICIES"===e)return o='SHOW RETENTION POLICIES on "'+this.database+'"'}if(a&&(a.match("^/.*/")||a.match(/^merge\(.*\)/)||(a='"'+a+'"'),i&&"default"!==i&&(a=(i='"'+i+'"')+"."+a),o+=" FROM "+a),t&&(o+=' WITH KEY = "'+t+'"'),this.target.tags&&this.target.tags.length>0){var s=n.a.reduce(this.target.tags,(function(e,r){return r.key===t?e:">"===r.operator||"<"===r.operator?e:(e.push(function(e,t){var r="",a=e.operator,n=e.value;return t>0&&(r=(e.condition||"AND")+" "),a||(a=/^\/.*\/$/.test(e.value)?"=~":"="),"=~"!==a&&"!~"!==a&&isNaN(+n)&&(n="'"+n+"'"),r+'"'+e.key+'" '+a+" "+n}(r,e.length)),e)}),[]);s.length>0&&(o+=" WHERE "+s.join(" "))}return"MEASUREMENTS"===e&&(o+=" LIMIT 100"),o}}])&&k(t.prototype,r),a&&k(t,a),e}();!function(e){e.InfluxQL="InfluxQL",e.Flux="Flux"}(T||(T={}));var C=r("5kRJ"),I=r("t8hP"),_=r("0/uQ"),D=r("q1tI"),N=r.n(D),F=r("txxJ"),R=r("kDDq"),B=r("kDLi");function q(e){return(q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Q(){var e=function(e,t){t||(t=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}(["\n              margin-top: 6px;\n            "]);return Q=function(){return e},e}function A(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function M(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?A(Object(r),!0).forEach((function(t){L(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):A(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function L(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function U(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function G(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function V(e,t){return!t||"object"!==q(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function $(e){return($=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function z(e,t){return(z=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var K=[{label:"Show buckets",description:"List the available buckets (table)",value:"buckets()"},{label:"Simple query",description:"filter by measurement and field",value:'from(bucket: "db/rp")\n  |> range(start: v.timeRangeStart, stop:v.timeRangeStop)\n  |> filter(fn: (r) =>\n    r._measurement == "example-measurement" and\n    r._field == "example-field"\n  )'},{label:"Grouped Query",description:"Group by (min/max/sum/median)",value:'// v.windowPeriod is a variable referring to the current optimized window period (currently: $interval)\nfrom(bucket: v.bucket)\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n  |> filter(fn: (r) => r["_measurement"] == "measurement1" or r["_measurement"] =~ /^.*?regex.*$/)\n  |> filter(fn: (r) => r["_field"] == "field2" or r["_field"] =~ /^.*?regex.*$/)\n  |> aggregateWindow(every: v.windowPeriod, fn: mean|median|max|count|derivative|sum)\n  |> yield(name: "some-name")'},{label:"Filter by value",description:"Results between a min/max",value:'// v.bucket, v.timeRangeStart, and v.timeRange stop are all variables supported by the flux plugin and influxdb\nfrom(bucket: v.bucket)\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n  |> filter(fn: (r) => r["_value"] >= 10 and r["_value"] <= 20)'},{label:"Schema Exploration: (measurements)",description:"Get a list of measurement using flux",value:'import "influxdata/influxdb/v1"\nv1.measurements(bucket: v.bucket)'},{label:"Schema Exploration: (fields)",description:"Return every possible key in a single table",value:'from(bucket: v.bucket)\n  |> range(start: v.timeRangeStart, stop:v.timeRangeStop)\n  |> keys()\n  |> keep(columns: ["_value"])\n  |> group()\n  |> distinct()'},{label:"Schema Exploration: (tag keys)",description:"Get a list of tag keys using flux",value:'import "influxdata/influxdb/v1"\nv1.tagKeys(bucket: v.bucket)'},{label:"Schema Exploration: (tag values)",description:"Get a list of tag values using flux",value:'import "influxdata/influxdb/v1"\nv1.tagValues(\n    bucket: v.bucket,\n    tag: "host",\n    predicate: (r) => true,\n    start: -1d\n)'}],H=function(e){function t(){var e,r;U(this,t);for(var a=arguments.length,n=new Array(a),i=0;i<a;i++)n[i]=arguments[i];return(r=V(this,(e=$(t)).call.apply(e,[this].concat(n)))).onFluxQueryChange=function(e){r.props.onChange(M({},r.props.query,{query:e})),r.props.onRunQuery()},r.onSampleChange=function(e){r.props.onChange(M({},r.props.query,{query:e.value})),r.forceUpdate(),r.props.onRunQuery()},r.getSuggestions=function(){var e=[{label:"v.timeRangeStart",kind:B.CodeEditorSuggestionItemKind.Property,detail:"The start time"},{label:"v.timeRangeStop",kind:B.CodeEditorSuggestionItemKind.Property,detail:"The stop time"},{label:"v.windowPeriod",kind:B.CodeEditorSuggestionItemKind.Property,detail:"based on max data points"},{label:"v.defaultBucket",kind:B.CodeEditorSuggestionItemKind.Property,detail:"bucket configured in the datsource"},{label:"v.organization",kind:B.CodeEditorSuggestionItemKind.Property,detail:"org configured for the datsource"}],t=Object(I.getTemplateSrv)();return t.getVariables().forEach((function(r){var a="${"+r.name+"}",n=t.replace(a);n===a&&(n=""),e.push({label:a,kind:B.CodeEditorSuggestionItemKind.Text,detail:"(Template Variable) ".concat(n)})})),e},r.editorDidMountCallbackHack=function(e){setTimeout((function(){return e.layout()}),100)},r}var r,a,n;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&z(e,t)}(t,e),r=t,(a=[{key:"render",value:function(){var e=this.props.query,t=N.a.createElement("div",null,"Type: ",N.a.createElement("i",null,"ctrl+space")," to show template variable suggestions ",N.a.createElement("br",null),"Many queries can be copied from chronograph");return N.a.createElement(N.a.Fragment,null,N.a.createElement(B.CodeEditor,{height:"200px",language:"sql",value:e.query||"",onBlur:this.onFluxQueryChange,onSave:this.onFluxQueryChange,showMiniMap:!1,showLineNumbers:!0,getSuggestions:this.getSuggestions,onEditorDidMount:this.editorDidMountCallbackHack}),N.a.createElement("div",{className:Object(R.cx)("gf-form-inline",Object(R.css)(Q()))},N.a.createElement(B.LinkButton,{icon:"external-link-alt",variant:"secondary",target:"blank",href:"https://docs.influxdata.com/flux/latest/introduction/getting-started/"},"Flux language syntax"),N.a.createElement(B.Segment,{options:K,value:"Sample Query",onChange:this.onSampleChange}),N.a.createElement("div",{className:"gf-form gf-form--grow"},N.a.createElement("div",{className:"gf-form-label gf-form-label--grow"})),N.a.createElement(B.InlineFormLabel,{width:5,tooltip:t},"Help")))}}])&&G(r.prototype,a),n&&G(r,n),t}(D.PureComponent);function W(e){return(W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function J(e,t,r,a,n,i,o){try{var s=e[i](o),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(a,n)}function Y(e){return function(){var t=this,r=arguments;return new Promise((function(a,n){var i=e.apply(t,r);function o(e){J(i,a,n,o,s,"next",e)}function s(e){J(i,a,n,o,s,"throw",e)}o(void 0)}))}}function X(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function Z(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?X(Object(r),!0).forEach((function(t){ee(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):X(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function ee(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function te(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function re(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function ae(e,t){return!t||"object"!==W(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function ne(e,t,r){return(ne="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var a=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=ie(e)););return e}(e,t);if(a){var n=Object.getOwnPropertyDescriptor(a,t);return n.get?n.get.call(r):n.value}})(e,t,r||e)}function ie(e){return(ie=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function oe(e,t){return(oe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}F.c.directive("fluxQueryEditor",["reactDirective",function(e){return e(H,["query","onChange","onRunQuery"])}]);var se=function(e){function t(e){var r,a,n,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Object(C.a)();te(this,t),(i=ae(this,ie(t).call(this,e))).templateSrv=o,i.type="influxdb",i.urls=(null!==(r=e.url)&&void 0!==r?r:"").split(",").map((function(e){return e.trim()})),i.username=null!==(a=e.username)&&void 0!==a?a:"",i.password=null!==(n=e.password)&&void 0!==n?n:"",i.name=e.name,i.database=e.database,i.basicAuth=e.basicAuth,i.withCredentials=e.withCredentials;var s=e.jsonData||{};return i.interval=s.timeInterval,i.httpMode=s.httpMode||"GET",i.responseParser=new x,i.isFlux=s.version===T.Flux,i.isFlux&&(i.annotations={QueryEditor:H}),i}var r,a,s,u,c,p;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&oe(e,t)}(t,e),r=t,(a=[{key:"query",value:function(e){return this.isFlux?ne(ie(t.prototype),"query",this).call(this,e):Object(_.a)(this.classicQuery(e))}},{key:"getQueryDisplayText",value:function(e){return this.isFlux?e.query:new E(e).render(!1)}},{key:"filterQuery",value:function(e){return!this.isFlux||!!e.query}},{key:"applyTemplateVariables",value:function(e,t){var r;return Z({},e,{query:this.templateSrv.replace(null!==(r=e.query)&&void 0!==r?r:"",t)})}},{key:"classicQuery",value:(p=Y(regeneratorRuntime.mark((function e(t){var r,a,i,o,s,u,c,p,m,f=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getTimeFilter(t),a=t.scopedVars,i=n.a.cloneDeep(t.targets),o=[],""!==(c=n.a.map(i,(function(e){return e.hide?"":(o.push(e),a.interval=a.__interval,new E(e,f.templateSrv,a).render(!0))})).reduce((function(e,t){return""!==t&&(e+=";"+t),e})))){e.next=7;break}return e.abrupt("return",Promise.resolve({data:[]}));case 7:return(p=this.templateSrv.getAdhocFilters(this.name)).length>0&&(m=new E({refId:"A"},this.templateSrv,a),r+=" AND "+m.renderAdhocFilters(p)),a.timeFilter={value:r},c=this.templateSrv.replace(c,a),e.abrupt("return",this._seriesQuery(c,t).then((function(e){if(!e||!e.results)return[];var r=[];for(s=0;s<e.results.length;s++){var a=e.results[s];if(a&&a.series){var n=o[s],i=n.alias;i&&(i=f.templateSrv.replace(n.alias,t.scopedVars));var c={executedQueryString:e.executedQueryString},p=new l({refId:n.refId,series:e.results[s].series,alias:i,meta:c});switch(n.resultFormat){case"logs":c.preferredVisualisationType="logs";case"table":r.push(p.getTable());break;default:var m=p.getTimeSeries();for(u=0;u<m.length;u++)r.push(m[u])}}}return{data:r}})));case 12:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"annotationQuery",value:(c=Y(regeneratorRuntime.mark((function e(t){var r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isFlux){e.next=2;break}return e.abrupt("return",Promise.reject({message:"Flux requires the standard annotation query"}));case 2:if(t.annotation.query){e.next=4;break}return e.abrupt("return",Promise.reject({message:"Query missing in annotation definition"}));case 4:return r=this.getTimeFilter({rangeRaw:t.rangeRaw,timezone:t.dashboard.timezone}),a=t.annotation.query.replace("$timeFilter",r),a=this.templateSrv.replace(a,void 0,"regex"),e.abrupt("return",this._seriesQuery(a,t).then((function(e){if(!e||!e.results||!e.results[0])throw{message:"No results in response from InfluxDB"};return new l({series:e.results[0].series,annotation:t.annotation}).getAnnotations()})));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"targetContainsTemplate",value:function(e){var t=!0,r=!1,a=void 0;try{for(var n,i=e.groupBy[Symbol.iterator]();!(t=(n=i.next()).done);t=!0){var o=n.value,s=!0,u=!1,l=void 0;try{for(var c,p=o.params[Symbol.iterator]();!(s=(c=p.next()).done);s=!0){var m=c.value;if(this.templateSrv.variableExists(m))return!0}}catch(e){u=!0,l=e}finally{try{s||null==p.return||p.return()}finally{if(u)throw l}}}}catch(e){r=!0,a=e}finally{try{t||null==i.return||i.return()}finally{if(r)throw a}}for(var f in e.tags)if(this.templateSrv.variableExists(e.tags[f].value))return!0;return!1}},{key:"interpolateVariablesInQueries",value:function(e,t){var r=this;if(!e||0===e.length)return[];var a=e;return e&&e.length>0&&(a=e.map((function(e){var a,n,i,o=Z({},e,{datasource:r.name,measurement:r.templateSrv.replace(null!==(a=e.measurement)&&void 0!==a?a:"",t,"regex"),policy:r.templateSrv.replace(null!==(n=e.policy)&&void 0!==n?n:"",t,"regex")});if(e.rawQuery&&(o.query=r.templateSrv.replace(null!==(i=e.query)&&void 0!==i?i:"",t,"regex")),e.tags){var s=e.tags.map((function(e){return Z({},e,{value:r.templateSrv.replace(e.value,void 0,"regex")})}));o.tags=s}return o}))),a}},{key:"metricFindQuery",value:(u=Y(regeneratorRuntime.mark((function e(r,a){var n,i,o=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isFlux){e.next=3;break}return n={refId:"metricFindQuery",query:r},e.abrupt("return",ne(ie(t.prototype),"query",this).call(this,Z({},a,{targets:[n]})).toPromise().then((function(e){var t;return(null===(t=e.data)||void 0===t?void 0:t.length)?Object(I.frameToMetricFindValue)(e.data[0]):[]})));case 3:return i=this.templateSrv.replace(r,void 0,"regex"),e.abrupt("return",this._seriesQuery(i,a).then((function(e){return o.responseParser.parse(r,e)})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"getTagKeys",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new j({measurement:e.measurement||"",tags:[]},this.database),r=t.buildExploreQuery("TAG_KEYS");return this.metricFindQuery(r,e)}},{key:"getTagValues",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new j({measurement:e.measurement||"",tags:[]},this.database),r=t.buildExploreQuery("TAG_VALUES",e.key);return this.metricFindQuery(r,e)}},{key:"_seriesQuery",value:function(e,t){if(!e)return Promise.resolve({results:[]});if(t&&t.range){var r=this.getTimeFilter({rangeRaw:t.range,timezone:t.timezone});e=e.replace("$timeFilter",r)}return this._influxRequest(this.httpMode,"/query",{q:e,epoch:"ms"},t)}},{key:"serializeParams",value:function(e){return e?n.a.reduce(e,(function(e,t,r){return null==t?e:(e.push(encodeURIComponent(r)+"="+encodeURIComponent(t)),e)}),[]).join("&"):""}},{key:"testDatasource",value:function(){if(this.isFlux){var e={targets:[{refId:"test",query:"buckets()"}],requestId:"".concat(this.id,"-health-").concat(Object(o.a)()),dashboardId:0,panelId:0,interval:"1m",intervalMs:6e4,maxDataPoints:423,range:{from:Object(i.dateTime)(1e3),to:Object(i.dateTime)(2e3)}};return ne(ie(t.prototype),"query",this).call(this,e).toPromise().then((function(e){if(!e||!e.data||e.state!==i.LoadingState.Done)return console.error("InfluxDB Error",e),{status:"error",message:"Error reading InfluxDB"};var t=e.data[0];return t&&t.length?{status:"success",message:"".concat(t.length," buckets found")}:(console.error("InfluxDB Error",e),{status:"error",message:"Error reading buckets"})})).catch((function(e){return console.error("InfluxDB Error",e),{status:"error",message:e.message}}))}var r=new j({measurement:"",tags:[]},this.database).buildExploreQuery("RETENTION POLICIES");return this._seriesQuery(r).then((function(e){var t=n.a.get(e,"results[0].error");return t?{status:"error",message:t}:{status:"success",message:"Data source is working"}})).catch((function(e){return{status:"error",message:e.message}}))}},{key:"_influxRequest",value:function(e,t,r,a){var i=this.urls.shift();this.urls.push(i);var o={};this.username&&(o.u=this.username,o.p=this.password),a&&a.database?o.db=a.database:this.database&&(o.db=this.database);var s=r.q;"POST"===e&&n.a.has(r,"q")?(n.a.extend(o,n.a.omit(r,["q"])),r=this.serializeParams(n.a.pick(r,["q"]))):"GET"!==e&&"POST"!==e||(n.a.extend(o,r),r=null);var u={method:e,url:i+t,params:o,data:r,precision:"ms",inspect:{type:"influxdb"},paramSerializer:this.serializeParams};return u.headers=u.headers||{},(this.basicAuth||this.withCredentials)&&(u.withCredentials=!0),this.basicAuth&&(u.headers.Authorization=this.basicAuth),"POST"===e&&(u.headers["Content-type"]="application/x-www-form-urlencoded"),Object(I.getBackendSrv)().datasourceRequest(u).then((function(e){var t=e.data;if(t&&(t.executedQueryString=s,t.results)){var r=e.data.results.filter((function(e){return e.error}));if(r.length>0)throw{message:"InfluxDB Error: "+r[0].error,data:t}}return t}),(function(e){throw Number.isInteger(e.status)&&0!==e.status||e.status>=300?e.data&&e.data.error?{message:"InfluxDB Error: "+e.data.error,data:e.data,config:e.config}:{message:"Network Error: "+e.statusText+"("+e.status+")",data:e.data,config:e.config}:e}))}},{key:"getTimeFilter",value:function(e){var t=this.getInfluxTime(e.rangeRaw.from,!1,e.timezone),r=this.getInfluxTime(e.rangeRaw.to,!0,e.timezone),a="ms"===t[t.length-1];return"now()"!==r||a?"time >= "+t+" and time <= "+r:"time >= "+t}},{key:"getInfluxTime",value:function(e,t,r){if(n.a.isString(e)){if("now"===e)return"now()";var a=/^now-(\d+)([dhms])$/.exec(e);if(a)return"now() - "+parseInt(a[1],10)+a[2];e=i.dateMath.parse(e,t,r)}return e.valueOf()+"ms"}}])&&re(r.prototype,a),s&&re(r,s),t}(I.DataSourceWithBackend),ue=r("KHwQ"),le=r.n(ue);function ce(e){return(ce="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function pe(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function me(e,t){return!t||"object"!==ce(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function fe(e){return(fe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function de(e,t){return(de=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var ge=function(e){function t(e,r,a,n){var i;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(i=me(this,fe(t).call(this,e,r))).templateSrv=a,i.uiSegmentSrv=n,i.onChange=function(e){i.target.query=e.query},i.onRunQuery=function(){i.panelCtrl.refresh()},i.target=i.target,i.queryModel=new E(i.target,a,i.panel.scopedVars),i.queryBuilder=new j(i.target,i.datasource.database),i.groupBySegment=i.uiSegmentSrv.newPlusButton(),i.resultFormats=[{text:"Time series",value:"time_series"},{text:"Table",value:"table"},{text:"Logs",value:"logs"}],i.policySegment=n.newSegment(i.target.policy),i.target.measurement?i.measurementSegment=n.newSegment(i.target.measurement):i.measurementSegment=n.newSelectMeasurement(),i.tagSegments=[];var o=!0,s=!1,u=void 0;try{for(var l,c=i.target.tags[Symbol.iterator]();!(o=(l=c.next()).done);o=!0){var p=l.value;p.operator||(/^\/.*\/$/.test(p.value)?p.operator="=~":p.operator="="),p.condition&&i.tagSegments.push(n.newCondition(p.condition)),i.tagSegments.push(n.newKey(p.key)),i.tagSegments.push(n.newOperator(p.operator)),i.tagSegments.push(n.newKeyValue(p.value))}}catch(e){s=!0,u=e}finally{try{o||null==c.return||c.return()}finally{if(s)throw u}}return i.fixTagSegments(),i.buildSelectMenu(),i.removeTagFilterSegment=n.newSegment({fake:!0,value:"-- remove tag filter --"}),i}var r,a,i;return t.$inject=["$scope","$injector","templateSrv","uiSegmentSrv"],function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&de(e,t)}(t,e),r=t,(a=[{key:"removeOrderByTime",value:function(){this.target.orderByTime="ASC"}},{key:"buildSelectMenu",value:function(){var e=b.getCategories();this.selectMenu=n.a.reduce(e,(function(e,t,r){var a={text:r,submenu:t.map((function(e){return{text:e.type,value:e.type}}))};return e.push(a),e}),[])}},{key:"getGroupByOptions",value:function(){var e=this,t=this.queryBuilder.buildExploreQuery("TAG_KEYS");return this.datasource.metricFindQuery(t).then((function(t){var r=[];e.queryModel.hasFill()||r.push(e.uiSegmentSrv.newSegment({value:"fill(null)"})),e.target.limit||r.push(e.uiSegmentSrv.newSegment({value:"LIMIT"})),e.target.slimit||r.push(e.uiSegmentSrv.newSegment({value:"SLIMIT"})),e.target.tz||r.push(e.uiSegmentSrv.newSegment({value:"tz"})),"ASC"===e.target.orderByTime&&r.push(e.uiSegmentSrv.newSegment({value:"ORDER BY time DESC"})),e.queryModel.hasGroupByTime()||r.push(e.uiSegmentSrv.newSegment({value:"time($interval)"}));var a=!0,n=!1,i=void 0;try{for(var o,s=t[Symbol.iterator]();!(a=(o=s.next()).done);a=!0){var u=o.value;r.push(e.uiSegmentSrv.newSegment({value:"tag("+u.text+")"}))}}catch(e){n=!0,i=e}finally{try{a||null==s.return||s.return()}finally{if(n)throw i}}return r})).catch(this.handleQueryError.bind(this))}},{key:"groupByAction",value:function(){switch(this.groupBySegment.value){case"LIMIT":this.target.limit=10;break;case"SLIMIT":this.target.slimit=10;break;case"tz":this.target.tz="UTC";break;case"ORDER BY time DESC":this.target.orderByTime="DESC";break;default:this.queryModel.addGroupBy(this.groupBySegment.value)}var e=this.uiSegmentSrv.newPlusButton();this.groupBySegment.value=e.value,this.groupBySegment.html=e.html,this.groupBySegment.fake=!0,this.panelCtrl.refresh()}},{key:"addSelectPart",value:function(e,t,r){this.queryModel.addSelectPart(e,r.value),this.panelCtrl.refresh()}},{key:"handleSelectPartEvent",value:function(e,t,r){switch(r.name){case"get-param-options":var a=this.queryBuilder.buildExploreQuery("FIELDS");return this.datasource.metricFindQuery(a).then(this.transformToSegments(!0)).catch(this.handleQueryError.bind(this));case"part-param-changed":this.panelCtrl.refresh();break;case"action":this.queryModel.removeSelectPart(e,t),this.panelCtrl.refresh();break;case"get-part-actions":return Promise.resolve([{text:"Remove",value:"remove-part"}])}return Promise.resolve()}},{key:"handleGroupByPartEvent",value:function(e,t,r){switch(r.name){case"get-param-options":var a=this.queryBuilder.buildExploreQuery("TAG_KEYS");return this.datasource.metricFindQuery(a).then(this.transformToSegments(!0)).catch(this.handleQueryError.bind(this));case"part-param-changed":this.panelCtrl.refresh();break;case"action":this.queryModel.removeGroupByPart(e,t),this.panelCtrl.refresh();break;case"get-part-actions":return Promise.resolve([{text:"Remove",value:"remove-part"}])}return Promise.resolve()}},{key:"fixTagSegments",value:function(){var e=this.tagSegments.length,t=this.tagSegments[Math.max(e-1,0)];t&&"plus-button"===t.type||this.tagSegments.push(this.uiSegmentSrv.newPlusButton())}},{key:"measurementChanged",value:function(){this.target.measurement=this.measurementSegment.value,this.panelCtrl.refresh()}},{key:"getPolicySegments",value:function(){var e=this.queryBuilder.buildExploreQuery("RETENTION POLICIES");return this.datasource.metricFindQuery(e).then(this.transformToSegments(!1)).catch(this.handleQueryError.bind(this))}},{key:"policyChanged",value:function(){this.target.policy=this.policySegment.value,this.panelCtrl.refresh()}},{key:"toggleEditorMode",value:function(){if(!this.datasource.isFlux){try{this.target.query=this.queryModel.render(!1)}catch(e){console.error("query render error")}this.target.rawQuery=!this.target.rawQuery}}},{key:"getMeasurements",value:function(e){var t=this.queryBuilder.buildExploreQuery("MEASUREMENTS",void 0,e);return this.datasource.metricFindQuery(t).then(this.transformToSegments(!0)).catch(this.handleQueryError.bind(this))}},{key:"handleQueryError",value:function(e){return this.error=e.message||"Failed to issue metric query",[]}},{key:"transformToSegments",value:function(e){var t=this;return function(r){var a=n.a.map(r,(function(e){return t.uiSegmentSrv.newSegment({value:e.text,expandable:e.expandable})}));if(e){var i=!0,o=!1,s=void 0;try{for(var u,l=t.templateSrv.getVariables()[Symbol.iterator]();!(i=(u=l.next()).done);i=!0){var c=u.value;a.unshift(t.uiSegmentSrv.newSegment({type:"value",value:"/^$"+c.name+"$/",expandable:!0}))}}catch(e){o=!0,s=e}finally{try{i||null==l.return||l.return()}finally{if(o)throw s}}}return a}}},{key:"getTagsOrValues",value:function(e,t){var r,a,n=this;if("condition"===e.type)return Promise.resolve([this.uiSegmentSrv.newSegment("AND"),this.uiSegmentSrv.newSegment("OR")]);if("operator"===e.type){var i=this.tagSegments[t+1].value;return/^\/.*\/$/.test(i)?Promise.resolve(this.uiSegmentSrv.newOperators(["=~","!~"])):Promise.resolve(this.uiSegmentSrv.newOperators(["=","!=","<>","<",">"]))}return"key"===e.type||"plus-button"===e.type?(r=this.queryBuilder.buildExploreQuery("TAG_KEYS"),a=!1):"value"===e.type&&(r=this.queryBuilder.buildExploreQuery("TAG_VALUES",this.tagSegments[t-2].value),a=!0),this.datasource.metricFindQuery(r).then(this.transformToSegments(a)).then((function(t){return"key"===e.type&&t.splice(0,0,le.a.copy(n.removeTagFilterSegment)),t})).catch(this.handleQueryError.bind(this))}},{key:"getFieldSegments",value:function(){var e=this.queryBuilder.buildExploreQuery("FIELDS");return this.datasource.metricFindQuery(e).then(this.transformToSegments(!1)).catch(this.handleQueryError)}},{key:"tagSegmentUpdated",value:function(e,t){this.tagSegments[t]=e,e.value===this.removeTagFilterSegment.value?(this.tagSegments.splice(t,3),0===this.tagSegments.length?this.tagSegments.push(this.uiSegmentSrv.newPlusButton()):this.tagSegments.length>2&&(this.tagSegments.splice(Math.max(t-1,0),1),"plus-button"!==this.tagSegments[this.tagSegments.length-1].type&&this.tagSegments.push(this.uiSegmentSrv.newPlusButton()))):("plus-button"===e.type&&(t>2&&this.tagSegments.splice(t,0,this.uiSegmentSrv.newCondition("AND")),this.tagSegments.push(this.uiSegmentSrv.newOperator("=")),this.tagSegments.push(this.uiSegmentSrv.newFake("select tag value","value","query-segment-value")),e.type="key",e.cssClass="query-segment-key"),t+1===this.tagSegments.length&&this.tagSegments.push(this.uiSegmentSrv.newPlusButton())),this.rebuildTargetTagConditions()}},{key:"rebuildTargetTagConditions",value:function(){var e=this,t=[],r=0,a="";n.a.each(this.tagSegments,(function(n,i){"key"===n.type?(0===t.length&&t.push({}),t[r].key=n.value):"value"===n.type?((a=e.getTagValueOperator(n.value,t[r].operator))&&(e.tagSegments[i-1]=e.uiSegmentSrv.newOperator(a),t[r].operator=a),t[r].value=n.value):"condition"===n.type?(t.push({condition:n.value}),r+=1):"operator"===n.type&&(t[r].operator=n.value)})),this.target.tags=t,this.panelCtrl.refresh()}},{key:"getTagValueOperator",value:function(e,t){return"=~"!==t&&"!~"!==t&&/^\/.*\/$/.test(e)?"=~":"=~"!==t&&"!~"!==t||!/^(?!\/.*\/$)/.test(e)?null:"="}}])&&pe(r.prototype,a),i&&pe(r,i),t}(r("LzXI").QueryCtrl);ge.templateUrl="partials/query.editor.html";var he=[{title:"Getting started",label:"Start by selecting a measurement and field from the dropdown above. You can then use the tag selector to further narrow your search."}],ye=function(e){return N.a.createElement("div",null,N.a.createElement("h2",null,"InfluxDB Cheat Sheet"),he.map((function(e){return N.a.createElement("div",{className:"cheat-sheet-item",key:e.title},N.a.createElement("div",{className:"cheat-sheet-item__title"},e.title),N.a.createElement("div",{className:"cheat-sheet-item__label"},e.label))})))};function ve(e){return(ve="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function be(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Se(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function we(e,t){return!t||"object"!==ve(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Ee(e){return(Ee=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Oe(e,t){return(Oe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var xe=function(e){function t(){return be(this,t),we(this,Ee(t).apply(this,arguments))}var r,a,n;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Oe(e,t)}(t,e),r=t,(a=[{key:"render",value:function(){return N.a.createElement(ye,{onClickExample:this.props.onClickExample})}}])&&Se(r.prototype,a),n&&Se(r,n),t}(D.PureComponent);function Pe(e){return(Pe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ke(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function Te(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ke(Object(r),!0).forEach((function(t){je(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ke(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function je(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ce(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ie(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function _e(e,t){return!t||"object"!==Pe(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function De(e){return(De=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Ne(e,t){return(Ne=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Fe=B.LegacyForms.Select,Re=B.LegacyForms.Input,Be=B.LegacyForms.SecretFormField,qe=[{label:"GET",value:"GET"},{label:"POST",value:"POST"}],Qe=[{label:"InfluxQL",value:T.InfluxQL,description:"The InfluxDB SQL-like query language.  Supported in InfluxDB 1.x"},{label:"Flux",value:T.Flux,description:"Advanced data scripting and query language.  Supported in InfluxDB 2.x and 1.8+ (beta)"}],Ae=function(e){function t(){var e,r;Ce(this,t);for(var a=arguments.length,n=new Array(a),o=0;o<a;o++)n[o]=arguments[o];return(r=_e(this,(e=De(t)).call.apply(e,[this].concat(n)))).onResetPassword=function(){Object(i.updateDatasourcePluginResetOption)(r.props,"password")},r.onResetToken=function(){Object(i.updateDatasourcePluginResetOption)(r.props,"token")},r.onVersionChanged=function(e){var t=r.props,a=t.options,n=t.onOptionsChange,i=Te({},a,{jsonData:Te({},a.jsonData,{version:e.value})});e.value===T.Flux&&(i.access="proxy",i.basicAuth=!0,i.jsonData.httpMode="POST",delete i.user,delete i.database),n(i)},r.onUpdateInflux2xURL=function(e){var t=r.props,a=t.options;(0,t.onOptionsChange)(Te({},a,{url:e.currentTarget.value,access:"proxy",basicAuth:!0}))},r}var r,a,n;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ne(e,t)}(t,e),r=t,(a=[{key:"renderInflux2x",value:function(){var e=this.props.options,t=e.secureJsonFields,r=e.secureJsonData||{};return N.a.createElement("div",null,N.a.createElement("div",{className:"gf-form-group"},N.a.createElement("div",{className:"width-30 grafana-info-box"},N.a.createElement("h5",null,"Support for flux in Grafana is currently in beta"),N.a.createElement("p",null,"Please report any issues to: ",N.a.createElement("br",null),N.a.createElement("a",{href:"https://github.com/grafana/grafana/issues/new/choose"},"https://github.com/grafana/grafana/issues")))),N.a.createElement("br",null),N.a.createElement("h3",{className:"page-heading"},"Connection"),N.a.createElement("div",{className:"gf-form-inline"},N.a.createElement("div",{className:"gf-form"},N.a.createElement(B.InlineFormLabel,{className:"width-10",tooltip:"This URL needs to be accessible from the grafana backend/server."},"URL"),N.a.createElement("div",{className:"width-20"},N.a.createElement(Re,{className:"width-20",value:e.url||"",placeholder:"http://localhost:9999",onChange:this.onUpdateInflux2xURL})))),N.a.createElement("div",{className:"gf-form-inline"},N.a.createElement("div",{className:"gf-form"},N.a.createElement(B.InlineFormLabel,{className:"width-10"},"Organization"),N.a.createElement("div",{className:"width-10"},N.a.createElement(Re,{className:"width-20",value:e.jsonData.organization||"",onChange:Object(i.onUpdateDatasourceJsonDataOption)(this.props,"organization")})))),N.a.createElement("div",{className:"gf-form-inline"},N.a.createElement("div",{className:"gf-form"},N.a.createElement(Be,{isConfigured:t&&t.token,value:r.token||"",label:"Token",labelWidth:10,inputWidth:20,onReset:this.onResetToken,onChange:Object(i.onUpdateDatasourceSecureJsonDataOption)(this.props,"token")}))),N.a.createElement("div",{className:"gf-form-inline"},N.a.createElement("div",{className:"gf-form"},N.a.createElement(B.InlineFormLabel,{className:"width-10"},"Default Bucket"),N.a.createElement("div",{className:"width-10"},N.a.createElement(Re,{className:"width-20",placeholder:"default bucket",value:e.jsonData.defaultBucket||"",onChange:Object(i.onUpdateDatasourceJsonDataOption)(this.props,"defaultBucket")})))),N.a.createElement("div",{className:"gf-form-inline"},N.a.createElement("div",{className:"gf-form"},N.a.createElement(B.InlineFormLabel,{className:"width-10",tooltip:"A lower limit for the auto group by time interval. Recommended to be set to write frequency, for example 1m if your data is written every minute."},"Min time interval"),N.a.createElement("div",{className:"width-10"},N.a.createElement(Re,{className:"width-10",placeholder:"10s",value:e.jsonData.timeInterval||"",onChange:Object(i.onUpdateDatasourceJsonDataOption)(this.props,"timeInterval")})))))}},{key:"renderInflux1x",value:function(){var e=this.props,t=e.options,r=e.onOptionsChange,a=t.secureJsonFields,n=t.secureJsonData||{};return N.a.createElement("div",null,N.a.createElement(B.DataSourceHttpSettings,{showAccessOptions:!0,dataSourceConfig:t,defaultUrl:"http://localhost:8086",onChange:r}),N.a.createElement("h3",{className:"page-heading"},"InfluxDB Details"),N.a.createElement("div",{className:"gf-form-group"},N.a.createElement("div",{className:"gf-form-inline"},N.a.createElement("div",{className:"gf-form"},N.a.createElement(B.InlineFormLabel,{className:"width-10"},"Database"),N.a.createElement("div",{className:"width-20"},N.a.createElement(Re,{className:"width-20",value:t.database||"",onChange:Object(i.onUpdateDatasourceOption)(this.props,"database")})))),N.a.createElement("div",{className:"gf-form-inline"},N.a.createElement("div",{className:"gf-form"},N.a.createElement(B.InlineFormLabel,{className:"width-10"},"User"),N.a.createElement("div",{className:"width-10"},N.a.createElement(Re,{className:"width-20",value:t.user||"",onChange:Object(i.onUpdateDatasourceOption)(this.props,"user")})))),N.a.createElement("div",{className:"gf-form-inline"},N.a.createElement("div",{className:"gf-form"},N.a.createElement(Be,{isConfigured:a&&a.password,value:n.password||"",label:"Password",labelWidth:10,inputWidth:20,onReset:this.onResetPassword,onChange:Object(i.onUpdateDatasourceSecureJsonDataOption)(this.props,"password")}))),N.a.createElement("div",{className:"gf-form-inline"},N.a.createElement("div",{className:"gf-form"},N.a.createElement(B.InlineFormLabel,{className:"width-10",tooltip:"You can use either GET or POST HTTP method to query your InfluxDB database. The POST method allows you to perform heavy requests (with a lots of WHERE clause) while the GET method will restrict you and return an error if the query is too large."},"HTTP Method"),N.a.createElement(Fe,{className:"width-10",value:qe.find((function(e){return e.value===t.jsonData.httpMode})),options:qe,defaultValue:t.jsonData.httpMode,onChange:Object(i.onUpdateDatasourceJsonDataOptionSelect)(this.props,"httpMode")})))),N.a.createElement("div",{className:"gf-form-group"},N.a.createElement("div",{className:"grafana-info-box"},N.a.createElement("h5",null,"Database Access"),N.a.createElement("p",null,"Setting the database for this datasource does not deny access to other databases. The InfluxDB query syntax allows switching the database in the query. For example:",N.a.createElement("code",null,"SHOW MEASUREMENTS ON _internal")," or ",N.a.createElement("code",null,'SELECT * FROM "_internal".."database" LIMIT 10'),N.a.createElement("br",null),N.a.createElement("br",null),"To support data isolation and security, make sure appropriate permissions are configured in InfluxDB."))),N.a.createElement("div",{className:"gf-form-group"},N.a.createElement("div",{className:"gf-form-inline"},N.a.createElement("div",{className:"gf-form"},N.a.createElement(B.InlineFormLabel,{className:"width-10",tooltip:"A lower limit for the auto group by time interval. Recommended to be set to write frequency, for example 1m if your data is written every minute."},"Min time interval"),N.a.createElement("div",{className:"width-10"},N.a.createElement(Re,{className:"width-10",placeholder:"10s",value:t.jsonData.timeInterval||"",onChange:Object(i.onUpdateDatasourceJsonDataOption)(this.props,"timeInterval")}))))))}},{key:"render",value:function(){var e=this.props.options;return N.a.createElement(N.a.Fragment,null,N.a.createElement("h3",{className:"page-heading"},"Query Language"),N.a.createElement("div",{className:"gf-form-group"},N.a.createElement("div",{className:"gf-form-inline"},N.a.createElement("div",{className:"gf-form"},N.a.createElement(Fe,{className:"width-30",value:e.jsonData.version===T.Flux?Qe[1]:Qe[0],options:Qe,defaultValue:Qe[0],onChange:this.onVersionChanged})))),e.jsonData.version===T.Flux?this.renderInflux2x():this.renderInflux1x())}}])&&Ie(r.prototype,a),n&&Ie(r,n),t}(D.PureComponent);function Me(e){return(Me="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Le(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ue(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Ge(e,t){return!t||"object"!==Me(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Ve(e){return(Ve=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function $e(e,t){return($e=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var ze=function(e){function t(){var e,r;Le(this,t);for(var a=arguments.length,n=new Array(a),i=0;i<a;i++)n[i]=arguments[i];return(r=Ge(this,(e=Ve(t)).call.apply(e,[this].concat(n)))).onRefresh=function(){},r}var r,a,n;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&$e(e,t)}(t,e),r=t,(a=[{key:"render",value:function(){var e=this.props,t=e.query,r=e.datasource,a=e.onChange;return r.isFlux?N.a.createElement(H,{datasource:r,query:{refId:"A",query:t},onRunQuery:this.onRefresh,onChange:function(e){return a(e.query)}}):N.a.createElement("div",{className:"gf-form-inline"},N.a.createElement(B.InlineFormLabel,{width:10},"Query"),N.a.createElement("div",{className:"gf-form-inline gf-form--grow"},N.a.createElement(B.TextArea,{value:t||"",placeholder:"metric name or tags query",rows:1,className:"gf-form-input",onChange:function(e){return a(e.currentTarget.value)}})))}}])&&Ue(r.prototype,a),n&&Ue(r,n),t}(D.PureComponent);r.d(t,"plugin",(function(){return He}));var Ke=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)};Ke.templateUrl="partials/annotations.editor.html";var He=new i.DataSourcePlugin(se).setConfigEditor(Ae).setQueryCtrl(ge).setAnnotationQueryCtrl(Ke).setVariableQueryEditor(ze).setExploreStartPage(xe)}}]);
  //# sourceMappingURL=influxdbPlugin.280e50dbf9c55707f8c1.js.map