1
- // Copyright 2016 The Prometheus Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
-
14
- package cortex
1
+ package distributor
15
2
16
3
import (
17
4
"bytes"
@@ -28,6 +15,7 @@ import (
28
15
"github.com/prometheus/prometheus/storage/remote"
29
16
"golang.org/x/net/context"
30
17
18
+ "github.com/weaveworks/cortex"
31
19
"github.com/weaveworks/cortex/ingester"
32
20
"github.com/weaveworks/cortex/user"
33
21
)
@@ -100,32 +88,32 @@ func (c *IngesterClient) Append(ctx context.Context, samples []*model.Sample) er
100
88
101
89
// Query implements Querier.
102
90
func (c * IngesterClient ) Query (ctx context.Context , from , to model.Time , matchers ... * metric.LabelMatcher ) (model.Matrix , error ) {
103
- req := & ReadRequest {
91
+ req := & cortex. ReadRequest {
104
92
StartTimestampMs : int64 (from ),
105
93
EndTimestampMs : int64 (to ),
106
94
}
107
95
for _ , matcher := range matchers {
108
- var mType MatchType
96
+ var mType cortex. MatchType
109
97
switch matcher .Type {
110
98
case metric .Equal :
111
- mType = MatchType_EQUAL
99
+ mType = cortex . MatchType_EQUAL
112
100
case metric .NotEqual :
113
- mType = MatchType_NOT_EQUAL
101
+ mType = cortex . MatchType_NOT_EQUAL
114
102
case metric .RegexMatch :
115
- mType = MatchType_REGEX_MATCH
103
+ mType = cortex . MatchType_REGEX_MATCH
116
104
case metric .RegexNoMatch :
117
- mType = MatchType_REGEX_NO_MATCH
105
+ mType = cortex . MatchType_REGEX_NO_MATCH
118
106
default :
119
107
panic ("invalid matcher type" )
120
108
}
121
- req .Matchers = append (req .Matchers , & LabelMatcher {
109
+ req .Matchers = append (req .Matchers , & cortex. LabelMatcher {
122
110
Type : mType ,
123
111
Name : string (matcher .Name ),
124
112
Value : string (matcher .Value ),
125
113
})
126
114
}
127
115
128
- resp := & ReadResponse {}
116
+ resp := & cortex. ReadResponse {}
129
117
err := c .doRequest (ctx , "/query" , req , resp , false )
130
118
if err != nil {
131
119
return nil , err
@@ -154,10 +142,10 @@ func (c *IngesterClient) Query(ctx context.Context, from, to model.Time, matcher
154
142
155
143
// LabelValuesForLabelName returns all of the label values that are associated with a given label name.
156
144
func (c * IngesterClient ) LabelValuesForLabelName (ctx context.Context , ln model.LabelName ) (model.LabelValues , error ) {
157
- req := & LabelValuesRequest {
145
+ req := & cortex. LabelValuesRequest {
158
146
LabelName : string (ln ),
159
147
}
160
- resp := & LabelValuesResponse {}
148
+ resp := & cortex. LabelValuesResponse {}
161
149
err := c .doRequest (ctx , "/label_values" , req , resp , false )
162
150
if err != nil {
163
151
return nil , err
@@ -172,7 +160,7 @@ func (c *IngesterClient) LabelValuesForLabelName(ctx context.Context, ln model.L
172
160
173
161
// UserStats returns stats for the current user.
174
162
func (c * IngesterClient ) UserStats (ctx context.Context ) (* ingester.UserStats , error ) {
175
- resp := & UserStatsResponse {}
163
+ resp := & cortex. UserStatsResponse {}
176
164
err := c .doRequest (ctx , "/user_stats" , nil , resp , false )
177
165
if err != nil {
178
166
return nil , err
@@ -210,7 +198,7 @@ func (c *IngesterClient) doRequest(ctx context.Context, endpoint string, req pro
210
198
if err != nil {
211
199
return fmt .Errorf ("unable to create request: %v" , err )
212
200
}
213
- httpReq .Header .Add (userIDHeaderName , userID )
201
+ httpReq .Header .Add (cortex . UserIDHeaderName , userID )
214
202
// TODO: This isn't actually the correct Content-type.
215
203
httpReq .Header .Set ("Content-Type" , string (expfmt .FmtProtoDelim ))
216
204
httpResp , err := c .client .Do (httpReq )
0 commit comments