EVOLUTION-MANAGER
Edit File: lokiPlugin.4d0490a94b199a11f40c.js
(window.webpackJsonp=window.webpackJsonp||[]).push([[37],{"+2Nz":function(e,t,r){"use strict";r.r(t);var n,a=r("Obii"),i=r("mrSG"),s=r("LvDl"),o=r.n(s),l=r("mEZQ"),c=r("lYZG"),u=r("0/uQ"),m=r("F/XL"),d=r("p0ib"),h=r("9Z1F"),f=r("VnD/"),p=r("67Y/"),v=r("15JJ"),b=r("psW0"),g=r("eqT+"),_=r("m257"),y=r("aCH8"),x=r.n(y),j=r("5kRJ"),O=r("iZOS");!function(e){e.Stream="streams",e.Vector="vector",e.Matrix="matrix"}(n||(n={}));var w=r("kGJw"),T=r.n(w),k=/(?:^|\s){[^{]*}/g;function E(e){var t=(e=e||"").match(k),r=e,n="";return t&&((n=e.replace(k,"").trim())&&-1===n.search(/\|=|\|~|!=|!~/)?r=t[0].trim():n=""),{regexp:n,query:r}}function C(e,t){return((e||"")+" "+(t||"")).trim()}function S(e){var t=E(e);if(t.regexp)return[t.regexp];for(var r=e,n=[];r;){var a=r.search(/\|=|\|~|!=|!~/);if(-1===a)break;var i=r.substr(a,2),s=0===r.substr(a).search(/!=|!~/);if(r=r.substr(a+2),!s){var o=r.search(/\|=|\|~|!=|!~/),l=void 0;-1===o?l=r.trim():(l=r.substr(0,o).trim(),r=r.substr(o));var c=l.match(/^"((?:[^\\"]|\\")*)"$/);if(!c)return null;var u=c[1],m="|~"===i;n.push(m?u:T()(u))}}return n}function L(e,t,r){var n,s,o=e.parsedLabels;!o&&e.labels&&(o=Object(a.parseLabels)(e.labels));var l=new a.ArrayVector([]),c=new a.ArrayVector([]),u=new a.ArrayVector([]),m=new a.ArrayVector([]);try{for(var d=Object(i.__values)(e.entries),h=d.next();!h.done;h=d.next()){var f=h.value,p=f.ts||f.timestamp;l.add(p),c.add(Object(a.dateTime)(p).valueOf()+"000000"),u.add(f.line),m.add(R(p,e.labels,f.line))}}catch(e){n={error:e}}finally{try{h&&!h.done&&(s=d.return)&&s.call(d)}finally{if(n)throw n.error}}return q(l,c,u,m,o,t,r)}function F(e,t,r){var n,s,o=e.stream,l=Object.entries(o).map(function(e){var t=Object(i.__read)(e,2);return t[0]+'="'+t[1]+'"'}).sort().join(""),c=new a.ArrayVector([]),u=new a.ArrayVector([]),m=new a.ArrayVector([]),d=new a.ArrayVector([]);try{for(var h=Object(i.__values)(e.values),f=h.next();!f.done;f=h.next()){var p=Object(i.__read)(f.value,2),v=p[0],b=p[1];c.add(new Date(parseInt(v.substr(0,v.length-6),10)).toISOString()),u.add(v),m.add(b),d.add(R(v,l,b))}}catch(e){n={error:e}}finally{try{f&&!f.done&&(s=h.return)&&s.call(h)}finally{if(n)throw n.error}}return q(c,u,m,d,o,t,r)}function q(e,t,r,n,i,s,o){var l={refId:o,fields:[{name:"ts",type:a.FieldType.time,config:{title:"Time"},values:e},{name:"line",type:a.FieldType.string,config:{},values:r,labels:i},{name:"id",type:a.FieldType.string,config:{},values:n},{name:"tsNs",type:a.FieldType.time,config:{title:"Time ns"},values:t}],length:e.length};if(s){var c=new a.MutableDataFrame(l);return c.reverse(),c}return l}function R(e,t,r){return x()(e+"_"+t+"_"+r)}function N(e,t){return{target:Q(e.metric,t),datapoints:I(e.values,t),tags:e.metric}}function I(e,t){var r,n,a=1e3*t.step,s=[],o=t.start/1e6;try{for(var l=Object(i.__values)(e),c=l.next();!c.done;c=l.next()){var u=Object(i.__read)(c.value,2),m=u[0],d=u[1],h=parseFloat(d);isNaN(h)&&(h=null);for(var f=1e3*m,p=o;p<f;p+=a)s.push([0,p]);o=f+a,s.push([h,f])}}catch(e){r={error:e}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}var v=t.end/1e6;for(p=o;p<=v;p+=a)s.push([0,p]);return s}function D(e,t,r,n){if(!e||0===e.length)return new O.a;var s=new Set(e.reduce(function(e,t){return e.concat(Object.keys(t.metric))},[])),o=Object(i.__spread)(s.values()).sort(),l=new O.a;return l.columns=Object(i.__spread)([{text:"Time",type:a.FieldType.time}],o.map(function(e){return{text:e,filterable:!0}}),[{text:t>1||n?"Value #"+r:"Value",type:a.FieldType.time}]),e.forEach(function(e){var t,r={metric:e.metric,values:e.value?[e.value]:e.values};r.values&&(r.metric?(t=l.rows).push.apply(t,Object(i.__spread)(r.values.map(function(e){var t=Object(i.__read)(e,2),n=t[0],a=t[1];return Object(i.__spread)([1e3*n],o.map(function(e){return r.metric[e]||""}),[parseFloat(a)])}))):l.rows.concat(r.values.map(function(e){var t=Object(i.__read)(e,2),r=t[0],n=t[1];return[1e3*r,parseFloat(n)]})))}),l}function Q(e,t){var r,n,a=void 0===t||o.a.isEmpty(t.legendFormat)?function(e){var t=e.__name__||"";delete e.__name__;var r=Object.entries(e).map(function(e){return e[0]+'="'+e[1]+'"'}).join(",");return t+"{"+r+"}"}(e):(r=j.b.replace(t.legendFormat),n=e,r.replace(/\{\{\s*(.+?)\s*\}\}/g,function(e,t){return n[t]?n[t]:t}));return a||(a=t.query),a}function A(e,t,r,n,a){return void 0===a&&(a=!1),e.map(function(e){var s=F(e,a);return V(s,n),Object(i.__assign)(Object(i.__assign)({},s),{refId:t.refId,meta:{searchWords:S(C(t.expr,t.regexp)),limit:r}})})}function P(e,t,r,n,a){return void 0===a&&(a=!1),0===Object.keys(e).length?[]:function(e){return!e.hasOwnProperty("streams")}(e)?[L(e,!1,t.refId)]:e.streams.map(function(e){var s=L(e,a);return V(s,n),Object(i.__assign)(Object(i.__assign)({},s),{refId:t.refId,meta:{searchWords:S(C(t.query,t.regexp)),limit:r}})})}var V=function(e,t){var r;if(t){var n=null!=(r=t.derivedFields)?r:[];if(n.length){var s=n.reduce(function(e,t){var r={};t.url&&(r.links=[{url:t.url,title:""}]);var n={name:t.name,type:a.FieldType.string,config:r,values:new a.ArrayVector([])};return e[t.name]=n,e},{});new a.DataFrameView(e).forEachRow(function(e){var t,r;try{for(var a=Object(i.__values)(n),o=a.next();!o.done;o=a.next()){var l=o.value,c=e.line.match(l.matcherRegex);s[l.name].values.add(c&&c[1])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}),e.fields=Object(i.__spread)(e.fields,Object.values(s))}}};function M(e,t,r,a){var i={format:r.format,legendFormat:r.legendFormat,start:t.start,end:t.end,step:t.step,query:t.query,responseListLength:a,refId:r.refId,valueWithRefId:r.valueWithRefId};switch(e.data.resultType){case n.Vector:return e.data.result.map(function(e){return N({metric:e.metric,values:[e.value]},i)});case n.Matrix:return e.data.result.map(function(e){return N(e,i)});default:return[]}}var W=r("GQ3c"),B=r("K9Ia"),U=r("FFOo"),z=r("6blF"),K=r("pugT"),$=r("S5bw"),J={url:"",deserializer:function(e){return JSON.parse(e.data)},serializer:function(e){return JSON.stringify(e)}},Z=function(e){function t(t,r){var n=e.call(this)||this;if(t instanceof z.a)n.destination=r,n.source=t;else{var a=n._config=i.__assign({},J);if(n._output=new B.b,"string"==typeof t)a.url=t;else for(var s in t)t.hasOwnProperty(s)&&(a[s]=t[s]);if(!a.WebSocketCtor&&WebSocket)a.WebSocketCtor=WebSocket;else if(!a.WebSocketCtor)throw new Error("no WebSocket constructor can be found");n.destination=new $.a}return n}return i.__extends(t,e),t.prototype.lift=function(e){var r=new t(this._config,this.destination);return r.operator=e,r.source=this,r},t.prototype._resetState=function(){this._socket=null,this.source||(this.destination=new $.a),this._output=new B.b},t.prototype.multiplex=function(e,t,r){var n=this;return new z.a(function(a){try{n.next(e())}catch(e){a.error(e)}var i=n.subscribe(function(e){try{r(e)&&a.next(e)}catch(e){a.error(e)}},function(e){return a.error(e)},function(){return a.complete()});return function(){try{n.next(t())}catch(e){a.error(e)}i.unsubscribe()}})},t.prototype._connectSocket=function(){var e=this,t=this._config,r=t.WebSocketCtor,n=t.protocol,a=t.url,i=t.binaryType,s=this._output,o=null;try{o=n?new r(a,n):new r(a),this._socket=o,i&&(this._socket.binaryType=i)}catch(e){return void s.error(e)}var l=new K.a(function(){e._socket=null,o&&1===o.readyState&&o.close()});o.onopen=function(t){if(!e._socket)return o.close(),void e._resetState();var r=e._config.openObserver;r&&r.next(t);var n=e.destination;e.destination=U.a.create(function(t){if(1===o.readyState)try{var r=e._config.serializer;o.send(r(t))}catch(t){e.destination.error(t)}},function(t){var r=e._config.closingObserver;r&&r.next(void 0),t&&t.code?o.close(t.code,t.reason):s.error(new TypeError("WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }")),e._resetState()},function(){var t=e._config.closingObserver;t&&t.next(void 0),o.close(),e._resetState()}),n&&n instanceof $.a&&l.add(n.subscribe(e.destination))},o.onerror=function(t){e._resetState(),s.error(t)},o.onclose=function(t){e._resetState();var r=e._config.closeObserver;r&&r.next(t),t.wasClean?s.complete():s.error(t)},o.onmessage=function(t){try{var r=e._config.deserializer;s.next(r(t))}catch(e){s.error(e)}}},t.prototype._subscribe=function(e){var t=this,r=this.source;return r?r.subscribe(e):(this._socket||this._connectSocket(),this._output.subscribe(e),e.add(function(){var e=t._socket;0===t._output.observers.length&&(e&&1===e.readyState&&e.close(),t._resetState())}),e)},t.prototype.unsubscribe=function(){var t=this._socket;t&&1===t.readyState&&t.close(),this._resetState(),e.prototype.unsubscribe.call(this)},t}(B.a);function G(e){return new Z(e)}var H=r("2WpN"),Y=function(){function e(){this.streams={}}return e.prototype.getLegacyStream=function(e){var t=this,r=this.streams[e.url];if(r)return r;var n=new a.CircularDataFrame({capacity:e.size});return n.addField({name:"ts",type:a.FieldType.time,config:{title:"Time"}}),n.addField({name:"line",type:a.FieldType.string}).labels=Object(a.parseLabels)(e.query),n.addField({name:"labels",type:a.FieldType.other}),n.addField({name:"id",type:a.FieldType.string}),r=G(e.url).pipe(Object(H.a)(function(){delete t.streams[e.url]}),Object(p.a)(function(e){return function(e,t){var r,n,s,o,l,c,u=e.streams;if(u&&u.length){var m={};try{for(var d=Object(i.__values)(t.fields),h=d.next();!h.done;h=d.next()){var f=h.value;if(f.type===a.FieldType.string){f.labels&&(m=f.labels);break}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(n=d.return)&&n.call(d)}finally{if(r)throw r.error}}try{for(var p=Object(i.__values)(u),v=p.next();!v.done;v=p.next()){var b=v.value,g=Object(a.parseLabels)(b.labels),_=Object(a.findUniqueLabels)(g,m);try{for(var y=(l=void 0,Object(i.__values)(b.entries)),x=y.next();!x.done;x=y.next()){var j=x.value,O=j.ts||j.timestamp;t.values.ts.add(O),t.values.line.add(j.line),t.values.labels.add(_),t.values.id.add(R(O,b.labels,j.line))}}catch(e){l={error:e}}finally{try{x&&!x.done&&(c=y.return)&&c.call(y)}finally{if(l)throw l.error}}}}catch(e){s={error:e}}finally{try{v&&!v.done&&(o=p.return)&&o.call(p)}finally{if(s)throw s.error}}}}(e,n),[n]})),this.streams[e.url]=r,r},e.prototype.getStream=function(e){var t=this,r=this.streams[e.url];if(r)return r;var n=new a.CircularDataFrame({capacity:e.size});return n.addField({name:"ts",type:a.FieldType.time,config:{title:"Time"}}),n.addField({name:"tsNs",type:a.FieldType.time,config:{title:"Time ns"}}),n.addField({name:"line",type:a.FieldType.string}).labels=Object(a.parseLabels)(e.query),n.addField({name:"labels",type:a.FieldType.other}),n.addField({name:"id",type:a.FieldType.string}),r=G(e.url).pipe(Object(H.a)(function(){delete t.streams[e.url]}),Object(p.a)(function(e){return function(e,t){var r,n,s,o,l,c,u=e.streams;if(u&&u.length){var m={};try{for(var d=Object(i.__values)(t.fields),h=d.next();!h.done;h=d.next()){var f=h.value;if(f.type===a.FieldType.string){f.labels&&(m=f.labels);break}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(n=d.return)&&n.call(d)}finally{if(r)throw r.error}}try{for(var p=Object(i.__values)(u),v=p.next();!v.done;v=p.next()){var b=v.value,g=Object(a.findUniqueLabels)(b.stream,m),_=Object.entries(b.stream).map(function(e){var t=Object(i.__read)(e,2);return t[0]+'="'+t[1]+'"'}).sort().join("");try{for(var y=(l=void 0,Object(i.__values)(b.values)),x=y.next();!x.done;x=y.next()){var j=Object(i.__read)(x.value,2),O=j[0],w=j[1];t.values.ts.add(new Date(parseInt(O.substr(0,O.length-6),10)).toISOString()),t.values.tsNs.add(O),t.values.line.add(w),t.values.labels.add(g),t.values.id.add(R(O,_,w))}}catch(e){l={error:e}}finally{try{x&&!x.done&&(c=y.return)&&c.call(y)}finally{if(l)throw l.error}}}}catch(e){s={error:e}}finally{try{v&&!v.done&&(o=p.return)&&o.call(p)}finally{if(s)throw s.error}}}}(e,n),[n]})),this.streams[e.url]=r,r},e}(),X=r("ceQ3"),ee=Object(i.__spread)([{label:"sum",insertText:"sum",documentation:"Calculate sum over dimensions"},{label:"min",insertText:"min",documentation:"Select minimum over dimensions"},{label:"max",insertText:"max",documentation:"Select maximum over dimensions"},{label:"avg",insertText:"avg",documentation:"Calculate the average over dimensions"},{label:"stddev",insertText:"stddev",documentation:"Calculate population standard deviation over dimensions"},{label:"stdvar",insertText:"stdvar",documentation:"Calculate population standard variance over dimensions"},{label:"count",insertText:"count",documentation:"Count number of elements in the vector"},{label:"bottomk",insertText:"bottomk",documentation:"Smallest k elements by sample value"},{label:"topk",insertText:"topk",documentation:"Largest k elements by sample value"}],[{insertText:"count_over_time",label:"count_over_time",detail:"count_over_time(range-vector)",documentation:"The count of all values in the specified interval."},{insertText:"rate",label:"rate",detail:"rate(v range-vector)",documentation:"Calculates the per-second average rate of increase of the time series in the range vector. Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for. Also, the calculation extrapolates to the ends of the time range, allowing for missed scrapes or imperfect alignment of scrape cycles with the range's time period."}]),te={comment:{pattern:/#.*/},"context-aggregation":{pattern:/((without|by)\s*)\([^)]*\)/,lookbehind:!0,inside:{"label-key":{pattern:/[^(),\s][^,)]*[^),\s]*/,alias:"attr-name"},punctuation:/[()]/}},"context-labels":{pattern:/\{[^}]*(?=})/,greedy:!0,inside:{comment:{pattern:/#.*/},"label-key":{pattern:/[a-z_]\w*(?=\s*(=|!=|=~|!~))/,alias:"attr-name",greedy:!0},"label-value":{pattern:/"(?:\\.|[^\\"])*"/,greedy:!0,alias:"attr-value"},punctuation:/[{]/}},function:new RegExp("\\b(?:"+ee.map(function(e){return e.label}).join("|")+")(?=\\s*\\()","i"),"context-range":[{pattern:/\[[^\]]*(?=\])/,inside:{"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}},{pattern:/(offset\s+)\w+/,lookbehind:!0,inside:{"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}}],number:/\b-?\d+((\.\d*)?([eE][+-]?\d+)?)?\b/,operator:new RegExp("/&&?|\\|?\\||!=?|<(?:=>?|<|>)?|>[>=]?","i"),punctuation:/[{}()`,.]/},re=r("itod"),ne=["job","namespace"],ae=864e5,ie=function(e){return{label:e}},se=function(e){return{start:1e6*e.from,end:1e6*e.to}};var oe=function(e){function t(t,r){var n=e.call(this)||this;return n.cleanText=function(e){return e.replace(/[{}[\]="(),!~+\-*/^%]/g,"").trim()},n.request=function(e,t){return n.datasource.metadataRequest(e,t)},n.start=function(){return n.startTask||(n.startTask=n.fetchLogLabels(n.initialRange).then(function(){return n.started=!0,[]})),n.startTask},n.getBeginningCompletionItems=function(e){return{suggestions:Object(i.__spread)(n.getEmptyCompletionItems(e).suggestions,n.getTermCompletionItems().suggestions)}},n.getTermCompletionItems=function(){var e=[];return e.push({prefixMatch:!0,label:"Functions",items:ee.map(function(e){return Object(i.__assign)(Object(i.__assign)({},e),{kind:"function"})})}),{suggestions:e}},n.datasource=t,n.labelKeys={},n.labelValues={},Object.assign(n,r),n}return Object(i.__extends)(t,e),t.prototype.getSyntax=function(){return te},t.prototype.getLabelKeys=function(){return this.labelKeys["{}"]},t.prototype.getLabelValues=function(e){return Object(i.__awaiter)(this,void 0,Promise,function(){return Object(i.__generator)(this,function(t){switch(t.label){case 0:return[4,this.fetchLabelValues(e,this.initialRange)];case 1:return t.sent(),[2,this.labelValues["{}"][e]]}})})},t.prototype.provideCompletionItems=function(e,t){return Object(i.__awaiter)(this,void 0,Promise,function(){var r,n,a,s,o,l,c,u,m,d,h,f,p,v;return Object(i.__generator)(this,function(i){switch(i.label){case 0:return r=e.wrapperClasses,n=e.value,a=e.prefix,s=e.text,o=0===n.document.text.length,l=n.document.getTextsAtRange(n.selection),c=1===l.size?l.first().getText():null,u=c?c[n.selection.anchor.offset]:null,m=r.length>3,d=a&&!m,h=!u||")"===u,f=a&&!s.match(/^['"~=\]})\s]+$/)&&h,p=/[+\-*/^%]/,v=s.match(p),r.includes("context-range")?[2,this.getRangeCompletionItems()]:[3,1];case 1:return r.includes("context-labels")?[4,this.getLabelCompletionItems(e,t)]:[3,3];case 2:return[2,i.sent()];case 3:if(o)return[2,this.getEmptyCompletionItems(t)];if(d&&h&&!v)return[2,this.getBeginningCompletionItems(t)];if(d&&f)return[2,this.getTermCompletionItems()];i.label=4;case 4:return[2,{suggestions:[]}]}})})},t.prototype.getEmptyCompletionItems=function(e){var t,r=null===(t=e)||void 0===t?void 0:t.history,n=[];if(r&&r.length){var s=o.a.chain(r).map(function(e){return e.query.expr}).filter().uniq().take(10).map(ie).map(function(e){return function(e,t){var r=Date.now()-ae,n=t.filter(function(t){return t.ts>r&&t.query.expr===e.label}),s="Queried "+n.length+" times in the last 24h.",o=n[0];return o&&(s=s+" Last queried "+Object(a.dateTime)(o.ts).fromNow()+"."),Object(i.__assign)(Object(i.__assign)({},e),{documentation:s})}(e,r)}).value();n.push({prefixMatch:!0,skipSort:!0,label:"History",items:s})}return{suggestions:n}},t.prototype.getRangeCompletionItems=function(){return{context:"context-range",suggestions:[{label:"Range vector",items:Object(i.__spread)(re.b)}]}},t.prototype.getLabelCompletionItems=function(e,t){var r=e.text,n=e.wrapperClasses,a=e.labelKey,s=e.value,l=t.absoluteRange;return Object(i.__awaiter)(this,void 0,Promise,function(){var e,t,c,u,m,d,h,f,p,v;return Object(i.__generator)(this,function(i){switch(i.label){case 0:t=[],c=s.anchorBlock.getText(),u=s.selection.anchor.offset,m="{}";try{d=Object(X.c)(c,u)}catch(e){}return h=d?d.labelKeys:[],r&&r.match(/^!?=~?/)||n.includes("attr-value")?a&&this.labelValues[m]?(f=this.labelValues[m][a])?[3,2]:[4,this.fetchLabelValues(a,l)]:[3,3]:[3,4];case 1:i.sent(),f=this.labelValues[m][a],i.label=2;case 2:e="context-label-values",t.push({label:'Label values for "'+a+'"',items:f.map(ie)}),i.label=3;case 3:return[3,5];case 4:(p=this.labelKeys[m]||ne)&&(v=o.a.difference(p,h)).length&&(e="context-labels",t.push({label:"Labels",items:v.map(ie)})),i.label=5;case 5:return[2,{context:e,suggestions:t}]}})})},t.prototype.importQueries=function(e,t){return Object(i.__awaiter)(this,void 0,Promise,function(){var r=this;return Object(i.__generator)(this,function(n){return"prometheus"===t?[2,Promise.all(e.map(function(e){return Object(i.__awaiter)(r,void 0,void 0,function(){var t,r;return Object(i.__generator)(this,function(n){switch(n.label){case 0:return[4,this.importPrometheusQuery(e.expr)];case 1:return t=n.sent(),r=Object(i.__rest)(e,[]),[2,Object(i.__assign)(Object(i.__assign)({},r),{expr:t})]}})})}))]:[2,e.map(function(e){return{refId:e.refId,expr:""}})]})})},t.prototype.importPrometheusQuery=function(e){return Object(i.__awaiter)(this,void 0,Promise,function(){var t,r,n,a,s,o,l;return Object(i.__generator)(this,function(i){switch(i.label){case 0:return e&&(t=e.match(X.f))?(r=t[0],n={},r.replace(X.b,function(e,t,r,a){return n[t]={value:a,operator:r},""}),[4,this.start()]):[2,""];case 1:if(i.sent(),a=this.labelKeys["{}"],s={},a&&a.length)for(o in n)a&&a.includes(o)&&(s[o]=n[o]);else s=n;return l=Object.keys(s).sort(),[2,["{",l.map(function(e){return""+e+s[e].operator+s[e].value}).join(","),"}"].join("")]}})})},t.prototype.fetchLogLabels=function(e){return Object(i.__awaiter)(this,void 0,Promise,function(){var t,r,n,a,s,o,l;return Object(i.__generator)(this,function(c){switch(c.label){case 0:t="/api/prom/label",c.label=1;case 1:return c.trys.push([1,3,,4]),this.logLabelFetchTs=Date.now(),r=e?se(e):{},[4,this.request(t,r)];case 2:return n=c.sent(),a=n.data.data.slice().sort(),this.labelKeys=Object(i.__assign)(Object(i.__assign)({},this.labelKeys),((o={})["{}"]=a,o)),this.labelValues=((l={})["{}"]={},l),this.logLabelOptions=a.map(function(e){return{label:e,value:e,isLeaf:!1}}),[3,4];case 3:return s=c.sent(),console.error(s),[3,4];case 4:return[2,[]]}})})},t.prototype.refreshLogLabels=function(e,t){return Object(i.__awaiter)(this,void 0,void 0,function(){return Object(i.__generator)(this,function(r){switch(r.label){case 0:return this.labelKeys&&Date.now()-this.logLabelFetchTs>3e4||t?[4,this.fetchLogLabels(e)]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})},t.prototype.fetchLabelValues=function(e,t){return Object(i.__awaiter)(this,void 0,void 0,function(){var r,n,a,s,o,l,c,u,m;return Object(i.__generator)(this,function(d){switch(d.label){case 0:r="/api/prom/label/"+e+"/values",d.label=1;case 1:return d.trys.push([1,3,,4]),n=t?se(t):{},[4,this.request(r,n)];case 2:return a=d.sent(),s=a.data.data.slice().sort(),this.logLabelOptions=this.logLabelOptions.map(function(t){return t.value===e?Object(i.__assign)(Object(i.__assign)({},t),{children:s.map(function(e){return{label:e,value:e}})}):t}),o=this.labelValues["{}"],l=Object(i.__assign)(Object(i.__assign)({},o),((u={})[e]=s,u)),this.labelValues=Object(i.__assign)(Object(i.__assign)({},this.labelValues),((m={})["{}"]=l,m)),[3,4];case 3:return c=d.sent(),console.error(c),[3,4];case 4:return[2]}})})},t}(a.LanguageProvider),le=1e3,ce="/api/prom/query",ue="/loki/api/v1/query_range",me="/loki/api/v1/query",de={direction:"BACKWARD",limit:le,regexp:"",query:""};function he(e){return Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&")}function fe(e){return"string"==typeof e?e.replace(/'/g,"\\\\'"):e}function pe(e){return"string"==typeof e?fe(e.replace(/\\/g,"\\\\\\\\").replace(/[$^*{}\[\]+?.()|]/g,"\\\\$&")):e}var ve=function(e){function t(t,r,s){var o=e.call(this,t)||this;o.instanceSettings=t,o.backendSrv=r,o.templateSrv=s,o.streams=new Y,o.runLegacyQuery=function(e,t){if(e.liveStreaming)return o.runLiveQuery(e,t);var r=t.range?{start:o.getTime(t.range.from,!1),end:o.getTime(t.range.to,!0)}:{},n=Object(i.__assign)(Object(i.__assign)(Object(i.__assign)(Object(i.__assign)({},de),E(e.expr)),r),{limit:Math.min(t.maxDataPoints||1/0,o.maxLines),refId:e.refId});return o._request(ce,n).pipe(Object(h.a)(function(t){return o.throwUnless(t,t.cancelled,e)}),Object(f.a)(function(e){return!e.cancelled}),Object(p.a)(function(r){return{data:P(r.data,n,o.maxLines,o.instanceSettings.jsonData,t.reverse),key:e.refId+"_log"}}))},o.runInstantQuery=function(e,t,r){var a=o.getTime(t.range.to,!0),i={query:E(e.expr).query,time:""+(a+(1e9-a%1e9)),limit:Math.min(t.maxDataPoints||1/0,o.maxLines)};return o._request(me,i).pipe(Object(h.a)(function(t){return o.throwUnless(t,t.cancelled,e)}),Object(f.a)(function(e){return!e.cancelled}),Object(p.a)(function(t){if(t.data.data.resultType===n.Stream)throw new Error("Metrics mode does not support logs. Use an aggregation or switch to Logs mode.");return{data:[D(t.data.data.result,r,e.refId,!0)],key:e.refId+"_instant"}}))},o.runRangeQueryWithFallback=function(e,t,r){if(void 0===r&&(r=1),e.liveStreaming)return o.runLiveQuery(e,t);var a=o.createRangeQuery(e,t);return o._request(ue,a).pipe(Object(h.a)(function(t){return o.throwUnless(t,t.cancelled||404===t.status,e)}),Object(f.a)(function(e){return!e.cancelled}),Object(v.a)(function(s){return Object(l.a)(function(){return 404===s.status},Object(c.a)(function(){return o.runLegacyQuery(e,t)}),Object(c.a)(function(){return function(e,t,r,a,s,o,l){switch(void 0===l&&(l=!1),e.data.resultType){case n.Stream:return Object(m.a)({data:A(e.data.result,t,s,o,l),key:t.refId+"_log"});case n.Vector:case n.Matrix:return Object(m.a)({data:M(e,r,Object(i.__assign)(Object(i.__assign)({},t),{format:"time_series"}),a),key:t.refId});default:throw new Error('Unknown result type "'+e.data.resultType+'".')}}(s.data,e,a,r,o.maxLines,o.instanceSettings.jsonData,t.reverse)}))}))},o.runLiveQuery=function(e,t){var r=o.createLiveTarget(e,t);return Object(u.a)(o.getVersion()).pipe(Object(b.a)(function(n){return Object(l.a)(function(){return"v1"===n},Object(c.a)(function(){return o.streams.getStream(r)}),Object(c.a)(function(){var r=o.createLegacyLiveTarget(e,t);return o.streams.getLegacyStream(r)}))}),Object(p.a)(function(e){return{data:e,key:"loki-"+r.refId,state:a.LoadingState.Streaming}}))},o.getLogRowContext=function(e,t){var r=o.prepareLogRowContextQueryTarget(e,t&&t.limit||10,t&&t.direction||"BACKWARD"),n=t&&"FORWARD"===t.direction;return o._request(ue,r).pipe(Object(h.a)(function(e){if(404===e.status)return Object(m.a)(e);throw{message:"Error during context query. Please check JS console logs.",status:e.status,statusText:e.statusText}}),Object(v.a)(function(e){return Object(l.a)(function(){return 404===e.status},Object(c.a)(function(){return o._request(ce,r).pipe(Object(h.a)(function(e){throw{message:"Error during context query. Please check JS console logs.",status:e.status,statusText:e.statusText}}),Object(p.a)(function(e){return{data:e.data?e.data.streams.map(function(e){return L(e,n)}):[]}}))}),Object(c.a)(function(){return Object(m.a)({data:e.data?e.data.data.result.map(function(e){return F(e,n)}):[]})}))})).toPromise()},o.prepareLogRowContextQueryTarget=function(e,t,r){var n=Object.keys(e.labels).map(function(t){return t+'="'+e.labels[t]+'"'}).join(","),s={limit:t,query:"{"+n+"}",expr:"{"+n+"}",direction:r},o=new a.FieldCache(e.dataFrame).getFieldByName("tsNs").values.get(e.rowIndex);return"BACKWARD"===r?Object(i.__assign)(Object(i.__assign)({},s),{start:e.timeEpochMs-72e5+"000000",end:o,direction:r}):Object(i.__assign)(Object(i.__assign)({},s),{start:o,end:e.timeEpochMs+72e5+"000000"})},o.throwUnless=function(e,t,r){if(t)return Object(m.a)(e);throw o.processError(e,r)},o.processError=function(e,t){var r={message:e&&e.statusText||"Unknown error during query transaction. Please check JS console logs.",refId:t.refId};return e.data?"string"==typeof e.data?r.message=e.data:e.data.error&&(r.message=Object(_.u)(e.data.error)):e.message?r.message=e.message:"string"==typeof e&&(r.message=e),r.status=e.status,r.statusText=e.statusText,r},o.languageProvider=new oe(o);var d=t.jsonData||{};return o.maxLines=parseInt(d.maxLines,10)||le,o}return t.$inject=["instanceSettings","backendSrv","templateSrv"],Object(i.__extends)(t,e),t.prototype.getVersion=function(){var e=this;return this.version?Promise.resolve(this.version):this._request(ue).toPromise().then(function(){return e.version="v1",e.version}).catch(function(t){return e.version=404!==t.status?"v1":"v0",e.version})},t.prototype._request=function(e,t,r){var n=this.instanceSettings.url,a=t?he(t):"",s=""+n+e+(a.length?"?"+a:""),o=Object(i.__assign)(Object(i.__assign)({},r),{url:s});return Object(u.a)(this.backendSrv.datasourceRequest(o))},t.prototype.query=function(e){var t=this,r=[],n=e.targets.filter(function(e){return e.expr&&!e.hide}).map(function(r){return Object(i.__assign)(Object(i.__assign)({},r),{expr:t.templateSrv.replace(r.expr,e.scopedVars,t.interpolateQueryExpr)})});return e.exploreMode===W.ExploreMode.Metrics?n.forEach(function(a){return r.push(t.runInstantQuery(a,e,n.length),t.runRangeQueryWithFallback(a,e,n.length))}):n.forEach(function(a){return r.push(t.runRangeQueryWithFallback(a,e,n.length).pipe(Object(p.a)(function(t){if(e.exploreMode===W.ExploreMode.Logs&&t.data.find(function(e){return e.hasOwnProperty("datapoints")}))throw new Error("Logs mode does not support queries that return time series data. Please perform a logs query or switch to Metrics mode.");return t})))}),Object(s.isEmpty)(r)?Object(m.a)({data:[],state:a.LoadingState.Done}):d.a.apply(void 0,Object(i.__spread)(r))},t.prototype.createRangeQuery=function(e,t){var r=E(e.expr).query,n={};if(t.range){var a=this.getTime(t.range.from,!1),s=this.getTime(t.range.to,!0),o=Math.ceil((s-a)/1e6),l=Math.ceil(this.adjustInterval(t.intervalMs||1e3,o)/1e3),c={start:a-a%1e9,end:s+(1e9-s%1e9)};n={start:c.start,end:c.end,step:l}}return Object(i.__assign)(Object(i.__assign)(Object(i.__assign)({},de),n),{query:r,limit:Math.min(t.maxDataPoints||1/0,this.maxLines)})},t.prototype.createLegacyLiveTarget=function(e,t){var r=E(e.expr),n=r.query,a=r.regexp,i=this.instanceSettings.url,s=he({query:n});return{query:n,regexp:a,url:Object(_.f)(i+"/api/prom/tail?"+s),refId:e.refId,size:Math.min(t.maxDataPoints||1/0,this.maxLines)}},t.prototype.createLiveTarget=function(e,t){var r=E(e.expr),n=r.query,a=r.regexp,i=this.instanceSettings.url,s=he({query:n});return{query:n,regexp:a,url:Object(_.f)(i+"/loki/api/v1/tail?"+s),refId:e.refId,size:Math.min(t.maxDataPoints||1/0,this.maxLines)}},t.prototype.interpolateVariablesInQueries=function(e,t){var r=this,n=e;return e&&e.length&&(n=e.map(function(e){return Object(i.__assign)(Object(i.__assign)({},e),{datasource:r.name,expr:r.templateSrv.replace(e.expr,t,r.interpolateQueryExpr)})})),n},t.prototype.importQueries=function(e,t){return Object(i.__awaiter)(this,void 0,Promise,function(){return Object(i.__generator)(this,function(r){return[2,this.languageProvider.importQueries(e,t.id)]})})},t.prototype.metadataRequest=function(e,t){return Object(i.__awaiter)(this,void 0,void 0,function(){var r;return Object(i.__generator)(this,function(n){switch(n.label){case 0:return[4,this._request(e,t,{silent:!0}).toPromise()];case 1:return[2,{data:{data:(r=n.sent()).data.data||r.data.values||[]}}]}})})},t.prototype.metricFindQuery=function(e){return Object(i.__awaiter)(this,void 0,void 0,function(){var t;return Object(i.__generator)(this,function(r){switch(r.label){case 0:return e?(t=this.templateSrv.replace(e,{},this.interpolateQueryExpr),[4,this.processMetricFindQuery(t)]):[2,Promise.resolve([])];case 1:return[2,r.sent()]}})})},t.prototype.processMetricFindQuery=function(e){return Object(i.__awaiter)(this,void 0,void 0,function(){var t,r,n;return Object(i.__generator)(this,function(a){switch(a.label){case 0:return t=/^label_names\(\)\s*$/,r=/^label_values\((?:(.+),\s*)?([a-zA-Z_][a-zA-Z0-9_]*)\)\s*$/,e.match(t)?[4,this.labelNamesQuery()]:[3,2];case 1:return[2,a.sent()];case 2:return(n=e.match(r))?[4,this.labelValuesQuery(n[2])]:[3,4];case 3:return[2,a.sent()];case 4:return[2,Promise.resolve([])]}})})},t.prototype.labelNamesQuery=function(){return Object(i.__awaiter)(this,void 0,void 0,function(){var e;return Object(i.__generator)(this,function(t){switch(t.label){case 0:return[4,this.getVersion()];case 1:return e="v0"===t.sent()?"/api/prom/label":"/loki/api/v1/label",[4,this.metadataRequest(e)];case 2:return[2,t.sent().data.data.map(function(e){return{text:e}})]}})})},t.prototype.labelValuesQuery=function(e){return Object(i.__awaiter)(this,void 0,void 0,function(){var t;return Object(i.__generator)(this,function(r){switch(r.label){case 0:return[4,this.getVersion()];case 1:return t="v0"===r.sent()?"/api/prom/label/"+e+"/values":"/loki/api/v1/label/"+e+"/values",[4,this.metadataRequest(t)];case 2:return[2,r.sent().data.data.map(function(e){return{text:e}})]}})})},t.prototype.interpolateQueryExpr=function(e,t){return t.multi||t.includeAll?"string"==typeof e?pe(e):Object(s.map)(e,pe).join("|"):fe(e)},t.prototype.modifyQuery=function(e,t){var r=E(e.expr||""),n=r.query;switch(t.type){case"ADD_FILTER":n=(Object(g.a)(n,t.key,t.value)+" "+Object(g.c)(n)).trim();break;case"ADD_FILTER_OUT":n=(Object(g.a)(n,t.key,t.value,"!=")+" "+Object(g.c)(n)).trim()}var a=C(n,r.regexp);return Object(i.__assign)(Object(i.__assign)({},e),{expr:a})},t.prototype.getHighlighterExpression=function(e){return S(e.expr)},t.prototype.getTime=function(e,t){return"string"==typeof e&&(e=a.dateMath.parse(e,t)),Math.ceil(1e6*e.valueOf())},t.prototype.testDatasource=function(){var e=this,t=Date.now()-6e5+"000000";return this._request("/loki/api/v1/label",{start:t}).pipe(Object(h.a)(function(e){if(404===e.status)return Object(m.a)(e);throw e}),Object(v.a)(function(r){return Object(l.a)(function(){return 404===r.status},Object(c.a)(function(){return e._request("/api/prom/label",{start:t})}),Object(c.a)(function(){return Object(m.a)(r)}))}),Object(p.a)(function(e){var t,r,n,a;return((null===(r=null===(t=e)||void 0===t?void 0:t.data)||void 0===r?void 0:r.data)||(null===(a=null===(n=e)||void 0===n?void 0:n.data)||void 0===a?void 0:a.values)||[]).length>0?{status:"success",message:"Data source connected and labels found."}:{status:"error",message:"Data source connected, but no labels received. Verify that Loki and Promtail is configured properly."}}),Object(h.a)(function(e){var t="Loki: ";return e.statusText?t+=e.statusText:t+="Cannot connect to Loki",e.status&&(t+=". "+e.status),e.data&&e.data.message?t+=". "+e.data.message:e.data&&(t+=". "+e.data),Object(m.a)({status:"error",message:t})})).toPromise()},t.prototype.annotationQuery=function(e){return Object(i.__awaiter)(this,void 0,Promise,function(){var t,r,n,s,o,l,c,u,m,d;return Object(i.__generator)(this,function(h){switch(h.label){case 0:return e.annotation.expr?(t=this.templateSrv.replace(e.annotation.expr,{},this.interpolateQueryExpr),r={refId:"annotation-"+e.annotation.name,expr:t},[4,this.runRangeQueryWithFallback(r,e).toPromise()]):[2,[]];case 1:n=h.sent().data,s=[],o=function(e){var t,r,n=[];try{for(var o=(t=void 0,Object(i.__values)(e.fields)),l=o.next();!l.done;l=o.next()){var c=l.value;c.labels&&n.push.apply(n,Object.values(c.labels))}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}new a.DataFrameView(e).forEachRow(function(e){s.push({time:new Date(e.ts).valueOf(),text:e.line,tags:n})})};try{for(l=Object(i.__values)(n),c=l.next();!c.done;c=l.next())u=c.value,o(u)}catch(e){m={error:e}}finally{try{c&&!c.done&&(d=l.return)&&d.call(l)}finally{if(m)throw m.error}}return[2,s]}})})},t.prototype.adjustInterval=function(e,t){return 0!==e&&t/e>11e3&&(e=Math.ceil(t/11e3)),Math.max(e,1e3)},t}(a.DataSourceApi);var be,ge,_e,ye,xe,je,Oe=r("q1tI"),we=r.n(Oe),Te=['{job="default/prometheus"}'],ke=["job","app","k8s_app"],Ee=5,Ce=[{title:"Count over time",expression:'count_over_time({job="mysql"}[5m])',label:"This query counts all the log lines within the last five minutes for the MySQL job."},{title:"Rate",expression:'rate(({job="mysql"} |= "error" != "timeout")[10s])',label:"This query gets the per-second rate of all non-timeout errors within the last ten seconds for the MySQL job."},{title:"Aggregate, count, and group",expression:'sum(count_over_time({job="mysql"}[5m])) by (level)',label:"Get the count of logs during the last five minutes, grouping by level."}],Se=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={userExamples:Te},t.checkUserLabels=function(){return Object(i.__awaiter)(t,void 0,void 0,function(){var e,t,r,n,a;return Object(i.__generator)(this,function(i){switch(i.label){case 0:return(e=this.props.datasource.languageProvider).started?(t=e.getLabelKeys()||[],(r=ke.find(function(e){return t.includes(e)}))?[4,e.getLabelValues(r)]:[3,2]):[3,3];case 1:n=i.sent(),a=Object(s.shuffle)(n).slice(0,Ee).map(function(e){return"{"+r+'="'+e+'"}'}),this.setState({userExamples:a}),i.label=2;case 2:return[3,4];case 3:this.scheduleUserLabelChecking(),i.label=4;case 4:return[2]}})})},t}return Object(i.__extends)(t,e),t.prototype.componentDidMount=function(){this.scheduleUserLabelChecking()},t.prototype.componentWillUnmount=function(){clearTimeout(this.userLabelTimer)},t.prototype.scheduleUserLabelChecking=function(){this.userLabelTimer=setTimeout(this.checkUserLabels,1e3)},t.prototype.renderExpression=function(e){var t=this.props.onClickExample;return we.a.createElement("div",{className:"cheat-sheet-item__example",key:e,onClick:function(r){return t({refId:"A",expr:e})}},we.a.createElement("code",null,e))},t.prototype.renderLogsCheatSheet=function(){var e=this,t=this.state.userExamples;return we.a.createElement(we.a.Fragment,null,we.a.createElement("h2",null,"Loki Cheat Sheet"),we.a.createElement("div",{className:"cheat-sheet-item"},we.a.createElement("div",{className:"cheat-sheet-item__title"},"See your logs"),we.a.createElement("div",{className:"cheat-sheet-item__label"},"Start by selecting a log stream from the Log labels selector."),we.a.createElement("div",{className:"cheat-sheet-item__label"},"Alternatively, you can write a stream selector into the query field:"),this.renderExpression('{job="default/prometheus"}'),t!==Te&&t.length>0?we.a.createElement("div",null,we.a.createElement("div",{className:"cheat-sheet-item__label"},"Here are some example streams from your logs:"),t.map(function(t){return e.renderExpression(t)})):null),we.a.createElement("div",{className:"cheat-sheet-item"},we.a.createElement("div",{className:"cheat-sheet-item__title"},"Combine stream selectors"),this.renderExpression('{app="cassandra",namespace="prod"}'),we.a.createElement("div",{className:"cheat-sheet-item__label"},"Returns all log lines from streams that have both labels.")),we.a.createElement("div",{className:"cheat-sheet-item"},we.a.createElement("div",{className:"cheat-sheet-item__title"},"Filtering for search terms."),this.renderExpression('{app="cassandra"} |~ "(duration|latency)s*(=|is|of)s*[d.]+"'),this.renderExpression('{app="cassandra"} |= "exact match"'),this.renderExpression('{app="cassandra"} != "do not match"'),we.a.createElement("div",{className:"cheat-sheet-item__label"},we.a.createElement("a",{href:"https://github.com/grafana/loki/blob/master/docs/logql.md#filter-expression",target:"logql"},"LogQL")," ","supports exact and regular expression filters.")))},t.prototype.renderMetricsCheatSheet=function(){var e=this;return we.a.createElement("div",null,we.a.createElement("h2",null,"LogQL Cheat Sheet"),Ce.map(function(t){return we.a.createElement("div",{className:"cheat-sheet-item",key:t.expression},we.a.createElement("div",{className:"cheat-sheet-item__title"},t.title),e.renderExpression(t.expression),we.a.createElement("div",{className:"cheat-sheet-item__label"},t.label))}))},t.prototype.render=function(){return this.props.exploreMode===W.ExploreMode.Logs?this.renderLogsCheatSheet():this.renderMetricsCheatSheet()},t}(Oe.PureComponent),Le=r("KwPh"),Fe=r("uz0r"),qe=function(e){var t=e.datasource,r=Object(i.__rest)(e,["datasource"]),n=Object(Fe.a)(t.languageProvider,r.absoluteRange),a=n.isSyntaxReady,s=n.setActiveOption,o=n.refreshLabels,l=Object(i.__rest)(n,["isSyntaxReady","setActiveOption","refreshLabels"]);return we.a.createElement(Le.a,Object(i.__assign)({datasource:t,syntaxLoaded:a,onLoadOptions:s,onLabelsRefresh:o},l,r))},Re=qe,Ne=Object(Oe.memo)(function(e){var t,r=e.query,n=e.data,a=e.datasource,s=e.onChange,o=e.onRunQuery;if(n&&n.request){var l=n.request.range;t={from:l.from.valueOf(),to:l.to.valueOf()}}else t={from:Date.now()-1e4,to:Date.now()};var c=Object(Fe.a)(a.languageProvider,t),u=c.isSyntaxReady,m=c.setActiveOption,d=c.refreshLabels,h=Object(i.__rest)(c,["isSyntaxReady","setActiveOption","refreshLabels"]);return we.a.createElement("div",null,we.a.createElement(qe,Object(i.__assign)({datasource:a,query:r,onChange:s,onRunQuery:o,history:[],data:n,onLoadOptions:m,onLabelsRefresh:d,syntaxLoaded:u,absoluteRange:t},h)))}),Ie=function(){function e(){this.annotation.target=this.annotation.target||{},this.onQueryChange=this.onQueryChange.bind(this)}return e.prototype.onQueryChange=function(e){this.annotation.expr=e},e.templateUrl="partials/annotations.editor.html",e}(),De=r("kDLi"),Qe=function(e){var t=e.value,r=e.onChange;return we.a.createElement(De.FormField,{label:"Maximum lines",labelWidth:11,inputWidth:20,inputEl:we.a.createElement("input",{type:"number",className:"gf-form-input width-8 gf-form-input--has-help-icon",value:t,onChange:function(e){return r(e.currentTarget.value)},spellCheck:!1,placeholder:"1000"}),tooltip:we.a.createElement(we.a.Fragment,null,"Loki queries must contain a limit of the maximum number of lines returned (default: 1000). Increase this limit to have a bigger result set for ad-hoc analysis. Decrease this limit if your browser becomes sluggish when displaying the log results.")})},Ae=r("PAeb"),Pe=Object(De.stylesFactory)(function(){return{firstRow:Object(Ae.css)(be||(be=Object(i.__makeTemplateObject)(["\n display: flex;\n align-items: baseline;\n "],["\n display: flex;\n align-items: baseline;\n "]))),nameField:Object(Ae.css)(ge||(ge=Object(i.__makeTemplateObject)(["\n flex: 2;\n "],["\n flex: 2;\n "]))),regexField:Object(Ae.css)(_e||(_e=Object(i.__makeTemplateObject)(["\n flex: 3;\n "],["\n flex: 3;\n "])))}}),Ve=function(e){var t=e.value,r=e.onChange,n=e.onDelete,a=e.suggestions,s=e.className,o=Pe(),l=function(e){return function(n){var a;r(Object(i.__assign)(Object(i.__assign)({},t),((a={})[e]=n.currentTarget.value,a)))}};return we.a.createElement("div",{className:s},we.a.createElement("div",{className:o.firstRow},we.a.createElement(De.FormField,{className:o.nameField,labelWidth:5,inputWidth:null,label:"Name",type:"text",value:t.name,onChange:l("name")}),we.a.createElement(De.FormField,{className:o.regexField,inputWidth:null,label:"Regex",type:"text",value:t.matcherRegex,onChange:l("matcherRegex"),tooltip:"Use to parse and capture some part of the log message. You can use the captured groups in the template."}),we.a.createElement(De.Button,{variant:"inverse",title:"Remove field",icon:"fa fa-times",onClick:function(e){e.preventDefault(),n()},className:Object(Ae.css)(ye||(ye=Object(i.__makeTemplateObject)(["\n margin-left: 8px;\n "],["\n margin-left: 8px;\n "])))})),we.a.createElement(De.FormField,{label:"URL",labelWidth:5,inputEl:we.a.createElement(De.DataLinkInput,{placeholder:"http://example.com/${__value.raw}",value:t.url||"",onChange:function(e){return r(Object(i.__assign)(Object(i.__assign)({},t),{url:e}))},suggestions:a}),className:Object(Ae.css)(xe||(xe=Object(i.__makeTemplateObject)(["\n width: 100%;\n "],["\n width: 100%;\n "])))}))},Me=r("TSYQ"),We=r.n(Me),Be=r("MAcC"),Ue=function(e){var t=e.derivedFields,r=e.className,n=Object(i.__read)(Object(Oe.useState)(""),2),s=n[0],o=n[1],l=[];return s&&t&&(l=function(e,t){return e.filter(function(e){return e.name&&e.matcherRegex}).map(function(e){try{var r=t.match(e.matcherRegex),n=r&&r[1],i=void 0;return e.url&&n&&(i=Object(Be.b)({name:"",type:a.FieldType.string,values:new a.ArrayVector([n]),config:{links:[{title:"",url:e.url}]}},0)[0]),{name:e.name,value:n||"<no match>",href:i&&i.href}}catch(t){return{name:e.name,error:t}}})}(t,s)),we.a.createElement("div",{className:r},we.a.createElement(De.FormField,{labelWidth:12,label:"Debug log message",inputEl:we.a.createElement("textarea",{placeholder:"Paste an example log line here to test the regular expressions of your derived fields",className:We()("gf-form-input gf-form-textarea",Object(Ae.css)(je||(je=Object(i.__makeTemplateObject)(["\n width: 100%;\n "],["\n width: 100%;\n "])))),value:s,onChange:function(e){return o(e.currentTarget.value)}})}),!!l.length&&we.a.createElement(ze,{fields:l}))},ze=function(e){var t=e.fields;return we.a.createElement("table",{className:"filter-table"},we.a.createElement("thead",null,we.a.createElement("tr",null,we.a.createElement("th",null,"Name"),we.a.createElement("th",null,"Value"),we.a.createElement("th",null,"Url"))),we.a.createElement("tbody",null,t.map(function(e){var t=e.value;return e.error?t=e.error.message:e.href&&(t=we.a.createElement("a",{href:e.href},t)),we.a.createElement("tr",{key:e.name+"="+e.value},we.a.createElement("td",null,e.name),we.a.createElement("td",null,t),we.a.createElement("td",null,e.href?we.a.createElement("a",{href:e.href},e.href):""))})))};var Ke,$e,Je,Ze,Ge=Object(De.stylesFactory)(function(e){return{infoText:Object(Ae.css)(Ke||(Ke=Object(i.__makeTemplateObject)(["\n padding-bottom: ",";\n color: ",";\n "],["\n padding-bottom: ",";\n color: ",";\n "])),e.spacing.md,e.colors.textWeak),derivedField:Object(Ae.css)($e||($e=Object(i.__makeTemplateObject)(["\n margin-bottom: ",";\n "],["\n margin-bottom: ",";\n "])),e.spacing.sm)}}),He=function(e){var t=e.value,r=e.onChange,n=Object(De.useTheme)(),a=Ge(n),s=Object(i.__read)(Object(Oe.useState)(!1),2),o=s[0],l=s[1];return we.a.createElement(we.a.Fragment,null,we.a.createElement("h3",{className:"page-heading"},"Derived fields"),we.a.createElement("div",{className:a.infoText},"Derived fields can be used to extract new fields from the log message and create link from it's value."),we.a.createElement("div",{className:"gf-form-group"},t&&t.map(function(e,n){return we.a.createElement(Ve,{className:a.derivedField,key:n,value:e,onChange:function(e){var a=Object(i.__spread)(t);a.splice(n,1,e),r(a)},onDelete:function(){var e=Object(i.__spread)(t);e.splice(n,1),r(e)},suggestions:[{value:De.DataLinkBuiltInVars.valueRaw,label:"Raw value",documentation:"Exact string captured by the regular expression",origin:De.VariableOrigin.Value}]})}),we.a.createElement("div",null,we.a.createElement(De.Button,{variant:"inverse",className:Object(Ae.css)(Je||(Je=Object(i.__makeTemplateObject)(["\n margin-right: 10px;\n "],["\n margin-right: 10px;\n "]))),icon:"fa fa-plus",onClick:function(e){e.preventDefault();var n=Object(i.__spread)(t||[],[{name:"",matcherRegex:""}]);r(n)}},"Add"),t&&t.length>0&&we.a.createElement(De.Button,{variant:"inverse",onClick:function(){return l(!o)}},o?"Hide example log message":"Show example log message"))),o&&we.a.createElement("div",{className:"gf-form-group"},we.a.createElement(Ue,{className:Object(Ae.css)(Ze||(Ze=Object(i.__makeTemplateObject)(["\n margin-bottom: 10px;\n "],["\n margin-bottom: 10px;\n "]))),derivedFields:t})))},Ye=function(e){return function(t,r){var n;return Object(i.__assign)(Object(i.__assign)({},t),{jsonData:Object(i.__assign)(Object(i.__assign)({},t.jsonData),(n={},n[e]=r,n))})}},Xe=Ye("maxLines"),et=Ye("derivedFields");r.d(t,"plugin",function(){return tt});var tt=new a.DataSourcePlugin(ve).setQueryEditor(Ne).setConfigEditor(function(e){var t=e.options,r=e.onOptionsChange;return we.a.createElement(we.a.Fragment,null,we.a.createElement(De.DataSourceHttpSettings,{defaultUrl:"http://localhost:3100",dataSourceConfig:t,showAccessOptions:!1,onChange:r}),we.a.createElement("div",{className:"gf-form-group"},we.a.createElement("div",{className:"gf-form-inline"},we.a.createElement("div",{className:"gf-form"},we.a.createElement(Qe,{value:t.jsonData.maxLines,onChange:function(e){return r(Xe(t,e))}})))),we.a.createElement(He,{value:t.jsonData.derivedFields,onChange:function(e){return r(et(t,e))}}))}).setExploreQueryField(Re).setExploreStartPage(Se).setAnnotationQueryCtrl(Ie)},ANhw:function(e,t){var r,n;r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],r=0,n=0;r<e.length;r++,n+=8)t[n>>>5]|=e[r]<<24-n%32;return t},wordsToBytes:function(e){for(var t=[],r=0;r<32*e.length;r+=8)t.push(e[r>>>5]>>>24-r%32&255);return t},bytesToHex:function(e){for(var t=[],r=0;r<e.length;r++)t.push((e[r]>>>4).toString(16)),t.push((15&e[r]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],r=0;r<e.length;r+=2)t.push(parseInt(e.substr(r,2),16));return t},bytesToBase64:function(e){for(var t=[],n=0;n<e.length;n+=3)for(var a=e[n]<<16|e[n+1]<<8|e[n+2],i=0;i<4;i++)8*n+6*i<=8*e.length?t.push(r.charAt(a>>>6*(3-i)&63)):t.push("=");return t.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var t=[],n=0,a=0;n<e.length;a=++n%4)0!=a&&t.push((r.indexOf(e.charAt(n-1))&Math.pow(2,-2*a+8)-1)<<2*a|r.indexOf(e.charAt(n))>>>6-2*a);return t}},e.exports=n},BEtg:function(e,t){function r(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)} /*! * Determine if an object is a Buffer * * @author Feross Aboukhadijeh <https://feross.org> * @license MIT */ e.exports=function(e){return null!=e&&(r(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&r(e.slice(0,0))}(e)||!!e._isBuffer)}},aCH8:function(e,t,r){var n,a,i,s,o;n=r("ANhw"),a=r("mmNF").utf8,i=r("BEtg"),s=r("mmNF").bin,(o=function(e,t){e.constructor==String?e=t&&"binary"===t.encoding?s.stringToBytes(e):a.stringToBytes(e):i(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||(e=e.toString());for(var r=n.bytesToWords(e),l=8*e.length,c=1732584193,u=-271733879,m=-1732584194,d=271733878,h=0;h<r.length;h++)r[h]=16711935&(r[h]<<8|r[h]>>>24)|4278255360&(r[h]<<24|r[h]>>>8);r[l>>>5]|=128<<l%32,r[14+(l+64>>>9<<4)]=l;var f=o._ff,p=o._gg,v=o._hh,b=o._ii;for(h=0;h<r.length;h+=16){var g=c,_=u,y=m,x=d;c=f(c,u,m,d,r[h+0],7,-680876936),d=f(d,c,u,m,r[h+1],12,-389564586),m=f(m,d,c,u,r[h+2],17,606105819),u=f(u,m,d,c,r[h+3],22,-1044525330),c=f(c,u,m,d,r[h+4],7,-176418897),d=f(d,c,u,m,r[h+5],12,1200080426),m=f(m,d,c,u,r[h+6],17,-1473231341),u=f(u,m,d,c,r[h+7],22,-45705983),c=f(c,u,m,d,r[h+8],7,1770035416),d=f(d,c,u,m,r[h+9],12,-1958414417),m=f(m,d,c,u,r[h+10],17,-42063),u=f(u,m,d,c,r[h+11],22,-1990404162),c=f(c,u,m,d,r[h+12],7,1804603682),d=f(d,c,u,m,r[h+13],12,-40341101),m=f(m,d,c,u,r[h+14],17,-1502002290),c=p(c,u=f(u,m,d,c,r[h+15],22,1236535329),m,d,r[h+1],5,-165796510),d=p(d,c,u,m,r[h+6],9,-1069501632),m=p(m,d,c,u,r[h+11],14,643717713),u=p(u,m,d,c,r[h+0],20,-373897302),c=p(c,u,m,d,r[h+5],5,-701558691),d=p(d,c,u,m,r[h+10],9,38016083),m=p(m,d,c,u,r[h+15],14,-660478335),u=p(u,m,d,c,r[h+4],20,-405537848),c=p(c,u,m,d,r[h+9],5,568446438),d=p(d,c,u,m,r[h+14],9,-1019803690),m=p(m,d,c,u,r[h+3],14,-187363961),u=p(u,m,d,c,r[h+8],20,1163531501),c=p(c,u,m,d,r[h+13],5,-1444681467),d=p(d,c,u,m,r[h+2],9,-51403784),m=p(m,d,c,u,r[h+7],14,1735328473),c=v(c,u=p(u,m,d,c,r[h+12],20,-1926607734),m,d,r[h+5],4,-378558),d=v(d,c,u,m,r[h+8],11,-2022574463),m=v(m,d,c,u,r[h+11],16,1839030562),u=v(u,m,d,c,r[h+14],23,-35309556),c=v(c,u,m,d,r[h+1],4,-1530992060),d=v(d,c,u,m,r[h+4],11,1272893353),m=v(m,d,c,u,r[h+7],16,-155497632),u=v(u,m,d,c,r[h+10],23,-1094730640),c=v(c,u,m,d,r[h+13],4,681279174),d=v(d,c,u,m,r[h+0],11,-358537222),m=v(m,d,c,u,r[h+3],16,-722521979),u=v(u,m,d,c,r[h+6],23,76029189),c=v(c,u,m,d,r[h+9],4,-640364487),d=v(d,c,u,m,r[h+12],11,-421815835),m=v(m,d,c,u,r[h+15],16,530742520),c=b(c,u=v(u,m,d,c,r[h+2],23,-995338651),m,d,r[h+0],6,-198630844),d=b(d,c,u,m,r[h+7],10,1126891415),m=b(m,d,c,u,r[h+14],15,-1416354905),u=b(u,m,d,c,r[h+5],21,-57434055),c=b(c,u,m,d,r[h+12],6,1700485571),d=b(d,c,u,m,r[h+3],10,-1894986606),m=b(m,d,c,u,r[h+10],15,-1051523),u=b(u,m,d,c,r[h+1],21,-2054922799),c=b(c,u,m,d,r[h+8],6,1873313359),d=b(d,c,u,m,r[h+15],10,-30611744),m=b(m,d,c,u,r[h+6],15,-1560198380),u=b(u,m,d,c,r[h+13],21,1309151649),c=b(c,u,m,d,r[h+4],6,-145523070),d=b(d,c,u,m,r[h+11],10,-1120210379),m=b(m,d,c,u,r[h+2],15,718787259),u=b(u,m,d,c,r[h+9],21,-343485551),c=c+g>>>0,u=u+_>>>0,m=m+y>>>0,d=d+x>>>0}return n.endian([c,u,m,d])})._ff=function(e,t,r,n,a,i,s){var o=e+(t&r|~t&n)+(a>>>0)+s;return(o<<i|o>>>32-i)+t},o._gg=function(e,t,r,n,a,i,s){var o=e+(t&n|r&~n)+(a>>>0)+s;return(o<<i|o>>>32-i)+t},o._hh=function(e,t,r,n,a,i,s){var o=e+(t^r^n)+(a>>>0)+s;return(o<<i|o>>>32-i)+t},o._ii=function(e,t,r,n,a,i,s){var o=e+(r^(t|~n))+(a>>>0)+s;return(o<<i|o>>>32-i)+t},o._blocksize=16,o._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);var r=n.wordsToBytes(o(e,t));return t&&t.asBytes?r:t&&t.asString?s.bytesToString(r):n.bytesToHex(r)}},ceQ3:function(e,t,r){"use strict";r.d(t,"d",function(){return a}),r.d(t,"e",function(){return i}),r.d(t,"f",function(){return s}),r.d(t,"b",function(){return o}),r.d(t,"c",function(){return l}),r.d(t,"a",function(){return c});var n=r("mrSG"),a=function(e){for(var t=[],r=new RegExp("_bucket($|:)"),n=0;n<e.length;n++){var a=e[n];r.test(a)&&-1===t.indexOf(a)&&t.push(a)}return{values:{__name__:t}}};function i(e,t){void 0===t&&(t=!1);var r={};return e.forEach(function(e){var a=e.__name__,i=Object(n.__rest)(e,["__name__"]);t&&(r.__name__=r.__name__||[],r.__name__.includes(a)||r.__name__.push(a)),Object.keys(i).forEach(function(e){r[e]||(r[e]=[]),r[e].includes(i[e])||r[e].push(i[e])})}),{values:r,keys:Object.keys(r)}}var s=/\{[^}]*?\}/,o=/\b(\w+)(!?=~?)("[^"\n]*?")/g;function l(e,t){if(void 0===t&&(t=1),!e.match(s)){if(e.match(/^[A-Za-z:][\w:]*$/))return{selector:'{__name__="'+e+'"}',labelKeys:["__name__"]};throw new Error("Query must contain a selector: "+e)}var r=e.slice(0,t),n=r.lastIndexOf("{"),a=r.lastIndexOf("}");if(-1===n)throw new Error("Not inside selector, missing open brace: "+r);if(a>-1&&a>n)throw new Error("Not inside selector, previous selector already closed: "+r);var i=e.slice(t),l=i.indexOf("}")+t,c=i.indexOf("{"),u=c+t;if(-1===l)throw new Error("Not inside selector, missing closing brace in suffix: "+i);if(c>-1&&u<l)throw new Error("Not inside selector, next selector opens before this one closed: "+i);var m=e.slice(n,l),d={};m.replace(o,function(r,n,a,i){var s=e.indexOf(r),o=s+n.length+a.length+1,l=s+n.length+a.length+i.length-1;return(t<o||t>l)&&(d[n]={value:i,operator:a}),""});var h=e.slice(0,n).match(/[A-Za-z:][\w:]*$/);h&&(d.__name__={value:'"'+h[0]+'"',operator:"="});var f=Object.keys(d).sort(),p=f.map(function(e){return""+e+d[e].operator+d[e].value}).join(",");return{labelKeys:f,selector:["{",p,"}"].join("")}}function c(e,t){var r=Object.keys(t),n=new RegExp("(\\s|^)("+r.join("|")+")(\\s|$|\\(|\\[|\\{)","ig");return e.replace(n,function(e,r,n,a){return""+r+t[n]+a})}},"eqT+":function(e,t,r){"use strict";r.d(t,"a",function(){return u}),r.d(t,"c",function(){return m});var n=r("LvDl"),a=r.n(n),i="by|without|on|ignoring|group_left|group_right|bool|or|and|unless",s=[i,"count|count_values|min|max|avg|sum|stddev|stdvar|bottomk|topk|quantile","true|false|null|__name__|job","abs|absent|ceil|changes|clamp_max|clamp_min|count_scalar|day_of_month|day_of_week|days_in_month|delta|deriv","drop_common_labels|exp|floor|histogram_quantile|holt_winters|hour|idelta|increase|irate|label_replace|ln|log2","log10|minute|month|predict_linear|rate|resets|round|scalar|sort|sort_desc|sqrt|time|vector|year|avg_over_time","min_over_time|max_over_time|sum_over_time|count_over_time|quantile_over_time|stddev_over_time|stdvar_over_time"].join("|").split("|"),o=/([A-Za-z:][\w:]*)\b(?![\(\]{=!",])/g,l=/{([^{]*)}/g;var c=/(\w+)\s*(=|!=|=~|!~)\s*("[^"]*")/g;function u(e,t,r,n){var i=[];if(e)for(var s=c.exec(e);s;)i.push({key:s[1],operator:s[2],value:s[3]}),s=c.exec(e);var o=n||"=";return i.push({key:t,operator:o,value:'"'+r+'"'}),"{"+a.a.chain(i).uniqWith(a.a.isEqual).compact().sortBy("key").map(function(e){return""+e.key+e.operator+e.value}).value().join(",")+"}"}function m(e){return e.replace(/\{(.*?)\}/g,"").replace(/^ /,"")}t.b=function(e,t,r,n){if(!t||!r)throw new Error("Need label to add to query.");var a;e=e.replace(o,function(t,r,n){var o,l,c,u,m,d,h=(l=n,c="{",u="}",m=(o=e).slice(l).indexOf(c),(d=o.slice(l).indexOf(u))>-1&&(-1===m||m>d)),f=a&&i.split("|").indexOf(a)>-1,p=r.endsWith(":");return a=r,h||p||f||-1!==s.indexOf(r)?r:r+"{}"});for(var c=l.exec(e),m=[],d=0,h="";c;){var f=e.slice(d,c.index),p=u(c[1],t,r,n);d=c.index+c[1].length+2,h=e.slice(c.index+c[0].length),m.push(f,p),c=l.exec(e)}return m.push(h),m.join("")}},itod:function(e,t,r){"use strict";r.d(t,"b",function(){return a}),r.d(t,"a",function(){return i});var n=r("mrSG"),a=[{label:"$__interval",sortText:"$__interval"},{label:"1m",sortText:"00:01:00"},{label:"5m",sortText:"00:05:00"},{label:"10m",sortText:"00:10:00"},{label:"30m",sortText:"00:30:00"},{label:"1h",sortText:"01:00:00"},{label:"1d",sortText:"24:00:00"}],i=Object(n.__spread)([{label:"sum",insertText:"sum",documentation:"Calculate sum over dimensions"},{label:"min",insertText:"min",documentation:"Select minimum over dimensions"},{label:"max",insertText:"max",documentation:"Select maximum over dimensions"},{label:"avg",insertText:"avg",documentation:"Calculate the average over dimensions"},{label:"stddev",insertText:"stddev",documentation:"Calculate population standard deviation over dimensions"},{label:"stdvar",insertText:"stdvar",documentation:"Calculate population standard variance over dimensions"},{label:"count",insertText:"count",documentation:"Count number of elements in the vector"},{label:"count_values",insertText:"count_values",documentation:"Count number of elements with the same value"},{label:"bottomk",insertText:"bottomk",documentation:"Smallest k elements by sample value"},{label:"topk",insertText:"topk",documentation:"Largest k elements by sample value"},{label:"quantile",insertText:"quantile",documentation:"Calculate φ-quantile (0 ≤ φ ≤ 1) over dimensions"}],[{insertText:"abs",label:"abs",detail:"abs(v instant-vector)",documentation:"Returns the input vector with all sample values converted to their absolute value."},{insertText:"absent",label:"absent",detail:"absent(v instant-vector)",documentation:"Returns an empty vector if the vector passed to it has any elements and a 1-element vector with the value 1 if the vector passed to it has no elements. This is useful for alerting on when no time series exist for a given metric name and label combination."},{insertText:"ceil",label:"ceil",detail:"ceil(v instant-vector)",documentation:"Rounds the sample values of all elements in `v` up to the nearest integer."},{insertText:"changes",label:"changes",detail:"changes(v range-vector)",documentation:"For each input time series, `changes(v range-vector)` returns the number of times its value has changed within the provided time range as an instant vector."},{insertText:"clamp_max",label:"clamp_max",detail:"clamp_max(v instant-vector, max scalar)",documentation:"Clamps the sample values of all elements in `v` to have an upper limit of `max`."},{insertText:"clamp_min",label:"clamp_min",detail:"clamp_min(v instant-vector, min scalar)",documentation:"Clamps the sample values of all elements in `v` to have a lower limit of `min`."},{insertText:"count_scalar",label:"count_scalar",detail:"count_scalar(v instant-vector)",documentation:"Returns the number of elements in a time series vector as a scalar. This is in contrast to the `count()` aggregation operator, which always returns a vector (an empty one if the input vector is empty) and allows grouping by labels via a `by` clause."},{insertText:"day_of_month",label:"day_of_month",detail:"day_of_month(v=vector(time()) instant-vector)",documentation:"Returns the day of the month for each of the given times in UTC. Returned values are from 1 to 31."},{insertText:"day_of_week",label:"day_of_week",detail:"day_of_week(v=vector(time()) instant-vector)",documentation:"Returns the day of the week for each of the given times in UTC. Returned values are from 0 to 6, where 0 means Sunday etc."},{insertText:"days_in_month",label:"days_in_month",detail:"days_in_month(v=vector(time()) instant-vector)",documentation:"Returns number of days in the month for each of the given times in UTC. Returned values are from 28 to 31."},{insertText:"delta",label:"delta",detail:"delta(v range-vector)",documentation:"Calculates the difference between the first and last value of each time series element in a range vector `v`, returning an instant vector with the given deltas and equivalent labels. The delta is extrapolated to cover the full time range as specified in the range vector selector, so that it is possible to get a non-integer result even if the sample values are all integers."},{insertText:"deriv",label:"deriv",detail:"deriv(v range-vector)",documentation:"Calculates the per-second derivative of the time series in a range vector `v`, using simple linear regression."},{insertText:"drop_common_labels",label:"drop_common_labels",detail:"drop_common_labels(instant-vector)",documentation:"Drops all labels that have the same name and value across all series in the input vector."},{insertText:"exp",label:"exp",detail:"exp(v instant-vector)",documentation:"Calculates the exponential function for all elements in `v`.\nSpecial cases are:\n* `Exp(+Inf) = +Inf` \n* `Exp(NaN) = NaN`"},{insertText:"floor",label:"floor",detail:"floor(v instant-vector)",documentation:"Rounds the sample values of all elements in `v` down to the nearest integer."},{insertText:"histogram_quantile",label:"histogram_quantile",detail:"histogram_quantile(φ float, b instant-vector)",documentation:"Calculates the φ-quantile (0 ≤ φ ≤ 1) from the buckets `b` of a histogram. The samples in `b` are the counts of observations in each bucket. Each sample must have a label `le` where the label value denotes the inclusive upper bound of the bucket. (Samples without such a label are silently ignored.) The histogram metric type automatically provides time series with the `_bucket` suffix and the appropriate labels."},{insertText:"holt_winters",label:"holt_winters",detail:"holt_winters(v range-vector, sf scalar, tf scalar)",documentation:"Produces a smoothed value for time series based on the range in `v`. The lower the smoothing factor `sf`, the more importance is given to old data. The higher the trend factor `tf`, the more trends in the data is considered. Both `sf` and `tf` must be between 0 and 1."},{insertText:"hour",label:"hour",detail:"hour(v=vector(time()) instant-vector)",documentation:"Returns the hour of the day for each of the given times in UTC. Returned values are from 0 to 23."},{insertText:"idelta",label:"idelta",detail:"idelta(v range-vector)",documentation:"Calculates the difference between the last two samples in the range vector `v`, returning an instant vector with the given deltas and equivalent labels."},{insertText:"increase",label:"increase",detail:"increase(v range-vector)",documentation:"Calculates the increase in the time series in the range vector. Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for. The increase is extrapolated to cover the full time range as specified in the range vector selector, so that it is possible to get a non-integer result even if a counter increases only by integer increments."},{insertText:"irate",label:"irate",detail:"irate(v range-vector)",documentation:"Calculates the per-second instant rate of increase of the time series in the range vector. This is based on the last two data points. Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for."},{insertText:"label_replace",label:"label_replace",detail:"label_replace(v instant-vector, dst_label string, replacement string, src_label string, regex string)",documentation:"For each timeseries in `v`, `label_replace(v instant-vector, dst_label string, replacement string, src_label string, regex string)` matches the regular expression `regex` against the label `src_label`. If it matches, then the timeseries is returned with the label `dst_label` replaced by the expansion of `replacement`. `$1` is replaced with the first matching subgroup, `$2` with the second etc. If the regular expression doesn't match then the timeseries is returned unchanged."},{insertText:"ln",label:"ln",detail:"ln(v instant-vector)",documentation:"calculates the natural logarithm for all elements in `v`.\nSpecial cases are:\n * `ln(+Inf) = +Inf`\n * `ln(0) = -Inf`\n * `ln(x < 0) = NaN`\n * `ln(NaN) = NaN`"},{insertText:"log2",label:"log2",detail:"log2(v instant-vector)",documentation:"Calculates the binary logarithm for all elements in `v`. The special cases are equivalent to those in `ln`."},{insertText:"log10",label:"log10",detail:"log10(v instant-vector)",documentation:"Calculates the decimal logarithm for all elements in `v`. The special cases are equivalent to those in `ln`."},{insertText:"minute",label:"minute",detail:"minute(v=vector(time()) instant-vector)",documentation:"Returns the minute of the hour for each of the given times in UTC. Returned values are from 0 to 59."},{insertText:"month",label:"month",detail:"month(v=vector(time()) instant-vector)",documentation:"Returns the month of the year for each of the given times in UTC. Returned values are from 1 to 12, where 1 means January etc."},{insertText:"predict_linear",label:"predict_linear",detail:"predict_linear(v range-vector, t scalar)",documentation:"Predicts the value of time series `t` seconds from now, based on the range vector `v`, using simple linear regression."},{insertText:"rate",label:"rate",detail:"rate(v range-vector)",documentation:"Calculates the per-second average rate of increase of the time series in the range vector. Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for. Also, the calculation extrapolates to the ends of the time range, allowing for missed scrapes or imperfect alignment of scrape cycles with the range's time period."},{insertText:"resets",label:"resets",detail:"resets(v range-vector)",documentation:"For each input time series, `resets(v range-vector)` returns the number of counter resets within the provided time range as an instant vector. Any decrease in the value between two consecutive samples is interpreted as a counter reset."},{insertText:"round",label:"round",detail:"round(v instant-vector, to_nearest=1 scalar)",documentation:"Rounds the sample values of all elements in `v` to the nearest integer. Ties are resolved by rounding up. The optional `to_nearest` argument allows specifying the nearest multiple to which the sample values should be rounded. This multiple may also be a fraction."},{insertText:"scalar",label:"scalar",detail:"scalar(v instant-vector)",documentation:"Given a single-element input vector, `scalar(v instant-vector)` returns the sample value of that single element as a scalar. If the input vector does not have exactly one element, `scalar` will return `NaN`."},{insertText:"sort",label:"sort",detail:"sort(v instant-vector)",documentation:"Returns vector elements sorted by their sample values, in ascending order."},{insertText:"sort_desc",label:"sort_desc",detail:"sort_desc(v instant-vector)",documentation:"Returns vector elements sorted by their sample values, in descending order."},{insertText:"sqrt",label:"sqrt",detail:"sqrt(v instant-vector)",documentation:"Calculates the square root of all elements in `v`."},{insertText:"time",label:"time",detail:"time()",documentation:"Returns the number of seconds since January 1, 1970 UTC. Note that this does not actually return the current time, but the time at which the expression is to be evaluated."},{insertText:"vector",label:"vector",detail:"vector(s scalar)",documentation:"Returns the scalar `s` as a vector with no labels."},{insertText:"year",label:"year",detail:"year(v=vector(time()) instant-vector)",documentation:"Returns the year for each of the given times in UTC."},{insertText:"avg_over_time",label:"avg_over_time",detail:"avg_over_time(range-vector)",documentation:"The average value of all points in the specified interval."},{insertText:"min_over_time",label:"min_over_time",detail:"min_over_time(range-vector)",documentation:"The minimum value of all points in the specified interval."},{insertText:"max_over_time",label:"max_over_time",detail:"max_over_time(range-vector)",documentation:"The maximum value of all points in the specified interval."},{insertText:"sum_over_time",label:"sum_over_time",detail:"sum_over_time(range-vector)",documentation:"The sum of all values in the specified interval."},{insertText:"count_over_time",label:"count_over_time",detail:"count_over_time(range-vector)",documentation:"The count of all values in the specified interval."},{insertText:"quantile_over_time",label:"quantile_over_time",detail:"quantile_over_time(scalar, range-vector)",documentation:"The φ-quantile (0 ≤ φ ≤ 1) of the values in the specified interval."},{insertText:"stddev_over_time",label:"stddev_over_time",detail:"stddev_over_time(range-vector)",documentation:"The population standard deviation of the values in the specified interval."},{insertText:"stdvar_over_time",label:"stdvar_over_time",detail:"stdvar_over_time(range-vector)",documentation:"The population standard variance of the values in the specified interval."}]),s={comment:{pattern:/#.*/},"context-aggregation":{pattern:/((by|without)\s*)\([^)]*\)/,lookbehind:!0,inside:{"label-key":{pattern:/[^(),\s][^,)]*[^),\s]*/,alias:"attr-name"},punctuation:/[()]/}},"context-labels":{pattern:/\{[^}]*(?=})/,greedy:!0,inside:{comment:{pattern:/#.*/},"label-key":{pattern:/[a-z_]\w*(?=\s*(=|!=|=~|!~))/,alias:"attr-name",greedy:!0},"label-value":{pattern:/"(?:\\.|[^\\"])*"/,greedy:!0,alias:"attr-value"},punctuation:/[{]/}},function:new RegExp("\\b(?:"+i.map(function(e){return e.label}).join("|")+")(?=\\s*\\()","i"),"context-range":[{pattern:/\[[^\]]*(?=])/,inside:{"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}},{pattern:/(offset\s+)\w+/,lookbehind:!0,inside:{"range-duration":{pattern:/\b\d+[smhdwy]\b/i,alias:"number"}}}],number:/\b-?\d+((\.\d*)?([eE][+-]?\d+)?)?\b/,operator:new RegExp("/[-+*/=%^~]|&&?|\\|?\\||!=?|<(?:=>?|<|>)?|>[>=]?|\\b(?:"+["by","group_left","group_right","ignoring","on","offset","without"].join("|")+")\\b","i"),punctuation:/[{};()`,.]/};t.c=s},kGJw:function(e,t,r){var n=r("dt0z"),a=/[\\^$.*+?()[\]{}|]/g,i=RegExp(a.source);e.exports=function(e){return(e=n(e))&&i.test(e)?e.replace(a,"\\$&"):e}},mmNF:function(e,t){var r={utf8:{stringToBytes:function(e){return r.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(r.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],r=0;r<e.length;r++)t.push(255&e.charCodeAt(r));return t},bytesToString:function(e){for(var t=[],r=0;r<e.length;r++)t.push(String.fromCharCode(e[r]));return t.join("")}}};e.exports=r}}]); //# sourceMappingURL=lokiPlugin.4d0490a94b199a11f40c.js.map