5704.e5218f14257b58a119f3.js.map 37 KB

1
  1. {"version":3,"file":"5704.e5218f14257b58a119f3.js","mappings":"kKAIA,MAgDaA,EAAiC,CAC5C,CACEC,MAAO,OACPC,WAAY,OACZC,cAAe,uFAEjB,CACEF,MAAO,SACPC,WAAY,YACZC,cAAe,wFACfC,MAAO,GAET,CACEH,MAAO,SACPC,WAAY,SACZC,cAAe,yFAEjB,CACEF,MAAO,UACPC,WAAY,UACZC,cAAe,0FAEjB,CACEF,MAAO,SACPC,WAAY,SACZG,OAAQ,oBACRF,cACE,0LAIOG,EAAmC,CAC9C,CACEL,MAAO,SACPC,WAAY,SACZG,OAAQ,oBACRF,cACE,uGAEJ,CACEF,MAAO,eACPC,WAAY,eACZC,cACE,2GAEJ,CACEF,MAAO,cACPC,WAAY,cACZC,cACE,oHAuFOI,EAAY,CAvLvB,CACEN,MAAO,MACPC,WAAY,MACZC,cAAe,iCAEjB,CACEF,MAAO,MACPC,WAAY,MACZC,cAAe,kCAEjB,CACEF,MAAO,MACPC,WAAY,MACZC,cAAe,kCAEjB,CACEF,MAAO,MACPC,WAAY,MACZC,cAAe,yCAEjB,CACEF,MAAO,SACPC,WAAY,SACZC,cAAe,2DAEjB,CACEF,MAAO,SACPC,WAAY,SACZC,cAAe,0DAEjB,CACEF,MAAO,QACPC,WAAY,QACZC,cAAe,0CAEjB,CACEF,MAAO,UACPC,WAAY,UACZC,cAAe,uCAEjB,CACEF,MAAO,OACPC,WAAY,OACZC,cAAe,sCA0DjB,CACED,WAAY,gBACZD,MAAO,gBACPI,OAAQ,8BACRF,cAAe,qFAEjB,CACED,WAAY,gBACZD,MAAO,gBACPI,OAAQ,8BACRF,cAAe,qFAEjB,CACED,WAAY,gBACZD,MAAO,gBACPI,OAAQ,8BACRF,cAAe,qFAEjB,CACED,WAAY,kBACZD,MAAO,kBACPI,OAAQ,gCACRF,cAAe,mFAEjB,CACED,WAAY,iBACZD,MAAO,iBACPI,OAAQ,+BACRF,cAAe,kFAEjB,CACED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CACRF,cAAe,uEAEjB,CACED,WAAY,mBACZD,MAAO,mBACPI,OAAQ,iCACRF,cAAe,8EAEjB,CACED,WAAY,mBACZD,MAAO,mBACPI,OAAQ,iCACRF,cAAe,6EAEjB,CACED,WAAY,iBACZD,MAAO,iBACPI,OAAQ,+BACRF,cAAe,uDAIN4B,EAAgBxB,EAAUE,KAAKC,GAAYA,EAAQT,QAoEhE,EAlEsC,CACpCW,QAAS,CACPC,QAAS,OAEX,sBAAuB,CACrBA,QAAS,6BACTC,YAAY,EACZC,OAAQ,CACN,YAAa,CACXF,QAAS,yBACTG,MAAO,aAETC,YAAa,SAGjB,iBAAkB,CAChBJ,QAAS,gBACTK,QAAQ,EACRH,OAAQ,CACNH,QAAS,CACPC,QAAS,OAEX,YAAa,CACXA,QAAS,+BACTG,MAAO,YACPE,QAAQ,GAEV,cAAe,CACbL,QAAS,oBACTK,QAAQ,EACRF,MAAO,cAETC,YAAa,QAGjBK,SAAU,IAAIH,OAAQ,SAAQZ,EAAUE,KAAKW,GAAMA,EAAEnB,QAAOoB,KAAK,mBAAoB,KACrF,gBAAiB,CACf,CACER,QAAS,gBACTE,OAAQ,CACN,iBAAkB,CAChBF,QAAS,mBACTG,MAAO,YAIb,CACEH,QAAS,iBACTC,YAAY,EACZC,OAAQ,CACN,iBAAkB,CAChBF,QAAS,mBACTG,MAAO,aAKfgB,OAAQ,CACNnB,QAAS,cACTG,MAAO,UAETS,OAAQ,sCACRC,SAAU,IAAIP,OAAQ,0DAAyDU,EAAUR,KAAK,WAAY,KAC1GJ,YAAa","sources":["webpack://grafana/./public/app/plugins/datasource/loki/syntax.ts","webpack://grafana/./public/app/plugins/datasource/prometheus/promql.ts"],"sourcesContent":["import { Grammar } from 'prismjs';\n\nimport { CompletionItem } from '@grafana/ui';\n\nconst AGGREGATION_OPERATORS: CompletionItem[] = [\n {\n label: 'sum',\n insertText: 'sum',\n documentation: 'Calculate sum over dimensions',\n },\n {\n label: 'min',\n insertText: 'min',\n documentation: 'Select minimum over dimensions',\n },\n {\n label: 'max',\n insertText: 'max',\n documentation: 'Select maximum over dimensions',\n },\n {\n label: 'avg',\n insertText: 'avg',\n documentation: 'Calculate the average over dimensions',\n },\n {\n label: 'stddev',\n insertText: 'stddev',\n documentation: 'Calculate population standard deviation over dimensions',\n },\n {\n label: 'stdvar',\n insertText: 'stdvar',\n documentation: 'Calculate population standard variance over dimensions',\n },\n {\n label: 'count',\n insertText: 'count',\n documentation: 'Count number of elements in the vector',\n },\n {\n label: 'bottomk',\n insertText: 'bottomk',\n documentation: 'Smallest k elements by sample value',\n },\n {\n label: 'topk',\n insertText: 'topk',\n documentation: 'Largest k elements by sample value',\n },\n];\n\nexport const PIPE_PARSERS: CompletionItem[] = [\n {\n label: 'json',\n insertText: 'json',\n documentation: 'Extracting labels from the log line using json parser. Only available in Loki 2.0+.',\n },\n {\n label: 'regexp',\n insertText: 'regexp \"\"',\n documentation: 'Extracting labels from the log line using regexp parser. Only available in Loki 2.0+.',\n move: -1,\n },\n {\n label: 'logfmt',\n insertText: 'logfmt',\n documentation: 'Extracting labels from the log line using logfmt parser. Only available in Loki 2.0+.',\n },\n {\n label: 'pattern',\n insertText: 'pattern',\n documentation: 'Extracting labels from the log line using pattern parser. Only available in Loki 2.3+.',\n },\n {\n label: 'unpack',\n insertText: 'unpack',\n detail: 'unpack identifier',\n documentation:\n 'Parses a JSON log line, unpacking all embedded labels in the pack stage. A special property \"_entry\" will also be used to replace the original log line. Only available in Loki 2.2+.',\n },\n];\n\nexport const PIPE_OPERATORS: CompletionItem[] = [\n {\n label: 'unwrap',\n insertText: 'unwrap',\n detail: 'unwrap identifier',\n documentation:\n 'Take labels and use the values as sample data for metric aggregations. Only available in Loki 2.0+.',\n },\n {\n label: 'label_format',\n insertText: 'label_format',\n documentation:\n 'Use to rename, modify or add labels. For example, | label_format foo=bar . Only available in Loki 2.0+.',\n },\n {\n label: 'line_format',\n insertText: 'line_format',\n documentation:\n 'Rewrites log line content. For example, | line_format \"{{.query}} {{.duration}}\" . Only available in Loki 2.0+.',\n },\n];\n\nexport const RANGE_VEC_FUNCTIONS = [\n {\n insertText: 'avg_over_time',\n label: 'avg_over_time',\n detail: 'avg_over_time(range-vector)',\n documentation: 'The average of all values in the specified interval. Only available in Loki 2.0+.',\n },\n {\n insertText: 'min_over_time',\n label: 'min_over_time',\n detail: 'min_over_time(range-vector)',\n documentation: 'The minimum of all values in the specified interval. Only available in Loki 2.0+.',\n },\n {\n insertText: 'max_over_time',\n label: 'max_over_time',\n detail: 'max_over_time(range-vector)',\n documentation: 'The maximum of all values in the specified interval. Only available in Loki 2.0+.',\n },\n {\n insertText: 'first_over_time',\n label: 'first_over_time',\n detail: 'first_over_time(range-vector)',\n documentation: 'The first of all values in the specified interval. Only available in Loki 2.3+.',\n },\n {\n insertText: 'last_over_time',\n label: 'last_over_time',\n detail: 'last_over_time(range-vector)',\n documentation: 'The last of all values in the specified interval. Only available in Loki 2.3+.',\n },\n {\n insertText: 'sum_over_time',\n label: 'sum_over_time',\n detail: 'sum_over_time(range-vector)',\n documentation: 'The sum of all values in the specified interval. Only available in Loki 2.0+.',\n },\n {\n insertText: 'count_over_time',\n label: 'count_over_time',\n detail: 'count_over_time(range-vector)',\n documentation: 'The count of all values in the specified interval.',\n },\n {\n insertText: 'stdvar_over_time',\n label: 'stdvar_over_time',\n detail: 'stdvar_over_time(range-vector)',\n documentation:\n 'The population standard variance of the values in the specified interval. Only available in Loki 2.0+.',\n },\n {\n insertText: 'stddev_over_time',\n label: 'stddev_over_time',\n detail: 'stddev_over_time(range-vector)',\n documentation:\n 'The population standard deviation of the values in the specified interval. Only available in Loki 2.0+.',\n },\n {\n insertText: 'quantile_over_time',\n label: 'quantile_over_time',\n detail: 'quantile_over_time(scalar, range-vector)',\n documentation: 'The φ-quantile (0 ≤ φ ≤ 1) of the values in the specified interval. Only available in Loki 2.0+.',\n },\n {\n insertText: 'bytes_over_time',\n label: 'bytes_over_time',\n detail: 'bytes_over_time(range-vector)',\n documentation: 'Counts the amount of bytes used by each log stream for a given range',\n },\n {\n insertText: 'bytes_rate',\n label: 'bytes_rate',\n detail: 'bytes_rate(range-vector)',\n documentation: 'Calculates the number of bytes per second for each stream.',\n },\n {\n insertText: 'rate',\n label: 'rate',\n detail: 'rate(v range-vector)',\n documentation: 'Calculates the number of entries per second.',\n },\n];\n\nexport const FUNCTIONS = [...AGGREGATION_OPERATORS, ...RANGE_VEC_FUNCTIONS];\nexport const LOKI_KEYWORDS = [...FUNCTIONS, ...PIPE_OPERATORS, ...PIPE_PARSERS].map((keyword) => keyword.label);\n\nexport const lokiGrammar: Grammar = {\n comment: {\n pattern: /#.*/,\n },\n 'context-aggregation': {\n pattern: /((without|by)\\s*)\\([^)]*\\)/, // by ()\n lookbehind: true,\n inside: {\n 'label-key': {\n pattern: /[^(),\\s][^,)]*[^),\\s]*/,\n alias: 'attr-name',\n },\n punctuation: /[()]/,\n },\n },\n 'context-labels': {\n pattern: /\\{[^}]*(?=}?)/,\n greedy: true,\n inside: {\n comment: {\n pattern: /#.*/,\n },\n 'label-key': {\n pattern: /[a-zA-Z_]\\w*(?=\\s*(=|!=|=~|!~))/,\n alias: 'attr-name',\n greedy: true,\n },\n 'label-value': {\n pattern: /\"(?:\\\\.|[^\\\\\"])*\"/,\n greedy: true,\n alias: 'attr-value',\n },\n punctuation: /[{]/,\n },\n },\n 'context-pipe': {\n pattern: /\\s\\|[^=~]\\s?\\w*/i,\n inside: {\n 'pipe-operator': {\n pattern: /\\|/i,\n alias: 'operator',\n },\n 'pipe-operations': {\n pattern: new RegExp(`${[...PIPE_PARSERS, ...PIPE_OPERATORS].map((f) => f.label).join('|')}`, 'i'),\n alias: 'keyword',\n },\n },\n },\n function: new RegExp(`\\\\b(?:${FUNCTIONS.map((f) => f.label).join('|')})(?=\\\\s*\\\\()`, 'i'),\n 'context-range': [\n {\n pattern: /\\[[^\\]]*(?=\\])/, // [1m]\n inside: {\n 'range-duration': {\n pattern: /\\b\\d+[smhdwy]\\b/i,\n alias: 'number',\n },\n },\n },\n {\n pattern: /(offset\\s+)\\w+/, // offset 1m\n lookbehind: true,\n inside: {\n 'range-duration': {\n pattern: /\\b\\d+[smhdwy]\\b/i,\n alias: 'number',\n },\n },\n },\n ],\n quote: {\n pattern: /\"(?:\\\\.|[^\\\\\"])*\"/,\n alias: 'string',\n greedy: true,\n },\n backticks: {\n pattern: /`(?:\\\\.|[^\\\\`])*`/,\n alias: 'string',\n greedy: true,\n },\n number: /\\b-?\\d+((\\.\\d*)?([eE][+-]?\\d+)?)?\\b/,\n operator: /\\s?(\\|[=~]?|!=?|<(?:=>?|<|>)?|>[>=]?)\\s?/i,\n punctuation: /[{}(),.]/,\n};\n\nexport default lokiGrammar;\n","import { Grammar } from 'prismjs';\n\nimport { CompletionItem } from '@grafana/ui';\n\n// When changing RATE_RANGES, check if Loki/LogQL ranges should be changed too\n// @see public/app/plugins/datasource/loki/language_provider.ts\nexport const RATE_RANGES: CompletionItem[] = [\n { label: '$__interval', sortValue: '$__interval' },\n { label: '$__rate_interval', sortValue: '$__rate_interval' },\n { label: '$__range', sortValue: '$__range' },\n { label: '1m', sortValue: '00:01:00' },\n { label: '5m', sortValue: '00:05:00' },\n { label: '10m', sortValue: '00:10:00' },\n { label: '30m', sortValue: '00:30:00' },\n { label: '1h', sortValue: '01:00:00' },\n { label: '1d', sortValue: '24:00:00' },\n];\n\nexport const OPERATORS = ['by', 'group_left', 'group_right', 'ignoring', 'on', 'offset', 'without'];\nexport const LOGICAL_OPERATORS = ['or', 'and', 'unless'];\n\nconst TRIGONOMETRIC_FUNCTIONS: CompletionItem[] = [\n {\n label: 'acos',\n insertText: 'acos',\n detail: 'acos(v instant-vector)',\n documentation: 'calculates the arccosine of all elements in v',\n },\n {\n label: 'acosh',\n insertText: 'acosh',\n detail: 'acosh(v instant-vector)',\n documentation: 'calculates the inverse hyperbolic cosine of all elements in v',\n },\n {\n label: 'asin',\n insertText: 'asin',\n detail: 'asin(v instant-vector)',\n documentation: 'calculates the arcsine of all elements in v',\n },\n {\n label: 'asinh',\n insertText: 'asinh',\n detail: 'asinh(v instant-vector)',\n documentation: 'calculates the inverse hyperbolic sine of all elements in v',\n },\n {\n label: 'atan',\n insertText: 'atan',\n detail: 'atan(v instant-vector)',\n documentation: 'calculates the arctangent of all elements in v',\n },\n {\n label: 'atanh',\n insertText: 'atanh',\n detail: 'atanh(v instant-vector)',\n documentation: 'calculates the inverse hyperbolic tangent of all elements in v',\n },\n {\n label: 'cos',\n insertText: 'cos',\n detail: 'cos(v instant-vector)',\n documentation: 'calculates the cosine of all elements in v',\n },\n {\n label: 'cosh',\n insertText: 'cosh',\n detail: 'cosh(v instant-vector)',\n documentation: 'calculates the hyperbolic cosine of all elements in v',\n },\n {\n label: 'sin',\n insertText: 'sin',\n detail: 'sin(v instant-vector)',\n documentation: 'calculates the sine of all elements in v',\n },\n {\n label: 'sinh',\n insertText: 'sinh',\n detail: 'sinh(v instant-vector)',\n documentation: 'calculates the hyperbolic sine of all elements in v',\n },\n {\n label: 'tan',\n insertText: 'tan',\n detail: 'tan(v instant-vector)',\n documentation: 'calculates the tangent of all elements in v',\n },\n {\n label: 'tanh',\n insertText: 'tanh',\n detail: 'tanh(v instant-vector)',\n documentation: 'calculates the hyperbolic tangent of all elements in v',\n },\n];\n\nconst AGGREGATION_OPERATORS: CompletionItem[] = [\n {\n label: 'sum',\n insertText: 'sum',\n documentation: 'Calculate sum over dimensions',\n },\n {\n label: 'min',\n insertText: 'min',\n documentation: 'Select minimum over dimensions',\n },\n {\n label: 'max',\n insertText: 'max',\n documentation: 'Select maximum over dimensions',\n },\n {\n label: 'avg',\n insertText: 'avg',\n documentation: 'Calculate the average over dimensions',\n },\n {\n label: 'group',\n insertText: 'group',\n documentation: 'All values in the resulting vector are 1',\n },\n {\n label: 'stddev',\n insertText: 'stddev',\n documentation: 'Calculate population standard deviation over dimensions',\n },\n {\n label: 'stdvar',\n insertText: 'stdvar',\n documentation: 'Calculate population standard variance over dimensions',\n },\n {\n label: 'count',\n insertText: 'count',\n documentation: 'Count number of elements in the vector',\n },\n {\n label: 'count_values',\n insertText: 'count_values',\n documentation: 'Count number of elements with the same value',\n },\n {\n label: 'bottomk',\n insertText: 'bottomk',\n documentation: 'Smallest k elements by sample value',\n },\n {\n label: 'topk',\n insertText: 'topk',\n documentation: 'Largest k elements by sample value',\n },\n {\n label: 'quantile',\n insertText: 'quantile',\n documentation: 'Calculate φ-quantile (0 ≤ φ ≤ 1) over dimensions',\n },\n];\n\nexport const FUNCTIONS = [\n ...AGGREGATION_OPERATORS,\n ...TRIGONOMETRIC_FUNCTIONS,\n {\n insertText: 'abs',\n label: 'abs',\n detail: 'abs(v instant-vector)',\n documentation: 'Returns the input vector with all sample values converted to their absolute value.',\n },\n {\n insertText: 'absent',\n label: 'absent',\n detail: 'absent(v instant-vector)',\n documentation:\n '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.',\n },\n {\n insertText: 'absent_over_time',\n label: 'absent_over_time',\n detail: 'absent(v range-vector)',\n documentation:\n 'Returns an empty vector if the range vector passed to it has any elements and a 1-element vector with the value 1 if the range vector passed to it has no elements.',\n },\n {\n insertText: 'ceil',\n label: 'ceil',\n detail: 'ceil(v instant-vector)',\n documentation: 'Rounds the sample values of all elements in `v` up to the nearest integer.',\n },\n {\n insertText: 'changes',\n label: 'changes',\n detail: 'changes(v range-vector)',\n documentation:\n '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.',\n },\n {\n insertText: 'clamp',\n label: 'clamp',\n detail: 'clamp(v instant-vector, min scalar, max scalar)',\n documentation:\n 'Clamps the sample values of all elements in `v` to have a lower limit of `min` and an upper limit of `max`.',\n },\n {\n insertText: 'clamp_max',\n label: 'clamp_max',\n detail: 'clamp_max(v instant-vector, max scalar)',\n documentation: 'Clamps the sample values of all elements in `v` to have an upper limit of `max`.',\n },\n {\n insertText: 'clamp_min',\n label: 'clamp_min',\n detail: 'clamp_min(v instant-vector, min scalar)',\n documentation: 'Clamps the sample values of all elements in `v` to have a lower limit of `min`.',\n },\n {\n insertText: 'count_scalar',\n label: 'count_scalar',\n detail: 'count_scalar(v instant-vector)',\n documentation:\n '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.',\n },\n {\n insertText: 'deg',\n label: 'deg',\n detail: 'deg(v instant-vector)',\n documentation: 'Converts radians to degrees for all elements in v',\n },\n {\n insertText: 'day_of_month',\n label: 'day_of_month',\n detail: 'day_of_month(v=vector(time()) instant-vector)',\n documentation: 'Returns the day of the month for each of the given times in UTC. Returned values are from 1 to 31.',\n },\n {\n insertText: 'day_of_week',\n label: 'day_of_week',\n detail: 'day_of_week(v=vector(time()) instant-vector)',\n documentation:\n '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.',\n },\n {\n insertText: 'days_in_month',\n label: 'days_in_month',\n detail: 'days_in_month(v=vector(time()) instant-vector)',\n documentation:\n 'Returns number of days in the month for each of the given times in UTC. Returned values are from 28 to 31.',\n },\n {\n insertText: 'delta',\n label: 'delta',\n detail: 'delta(v range-vector)',\n documentation:\n '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.',\n },\n {\n insertText: 'deriv',\n label: 'deriv',\n detail: 'deriv(v range-vector)',\n documentation:\n 'Calculates the per-second derivative of the time series in a range vector `v`, using simple linear regression.',\n },\n {\n insertText: 'drop_common_labels',\n label: 'drop_common_labels',\n detail: 'drop_common_labels(instant-vector)',\n documentation: 'Drops all labels that have the same name and value across all series in the input vector.',\n },\n {\n insertText: 'exp',\n label: 'exp',\n detail: 'exp(v instant-vector)',\n documentation:\n 'Calculates the exponential function for all elements in `v`.\\nSpecial cases are:\\n* `Exp(+Inf) = +Inf` \\n* `Exp(NaN) = NaN`',\n },\n {\n insertText: 'floor',\n label: 'floor',\n detail: 'floor(v instant-vector)',\n documentation: 'Rounds the sample values of all elements in `v` down to the nearest integer.',\n },\n {\n insertText: 'histogram_quantile',\n label: 'histogram_quantile',\n detail: 'histogram_quantile(φ float, b instant-vector)',\n documentation:\n '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.',\n },\n {\n insertText: 'holt_winters',\n label: 'holt_winters',\n detail: 'holt_winters(v range-vector, sf scalar, tf scalar)',\n documentation:\n '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.',\n },\n {\n insertText: 'hour',\n label: 'hour',\n detail: 'hour(v=vector(time()) instant-vector)',\n documentation: 'Returns the hour of the day for each of the given times in UTC. Returned values are from 0 to 23.',\n },\n {\n insertText: 'idelta',\n label: 'idelta',\n detail: 'idelta(v range-vector)',\n documentation:\n 'Calculates the difference between the last two samples in the range vector `v`, returning an instant vector with the given deltas and equivalent labels.',\n },\n {\n insertText: 'increase',\n label: 'increase',\n detail: 'increase(v range-vector)',\n documentation:\n '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.',\n },\n {\n insertText: 'irate',\n label: 'irate',\n detail: 'irate(v range-vector)',\n documentation:\n '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.',\n },\n {\n insertText: 'label_join',\n label: 'label_join',\n detail:\n 'label_join(v instant-vector, dst_label string, separator string, src_label_1 string, src_label_2 string, ...)',\n documentation:\n 'For each timeseries in `v`, joins all the values of all the `src_labels` using `separator` and returns the timeseries with the label `dst_label` containing the joined value. There can be any number of `src_labels` in this function.',\n },\n {\n insertText: 'label_replace',\n label: 'label_replace',\n detail: 'label_replace(v instant-vector, dst_label string, replacement string, src_label string, regex string)',\n documentation:\n \"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.\",\n },\n {\n insertText: 'ln',\n label: 'ln',\n detail: 'ln(v instant-vector)',\n documentation:\n '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`',\n },\n {\n insertText: 'log2',\n label: 'log2',\n detail: 'log2(v instant-vector)',\n documentation:\n 'Calculates the binary logarithm for all elements in `v`. The special cases are equivalent to those in `ln`.',\n },\n {\n insertText: 'log10',\n label: 'log10',\n detail: 'log10(v instant-vector)',\n documentation:\n 'Calculates the decimal logarithm for all elements in `v`. The special cases are equivalent to those in `ln`.',\n },\n {\n insertText: 'minute',\n label: 'minute',\n detail: 'minute(v=vector(time()) instant-vector)',\n documentation:\n 'Returns the minute of the hour for each of the given times in UTC. Returned values are from 0 to 59.',\n },\n {\n insertText: 'month',\n label: 'month',\n detail: 'month(v=vector(time()) instant-vector)',\n documentation:\n '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.',\n },\n {\n insertText: 'pi',\n label: 'pi',\n detail: 'pi()',\n documentation: 'Returns pi',\n },\n {\n insertText: 'predict_linear',\n label: 'predict_linear',\n detail: 'predict_linear(v range-vector, t scalar)',\n documentation:\n 'Predicts the value of time series `t` seconds from now, based on the range vector `v`, using simple linear regression.',\n },\n {\n insertText: 'rad',\n label: 'rad',\n detail: 'rad(v instant-vector)',\n documentation: 'Converts degrees to radians for all elements in v',\n },\n {\n insertText: 'rate',\n label: 'rate',\n detail: 'rate(v range-vector)',\n documentation:\n \"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.\",\n },\n {\n insertText: 'resets',\n label: 'resets',\n detail: 'resets(v range-vector)',\n documentation:\n '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.',\n },\n {\n insertText: 'round',\n label: 'round',\n detail: 'round(v instant-vector, to_nearest=1 scalar)',\n documentation:\n '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.',\n },\n {\n insertText: 'scalar',\n label: 'scalar',\n detail: 'scalar(v instant-vector)',\n documentation:\n '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`.',\n },\n {\n insertText: 'sgn',\n label: 'sgn',\n detail: 'sgn(v instant-vector)',\n documentation:\n 'Returns a vector with all sample values converted to their sign, defined as this: 1 if v is positive, -1 if v is negative and 0 if v is equal to zero.',\n },\n {\n insertText: 'sort',\n label: 'sort',\n detail: 'sort(v instant-vector)',\n documentation: 'Returns vector elements sorted by their sample values, in ascending order.',\n },\n {\n insertText: 'sort_desc',\n label: 'sort_desc',\n detail: 'sort_desc(v instant-vector)',\n documentation: 'Returns vector elements sorted by their sample values, in descending order.',\n },\n {\n insertText: 'sqrt',\n label: 'sqrt',\n detail: 'sqrt(v instant-vector)',\n documentation: 'Calculates the square root of all elements in `v`.',\n },\n {\n insertText: 'time',\n label: 'time',\n detail: 'time()',\n documentation:\n '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.',\n },\n {\n insertText: 'timestamp',\n label: 'timestamp',\n detail: 'timestamp(v instant-vector)',\n documentation:\n 'Returns the timestamp of each of the samples of the given vector as the number of seconds since January 1, 1970 UTC.',\n },\n {\n insertText: 'vector',\n label: 'vector',\n detail: 'vector(s scalar)',\n documentation: 'Returns the scalar `s` as a vector with no labels.',\n },\n {\n insertText: 'year',\n label: 'year',\n detail: 'year(v=vector(time()) instant-vector)',\n documentation: 'Returns the year for each of the given times in UTC.',\n },\n {\n insertText: 'avg_over_time',\n label: 'avg_over_time',\n detail: 'avg_over_time(range-vector)',\n documentation: 'The average value of all points in the specified interval.',\n },\n {\n insertText: 'min_over_time',\n label: 'min_over_time',\n detail: 'min_over_time(range-vector)',\n documentation: 'The minimum value of all points in the specified interval.',\n },\n {\n insertText: 'max_over_time',\n label: 'max_over_time',\n detail: 'max_over_time(range-vector)',\n documentation: 'The maximum value of all points in the specified interval.',\n },\n {\n insertText: 'sum_over_time',\n label: 'sum_over_time',\n detail: 'sum_over_time(range-vector)',\n documentation: 'The sum of all values in the specified interval.',\n },\n {\n insertText: 'count_over_time',\n label: 'count_over_time',\n detail: 'count_over_time(range-vector)',\n documentation: 'The count of all values in the specified interval.',\n },\n {\n insertText: 'quantile_over_time',\n label: 'quantile_over_time',\n detail: 'quantile_over_time(scalar, range-vector)',\n documentation: 'The φ-quantile (0 ≤ φ ≤ 1) of the values in the specified interval.',\n },\n {\n insertText: 'stddev_over_time',\n label: 'stddev_over_time',\n detail: 'stddev_over_time(range-vector)',\n documentation: 'The population standard deviation of the values in the specified interval.',\n },\n {\n insertText: 'stdvar_over_time',\n label: 'stdvar_over_time',\n detail: 'stdvar_over_time(range-vector)',\n documentation: 'The population standard variance of the values in the specified interval.',\n },\n {\n insertText: 'last_over_time',\n label: 'last_over_time',\n detail: 'last_over_time(range-vector)',\n documentation: 'The most recent point value in specified interval.',\n },\n];\n\nexport const PROM_KEYWORDS = FUNCTIONS.map((keyword) => keyword.label);\n\nexport const promqlGrammar: Grammar = {\n comment: {\n pattern: /#.*/,\n },\n 'context-aggregation': {\n pattern: /((by|without)\\s*)\\([^)]*\\)/, // by ()\n lookbehind: true,\n inside: {\n 'label-key': {\n pattern: /[^(),\\s][^,)]*[^),\\s]*/,\n alias: 'attr-name',\n },\n punctuation: /[()]/,\n },\n },\n 'context-labels': {\n pattern: /\\{[^}]*(?=}?)/,\n greedy: true,\n inside: {\n comment: {\n pattern: /#.*/,\n },\n 'label-key': {\n pattern: /[a-z_]\\w*(?=\\s*(=|!=|=~|!~))/,\n alias: 'attr-name',\n greedy: true,\n },\n 'label-value': {\n pattern: /\"(?:\\\\.|[^\\\\\"])*\"/,\n greedy: true,\n alias: 'attr-value',\n },\n punctuation: /[{]/,\n },\n },\n function: new RegExp(`\\\\b(?:${FUNCTIONS.map((f) => f.label).join('|')})(?=\\\\s*\\\\()`, 'i'),\n 'context-range': [\n {\n pattern: /\\[[^\\]]*(?=])/, // [1m]\n inside: {\n 'range-duration': {\n pattern: /\\b\\d+[smhdwy]\\b/i,\n alias: 'number',\n },\n },\n },\n {\n pattern: /(offset\\s+)\\w+/, // offset 1m\n lookbehind: true,\n inside: {\n 'range-duration': {\n pattern: /\\b\\d+[smhdwy]\\b/i,\n alias: 'number',\n },\n },\n },\n ],\n idList: {\n pattern: /\\d+(\\|\\d+)+/,\n alias: 'number',\n },\n number: /\\b-?\\d+((\\.\\d*)?([eE][+-]?\\d+)?)?\\b/,\n operator: new RegExp(`/[-+*/=%^~]|&&?|\\\\|?\\\\||!=?|<(?:=>?|<|>)?|>[>=]?|\\\\b(?:${OPERATORS.join('|')})\\\\b`, 'i'),\n punctuation: /[{};()`,.]/,\n};\n\nexport default promqlGrammar;\n"],"names":["PIPE_PARSERS","label","insertText","documentation","move","detail","PIPE_OPERATORS","FUNCTIONS","LOKI_KEYWORDS","map","keyword","lokiGrammar","comment","pattern","lookbehind","inside","alias","punctuation","greedy","RegExp","f","join","function","quote","backticks","number","operator","RATE_RANGES","sortValue","OPERATORS","LOGICAL_OPERATORS","PROM_KEYWORDS","idList"],"sourceRoot":""}