6
6
"github.com/cortexproject/cortex/pkg/ingester/client"
7
7
"github.com/cortexproject/cortex/pkg/util"
8
8
"github.com/go-kit/kit/log/level"
9
- "github.com/prometheus/common/model"
10
9
"github.com/prometheus/prometheus/storage"
11
10
)
12
11
@@ -53,14 +52,8 @@ func RemoteReadHandler(q storage.Queryable) http.Handler {
53
52
return
54
53
}
55
54
56
- matrix , err := seriesSetToMatrix (seriesSet )
57
- if err != nil {
58
- errors <- err
59
- return
60
- }
61
-
62
- resp .Results [i ] = client .ToQueryResponse (matrix )
63
- errors <- nil
55
+ resp .Results [i ], err = seriesSetToQueryResponse (seriesSet )
56
+ errors <- err
64
57
}(i , qr )
65
58
}
66
59
@@ -82,26 +75,26 @@ func RemoteReadHandler(q storage.Queryable) http.Handler {
82
75
})
83
76
}
84
77
85
- func seriesSetToMatrix (s storage.SeriesSet ) (model. Matrix , error ) {
86
- result := model. Matrix {}
78
+ func seriesSetToQueryResponse (s storage.SeriesSet ) (* client. QueryResponse , error ) {
79
+ result := & client. QueryResponse {}
87
80
88
81
for s .Next () {
89
82
series := s .At ()
90
- values := []model. SamplePair {}
83
+ samples := []client. Sample {}
91
84
it := series .Iterator ()
92
85
for it .Next () {
93
86
t , v := it .At ()
94
- values = append (values , model. SamplePair {
95
- Timestamp : model . Time ( t ) ,
96
- Value : model . SampleValue ( v ) ,
87
+ samples = append (samples , client. Sample {
88
+ TimestampMs : t ,
89
+ Value : v ,
97
90
})
98
91
}
99
92
if err := it .Err (); err != nil {
100
93
return nil , err
101
94
}
102
- result = append (result , & model. SampleStream {
103
- Metric : util . LabelsToMetric (series .Labels ()),
104
- Values : values ,
95
+ result . Timeseries = append (result . Timeseries , client. TimeSeries {
96
+ Labels : client . FromLabelsToLabelAdapaters (series .Labels ()),
97
+ Samples : samples ,
105
98
})
106
99
}
107
100
0 commit comments