|
|
|
@ -16,14 +16,30 @@ package remote
|
|
|
|
|
import ( |
|
|
|
|
"context" |
|
|
|
|
|
|
|
|
|
"github.com/prometheus/client_golang/prometheus" |
|
|
|
|
"github.com/prometheus/common/model" |
|
|
|
|
"github.com/prometheus/prometheus/pkg/labels" |
|
|
|
|
"github.com/prometheus/prometheus/storage" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
var remoteReadQueries = prometheus.NewGaugeVec( |
|
|
|
|
prometheus.GaugeOpts{ |
|
|
|
|
Namespace: namespace, |
|
|
|
|
Subsystem: subsystem, |
|
|
|
|
Name: "remote_read_queries", |
|
|
|
|
Help: "The number of in-flight remote read queries.", |
|
|
|
|
}, |
|
|
|
|
[]string{"client"}, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func init() { |
|
|
|
|
prometheus.MustRegister(remoteReadQueries) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// QueryableClient returns a storage.Queryable which queries the given
|
|
|
|
|
// Client to select series sets.
|
|
|
|
|
func QueryableClient(c *Client) storage.Queryable { |
|
|
|
|
remoteReadQueries.WithLabelValues(c.Name()) |
|
|
|
|
return storage.QueryableFunc(func(ctx context.Context, mint, maxt int64) (storage.Querier, error) { |
|
|
|
|
return &querier{ |
|
|
|
|
ctx: ctx, |
|
|
|
@ -49,6 +65,10 @@ func (q *querier) Select(p *storage.SelectParams, matchers ...*labels.Matcher) (
|
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
remoteReadGauge := remoteReadQueries.WithLabelValues(q.client.Name()) |
|
|
|
|
remoteReadGauge.Inc() |
|
|
|
|
defer remoteReadGauge.Dec() |
|
|
|
|
|
|
|
|
|
res, err := q.client.Read(q.ctx, query) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|