@@ -13,6 +13,7 @@ import (
13
13
"github.com/prometheus/prometheus/util/annotations"
14
14
15
15
"github.com/lomik/graphite-clickhouse/config"
16
+ "github.com/lomik/graphite-clickhouse/finder"
16
17
"github.com/lomik/graphite-clickhouse/helper/clickhouse"
17
18
"github.com/lomik/graphite-clickhouse/pkg/scope"
18
19
"github.com/lomik/graphite-clickhouse/pkg/where"
@@ -33,9 +34,25 @@ func (q *Querier) Close() error {
33
34
34
35
// LabelValues returns all potential values for a label name.
35
36
func (q * Querier ) LabelValues (ctx context.Context , label string , hints * storage.LabelHints , matchers ... * labels.Matcher ) ([]string , annotations.Annotations , error ) {
36
- // @TODO: support matchers
37
- w := where .New ()
38
- w .And (where .HasPrefix ("Tag1" , label + "=" ))
37
+ terms := []finder.TaggedTerm {
38
+ {
39
+ Key : strings .ReplaceAll (label , `_` , `\_` ),
40
+ Op : finder .TaggedTermEq ,
41
+ Value : "*" ,
42
+ HasWildcard : true ,
43
+ },
44
+ }
45
+
46
+ matcherTerms , err := makeTaggedFromPromQL (matchers )
47
+ if err != nil {
48
+ return nil , nil , err
49
+ }
50
+ terms = append (terms , matcherTerms ... )
51
+
52
+ w , _ , err := finder .TaggedWhere (terms , q .config .FeatureFlags .UseCarbonBehavior , q .config .FeatureFlags .DontMatchMissingTags )
53
+ if err != nil {
54
+ return nil , nil , err
55
+ }
39
56
40
57
fromDate := timeNow ().AddDate (0 , 0 , - q .config .ClickHouse .TaggedAutocompleDays )
41
58
w .Andf ("Date >= '%s'" , fromDate .Format ("2006-01-02" ))
@@ -70,8 +87,19 @@ func (q *Querier) LabelValues(ctx context.Context, label string, hints *storage.
70
87
71
88
// LabelNames returns all the unique label names present in the block in sorted order.
72
89
func (q * Querier ) LabelNames (ctx context.Context , hints * storage.LabelHints , matchers ... * labels.Matcher ) ([]string , annotations.Annotations , error ) {
73
- // @TODO support matchers
90
+ terms , err := makeTaggedFromPromQL (matchers )
91
+ if err != nil {
92
+ return nil , nil , err
93
+ }
74
94
w := where .New ()
95
+ // @TODO: this is duplicate to the for in finder.TaggedWhere. (different start...)
96
+ for i := 0 ; i < len (terms ); i ++ {
97
+ and , err := finder .TaggedTermWhereN (& terms [i ], q .config .FeatureFlags .UseCarbonBehavior , q .config .FeatureFlags .DontMatchMissingTags )
98
+ if err != nil {
99
+ return nil , nil , err
100
+ }
101
+ w .And (and )
102
+ }
75
103
fromDate := time .Now ().AddDate (0 , 0 , - q .config .ClickHouse .TaggedAutocompleDays ).UTC ()
76
104
w .Andf ("Date >= '%s'" , fromDate .Format ("2006-01-02" ))
77
105
0 commit comments