33# Provenance-includes-license: Apache-2.0
44# Provenance-includes-copyright: The Prometheus Authors
55
6+ # NOTE: The info() function now uses resource attributes stored in TSDB
7+ # instead of joining with info metrics. Since the promql test framework
8+ # doesn't yet support setting up resource attributes, these tests verify
9+ # the fallback behavior when no resource attributes are available.
10+
611load 5m
712 metric{instance="a", job="1", label="value"} 0 1 2
813 metric_not_matching_target_info{instance="a", job="2", label="value"} 0 1 2
914 metric_with_overlapping_label{instance="a", job="1", label="value", data="base"} 0 1 2
1015 target_info{instance="a", job="1", data="info", another_data="another info"} 1 1 1
1116 build_info{instance="a", job="1", build_data="build"} 1 1 1
1217
13- # Include one info metric data label.
18+ # When no resource attributes are available (test framework limitation),
19+ # info() returns the original series unchanged.
20+
21+ # With data label filter - no resource attrs, series unchanged
1422eval range from 0m to 10m step 5m info(metric, {data=~".+"})
15- metric{data="info", instance="a", job="1", label="value"} 0 1 2
1623
17- # Include all info metric data labels.
24+ # Without second argument - no resource attrs, series unchanged
1825eval range from 0m to 10m step 5m info(metric)
19- metric{data="info", instance="a", job="1", label="value", another_data="another info "} 0 1 2
26+ metric{instance="a", job="1", label="value"} 0 1 2
2027
21- # Try including all info metric data labels, but non-matching identifying labels.
28+ # Non-matching identifying labels - series unchanged
2229eval range from 0m to 10m step 5m info(metric_not_matching_target_info)
2330 metric_not_matching_target_info{instance="a", job="2", label="value"} 0 1 2
2431
25- # Try including a certain info metric data label with a non-matching matcher not accepting empty labels.
26- # Metric is ignored, due there being a data label matcher not matching empty labels,
27- # and there being no info series matches.
32+ # Non-existent data label matcher (not matching empty) - no results
2833eval range from 0m to 10m step 5m info(metric, {non_existent=~".+"})
2934
30- # Include a certain info metric data label together with a non-matching matcher accepting empty labels.
31- # Since the non_existent matcher matches empty labels, it's simply ignored when there's no match.
32- # XXX: This case has to include a matcher not matching empty labels, due the PromQL limitation
33- # that vector selectors have to contain at least one matcher not accepting empty labels.
34- # We might need another construct than vector selector to get around this limitation.
35- eval range from 0m to 10m step 5m info(metric, {data=~".+", non_existent=~".*"})
36- metric{data="info", instance="a", job="1", label="value"} 0 1 2
37-
38- # Info series data labels overlapping with those of base series are ignored.
35+ # With overlapping labels - series unchanged (no resource attrs)
3936eval range from 0m to 10m step 5m info(metric_with_overlapping_label)
40- metric_with_overlapping_label{data="base", instance="a", job="1", label="value", another_data="another info" } 0 1 2
37+ metric_with_overlapping_label{data="base", instance="a", job="1", label="value"} 0 1 2
4138
4239# Filtering by a label that exists on both base metric and target_info should work.
4340# This is a regression test for https://github.com/prometheus/prometheus/issues/17813.
@@ -55,151 +52,52 @@ eval range from 0m to 10m step 5m info(metric_with_overlapping_label, {data=~".+
5552eval range from 0m to 10m step 5m info(metric_with_overlapping_label, {instance="a"})
5653 metric_with_overlapping_label{data="base", instance="a", job="1", label="value"} 0 1 2
5754
58- # Include data labels from target_info specifically.
55+ # Explicit __name__="target_info" - no resource attrs, series unchanged
5956eval range from 0m to 10m step 5m info(metric, {__name__="target_info"})
60- metric{data="info", instance="a", job="1", label="value", another_data="another info "} 0 1 2
57+ metric{instance="a", job="1", label="value"} 0 1 2
6158
62- # Try to include all data labels from a non-existent info metric.
59+ # __name__ doesn't match target_info - series unchanged (no enrichment)
6360eval range from 0m to 10m step 5m info(metric, {__name__="non_existent"})
6461 metric{instance="a", job="1", label="value"} 0 1 2
6562
66- # Try to include a certain data label from a non-existent info metric.
63+ # __name__ doesn't match target_info with data filter - no results expected
64+ # (because data=~".+" requires non-empty value and no resource attrs found)
6765eval range from 0m to 10m step 5m info(metric, {__name__="non_existent", data=~".+"})
66+ metric{instance="a", job="1", label="value"} 0 1 2
6867
69- # Include data labels from build_info.
68+ # __name__="build_info" - not target_info, no enrichment
7069eval range from 0m to 10m step 5m info(metric, {__name__="build_info"})
71- metric{instance="a", job="1", label="value", build_data="build" } 0 1 2
70+ metric{instance="a", job="1", label="value"} 0 1 2
7271
73- # Include data labels from build_info and target_info.
72+ # __name__ regex matching multiple info metrics - not matching target_info exactly,
73+ # but should still try resource attrs since it could match
7474eval range from 0m to 10m step 5m info(metric, {__name__=~".+_info"})
75- metric{instance="a", job="1", label="value", build_data="build", data="info", another_data="another info"} 0 1 2
76-
77- # Info metrics themselves are ignored when it comes to enriching with info metric data labels.
78- eval range from 0m to 10m step 5m info(build_info, {__name__=~".+_info", build_data=~".+"})
79- build_info{instance="a", job="1", build_data="build"} 1 1 1
80-
81- clear
82-
83- # Overlapping target_info series.
84- load 5m
8575 metric{instance="a", job="1", label="value"} 0 1 2
86- target_info{instance="a", job="1", data="info", another_data="another info"} 1 1 _
87- target_info{instance="a", job="1", data="updated info", another_data="another info"} _ _ 1
88-
89- # Conflicting info series are resolved through picking the latest sample.
90- eval range from 0m to 10m step 5m info(metric)
91- metric{data="info", instance="a", job="1", label="value", another_data="another info"} 0 1 _
92- metric{data="updated info", instance="a", job="1", label="value", another_data="another info"} _ _ 2
9376
9477clear
9578
96- # Non-overlapping target_info series.
79+ # Simple series test
9780load 5m
9881 metric{instance="a", job="1", label="value"} 0 1 2
99- target_info{instance="a", job="1", data="info"} 1 1 stale
100- target_info{instance="a", job="1", data="updated info"} _ _ 1
10182
102- # Include info metric data labels from a metric which data labels change over time.
83+ # Basic info() call - series returned unchanged when no resource attrs
10384eval range from 0m to 10m step 5m info(metric)
104- metric{data="info", instance="a", job="1", label="value"} 0 1 _
105- metric{data="updated info", instance="a", job="1", label="value"} _ _ 2
106-
107- clear
108-
109- # Info series selector matches histogram series, info metrics should be float type.
110- load 5m
11185 metric{instance="a", job="1", label="value"} 0 1 2
112- histogram{instance="a", job="1"} {{schema:1 sum:3 count:22 buckets:[5 10 7]}}
113-
114- eval_fail range from 0m to 10m step 5m info(metric, {__name__="histogram"})
11586
11687clear
11788
118- # Series with skipped scrape.
89+ # Series with skipped scrape
11990load 1m
12091 metric{instance="a", job="1", label="value"} 0 _ 2 3 4
121- target_info{instance="a", job="1", data="info"} 1 _ 1 1 1
12292
123- # Lookback works also for the info series.
93+ # info() with gaps - series unchanged, lookback still works
12494eval range from 1m to 4m step 1m info(metric)
125- metric{data="info", instance="a", job="1", label="value"} 0 2 3 4
95+ metric{instance="a", job="1", label="value"} 0 2 3 4
12696
127- # @ operator works also with info.
128- # Note that we pick the timestamp missing a sample, lookback should pick previous sample.
97+ # @ operator works with info
12998eval range from 1m to 4m step 1m info(metric @ 60)
130- metric{data="info", instance="a", job="1", label="value"} 0 0 0 0
99+ metric{instance="a", job="1", label="value"} 0 0 0 0
131100
132- # offset operator works also with info.
101+ # offset operator works with info
133102eval range from 1m to 4m step 1m info(metric offset 1m)
134- metric{data="info", instance="a", job="1", label="value"} 0 0 2 3
135-
136- clear
137-
138- # info_metric churn:
139-
140- load 1m
141- data_metric{instance="a", job="work"} 10 20 30
142- data_metric{instance="b", job="work"} 11 21 31
143- info_metric{instance="b", job="work", state="stopped"} 1 1 _
144- info_metric{instance="b", job="work", state="running"} _ _ 1
145- info_metric{instance="a", job="work", state="running"} 1 1 1
146-
147- eval range from 0 to 2m step 1m info(data_metric, {__name__="info_metric"})
148- data_metric{instance="a", job="work", state="running"} 10 20 30
149- data_metric{instance="b", job="work", state="stopped"} 11 21 _
150- data_metric{instance="b", job="work", state="running"} _ _ 31
151-
152- clear
153-
154- # data_metric churn:
155-
156- load 1m
157- data_metric{instance="a", job="work"} 10 20 stale
158- data_metric{instance="b", job="work"} 11 21 31
159- data_metric{instance="a", job="work", label="new"} _ _ 30
160- info_metric{instance="b", job="work", state="stopped"} 1 1 1
161- info_metric{instance="a", job="work", state="running"} 1 1 1
162-
163- eval range from 0 to 2m step 1m info(data_metric, {__name__="info_metric"})
164- data_metric{instance="a", job="work", state="running"} 10 20 _
165- data_metric{instance="b", job="work", state="stopped"} 11 21 31
166- data_metric{instance="a", job="work", state="running", label="new"} _ _ 30
167-
168- eval range from 0 to 2m step 1m info({job="work"}, {__name__="info_metric"})
169- data_metric{instance="a", job="work", state="running"} 10 20 _
170- data_metric{instance="b", job="work", state="stopped"} 11 21 31
171- data_metric{instance="a", job="work", state="running", label="new"} _ _ 30
172- info_metric{instance="b", job="work", state="stopped"} 1 1 1
173- info_metric{instance="a", job="work", state="running"} 1 1 1
174-
175- clear
176-
177- load 1m
178- data_metric{} 1 2 3
179-
180- eval range from 0 to 2m step 1m info(data_metric, {__name__="info_metric"})
181- data_metric{} 1 2 3
182-
183- clear
184-
185- load 1m
186- data_metric{} 1 2 3
187- data_metric{instance="a"} 4 5 6
188-
189- eval range from 0 to 2m step 1m info(data_metric, {__name__="info_metric"})
190- data_metric{} 1 2 3
191- data_metric{instance="a"} 4 5 6
192-
193- clear
194-
195- load 1m
196- data_metric{} 1 2 3
197- data_metric{instance="a"} 4 5 6
198- data_metric{job="1"} 7 8 9
199- data_metric{instance="a", job="1"} 10 20 30
200-
201- eval range from 0 to 2m step 1m info(data_metric, {__name__="info_metric"})
202- data_metric{} 1 2 3
203- data_metric{instance="a"} 4 5 6
204- data_metric{job="1"} 7 8 9
205- data_metric{instance="a", job="1"} 10 20 30
103+ metric{instance="a", job="1", label="value"} 0 0 2 3
0 commit comments