summaryrefslogtreecommitdiffstats
path: root/tests/snippets/promql
diff options
context:
space:
mode:
Diffstat (limited to 'tests/snippets/promql')
-rw-r--r--tests/snippets/promql/test_complex_exp_single_quotes.txt35
-rw-r--r--tests/snippets/promql/test_expression_and_comment.txt15
-rw-r--r--tests/snippets/promql/test_function_delta.txt19
-rw-r--r--tests/snippets/promql/test_function_multi_line.txt80
-rw-r--r--tests/snippets/promql/test_function_multi_line_with_offset.txt87
-rw-r--r--tests/snippets/promql/test_function_sum_with_args.txt19
-rw-r--r--tests/snippets/promql/test_matching_operator_no_regex_match.txt16
-rw-r--r--tests/snippets/promql/test_metric.txt6
-rw-r--r--tests/snippets/promql/test_metric_multiple_labels.txt19
-rw-r--r--tests/snippets/promql/test_metric_multiple_labels_with_spaces.txt22
-rw-r--r--tests/snippets/promql/test_metric_one_label.txt13
11 files changed, 331 insertions, 0 deletions
diff --git a/tests/snippets/promql/test_complex_exp_single_quotes.txt b/tests/snippets/promql/test_complex_exp_single_quotes.txt
new file mode 100644
index 0000000..cbbde3a
--- /dev/null
+++ b/tests/snippets/promql/test_complex_exp_single_quotes.txt
@@ -0,0 +1,35 @@
+---input---
+(sum(rate(metric_test_app{app='turtle',proc='web'}[2m])) by(node))
+
+---tokens---
+'(' Operator
+'sum' Keyword
+'(' Operator
+'rate' Keyword.Reserved
+'(' Operator
+'metric_test_app' Name.Variable
+'{' Punctuation
+'app' Name.Label
+'=' Operator
+"'" Punctuation
+'turtle' Literal.String
+"'" Punctuation
+',' Punctuation
+'proc' Name.Label
+'=' Operator
+"'" Punctuation
+'web' Literal.String
+"'" Punctuation
+'}' Punctuation
+'[' Punctuation
+'2m' Literal.String
+']' Punctuation
+')' Operator
+')' Operator
+' ' Text.Whitespace
+'by' Keyword
+'(' Operator
+'node' Name.Variable
+')' Operator
+')' Operator
+'\n' Text.Whitespace
diff --git a/tests/snippets/promql/test_expression_and_comment.txt b/tests/snippets/promql/test_expression_and_comment.txt
new file mode 100644
index 0000000..3ee2bfa
--- /dev/null
+++ b/tests/snippets/promql/test_expression_and_comment.txt
@@ -0,0 +1,15 @@
+---input---
+go_gc_duration_seconds{instance="localhost:9090"} # single comment
+
+---tokens---
+'go_gc_duration_seconds' Name.Variable
+'{' Punctuation
+'instance' Name.Label
+'=' Operator
+'"' Punctuation
+'localhost:9090' Literal.String
+'"' Punctuation
+'}' Punctuation
+' ' Text.Whitespace
+'# single comment' Comment.Single
+'\n' Text.Whitespace
diff --git a/tests/snippets/promql/test_function_delta.txt b/tests/snippets/promql/test_function_delta.txt
new file mode 100644
index 0000000..8b1f9b0
--- /dev/null
+++ b/tests/snippets/promql/test_function_delta.txt
@@ -0,0 +1,19 @@
+---input---
+delta(cpu_temp_celsius{host="zeus"}[2h])
+
+---tokens---
+'delta' Keyword.Reserved
+'(' Operator
+'cpu_temp_celsius' Name.Variable
+'{' Punctuation
+'host' Name.Label
+'=' Operator
+'"' Punctuation
+'zeus' Literal.String
+'"' Punctuation
+'}' Punctuation
+'[' Punctuation
+'2h' Literal.String
+']' Punctuation
+')' Operator
+'\n' Text.Whitespace
diff --git a/tests/snippets/promql/test_function_multi_line.txt b/tests/snippets/promql/test_function_multi_line.txt
new file mode 100644
index 0000000..31664cc
--- /dev/null
+++ b/tests/snippets/promql/test_function_multi_line.txt
@@ -0,0 +1,80 @@
+---input---
+label_replace(
+ sum by (instance) (
+ irate(node_disk_read_bytes_total[2m])
+ ) / 1024 / 1024,
+ "device",
+ 'disk',
+ "instance",
+ ".*"
+)
+
+---tokens---
+'label_replace' Keyword.Reserved
+'(' Operator
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'sum' Keyword
+' ' Text.Whitespace
+'by' Keyword
+' ' Text.Whitespace
+'(' Operator
+'instance' Name.Variable
+')' Operator
+' ' Text.Whitespace
+'(' Operator
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'irate' Keyword.Reserved
+'(' Operator
+'node_disk_read_bytes_total' Name.Variable
+'[' Punctuation
+'2m' Literal.String
+']' Punctuation
+')' Operator
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+')' Operator
+' ' Text.Whitespace
+'/' Operator
+' ' Text.Whitespace
+'1024' Literal.Number.Integer
+' ' Text.Whitespace
+'/' Operator
+' ' Text.Whitespace
+'1024' Literal.Number.Integer
+',' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'"' Punctuation
+'device' Literal.String
+'"' Punctuation
+',' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+"'" Punctuation
+'disk' Literal.String
+"'" Punctuation
+',' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'"' Punctuation
+'instance' Literal.String
+'"' Punctuation
+',' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'"' Punctuation
+'.*' Literal.String
+'"' Punctuation
+'\n' Text.Whitespace
+
+')' Operator
+'\n' Text.Whitespace
diff --git a/tests/snippets/promql/test_function_multi_line_with_offset.txt b/tests/snippets/promql/test_function_multi_line_with_offset.txt
new file mode 100644
index 0000000..a7462fb
--- /dev/null
+++ b/tests/snippets/promql/test_function_multi_line_with_offset.txt
@@ -0,0 +1,87 @@
+---input---
+label_replace(
+ avg by(instance)
+ (irate(node_cpu_seconds_total{mode = "idle"}[5m] offset 3s)
+ ) * 100,
+ "device",
+ "cpu",
+ "instance",
+ ".*"
+)
+
+---tokens---
+'label_replace' Keyword.Reserved
+'(' Operator
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'avg' Keyword
+' ' Text.Whitespace
+'by' Keyword
+'(' Operator
+'instance' Name.Variable
+')' Operator
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'(' Operator
+'irate' Keyword.Reserved
+'(' Operator
+'node_cpu_seconds_total' Name.Variable
+'{' Punctuation
+'mode' Name.Label
+' ' Text.Whitespace
+'=' Operator
+' ' Text.Whitespace
+'"' Punctuation
+'idle' Literal.String
+'"' Punctuation
+'}' Punctuation
+'[' Punctuation
+'5m' Literal.String
+']' Punctuation
+' ' Text.Whitespace
+'offset' Keyword
+' ' Text.Whitespace
+'3s' Literal.String
+')' Operator
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+')' Operator
+' ' Text.Whitespace
+'*' Operator
+' ' Text.Whitespace
+'100' Literal.Number.Integer
+',' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'"' Punctuation
+'device' Literal.String
+'"' Punctuation
+',' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'"' Punctuation
+'cpu' Literal.String
+'"' Punctuation
+',' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'"' Punctuation
+'instance' Literal.String
+'"' Punctuation
+',' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'"' Punctuation
+'.*' Literal.String
+'"' Punctuation
+'\n' Text.Whitespace
+
+')' Operator
+'\n' Text.Whitespace
diff --git a/tests/snippets/promql/test_function_sum_with_args.txt b/tests/snippets/promql/test_function_sum_with_args.txt
new file mode 100644
index 0000000..3d677e1
--- /dev/null
+++ b/tests/snippets/promql/test_function_sum_with_args.txt
@@ -0,0 +1,19 @@
+---input---
+sum by (app, proc) (instance_memory_usage_bytes)
+
+---tokens---
+'sum' Keyword
+' ' Text.Whitespace
+'by' Keyword
+' ' Text.Whitespace
+'(' Operator
+'app' Name.Variable
+',' Punctuation
+' ' Text.Whitespace
+'proc' Name.Variable
+')' Operator
+' ' Text.Whitespace
+'(' Operator
+'instance_memory_usage_bytes' Name.Variable
+')' Operator
+'\n' Text.Whitespace
diff --git a/tests/snippets/promql/test_matching_operator_no_regex_match.txt b/tests/snippets/promql/test_matching_operator_no_regex_match.txt
new file mode 100644
index 0000000..9859739
--- /dev/null
+++ b/tests/snippets/promql/test_matching_operator_no_regex_match.txt
@@ -0,0 +1,16 @@
+---input---
+metric_test_app{status!~'(4|5)..'}[2m]
+
+---tokens---
+'metric_test_app' Name.Variable
+'{' Punctuation
+'status' Name.Label
+'!~' Operator
+"'" Punctuation
+'(4|5)..' Literal.String
+"'" Punctuation
+'}' Punctuation
+'[' Punctuation
+'2m' Literal.String
+']' Punctuation
+'\n' Text.Whitespace
diff --git a/tests/snippets/promql/test_metric.txt b/tests/snippets/promql/test_metric.txt
new file mode 100644
index 0000000..e4889cf
--- /dev/null
+++ b/tests/snippets/promql/test_metric.txt
@@ -0,0 +1,6 @@
+---input---
+go_gc_duration_seconds
+
+---tokens---
+'go_gc_duration_seconds' Name.Variable
+'\n' Text.Whitespace
diff --git a/tests/snippets/promql/test_metric_multiple_labels.txt b/tests/snippets/promql/test_metric_multiple_labels.txt
new file mode 100644
index 0000000..bcb0b64
--- /dev/null
+++ b/tests/snippets/promql/test_metric_multiple_labels.txt
@@ -0,0 +1,19 @@
+---input---
+go_gc_duration_seconds{instance="localhost:9090",job="alertmanager"}
+
+---tokens---
+'go_gc_duration_seconds' Name.Variable
+'{' Punctuation
+'instance' Name.Label
+'=' Operator
+'"' Punctuation
+'localhost:9090' Literal.String
+'"' Punctuation
+',' Punctuation
+'job' Name.Label
+'=' Operator
+'"' Punctuation
+'alertmanager' Literal.String
+'"' Punctuation
+'}' Punctuation
+'\n' Text.Whitespace
diff --git a/tests/snippets/promql/test_metric_multiple_labels_with_spaces.txt b/tests/snippets/promql/test_metric_multiple_labels_with_spaces.txt
new file mode 100644
index 0000000..3ca3d49
--- /dev/null
+++ b/tests/snippets/promql/test_metric_multiple_labels_with_spaces.txt
@@ -0,0 +1,22 @@
+---input---
+go_gc_duration_seconds{ instance="localhost:9090", job="alertmanager" }
+
+---tokens---
+'go_gc_duration_seconds' Name.Variable
+'{' Punctuation
+' ' Text.Whitespace
+'instance' Name.Label
+'=' Operator
+'"' Punctuation
+'localhost:9090' Literal.String
+'"' Punctuation
+',' Punctuation
+' ' Text.Whitespace
+'job' Name.Label
+'=' Operator
+'"' Punctuation
+'alertmanager' Literal.String
+'"' Punctuation
+' ' Text.Whitespace
+'}' Punctuation
+'\n' Text.Whitespace
diff --git a/tests/snippets/promql/test_metric_one_label.txt b/tests/snippets/promql/test_metric_one_label.txt
new file mode 100644
index 0000000..8baeafb
--- /dev/null
+++ b/tests/snippets/promql/test_metric_one_label.txt
@@ -0,0 +1,13 @@
+---input---
+go_gc_duration_seconds{instance="localhost:9090"}
+
+---tokens---
+'go_gc_duration_seconds' Name.Variable
+'{' Punctuation
+'instance' Name.Label
+'=' Operator
+'"' Punctuation
+'localhost:9090' Literal.String
+'"' Punctuation
+'}' Punctuation
+'\n' Text.Whitespace