added the prometheus_remote_storage_remote_read_queries_total (#7328)

* added the prometheus_remote_storage_remote_read_queries_total query

Signed-off-by: njingco <jingco.nicole@gmail.com>

* adjusted the help label of remoteReadQueriesTotal

Signed-off-by: njingco <jingco.nicole@gmail.com>
This commit is contained in:
Nicole J 2020-06-03 10:30:52 -07:00 committed by GitHub
parent 18d9ebf0ff
commit 5e9bd17b1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -32,14 +32,27 @@ var remoteReadQueries = prometheus.NewGaugeVec(
[]string{remoteName, endpoint},
)
var remoteReadQueriesTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "remote_read_queries_total",
Help: "The total number of remote read queries.",
},
[]string{remoteName, endpoint},
)
func init() {
prometheus.MustRegister(remoteReadQueries)
prometheus.MustRegister(remoteReadQueriesTotal)
}
// QueryableClient returns a storage.Queryable which queries the given
// Client to select series sets.
func QueryableClient(c *Client) storage.Queryable {
remoteReadQueries.WithLabelValues(c.remoteName, c.url.String())
remoteReadQueriesTotal.WithLabelValues(c.remoteName, c.url.String())
return storage.QueryableFunc(func(ctx context.Context, mint, maxt int64) (storage.Querier, error) {
return &querier{
ctx: ctx,
@ -68,6 +81,9 @@ func (q *querier) Select(sortSeries bool, hints *storage.SelectHints, matchers .
remoteReadGauge.Inc()
defer remoteReadGauge.Dec()
remoteReadTotalCounter := remoteReadQueriesTotal.WithLabelValues(q.client.remoteName, q.client.url.String())
remoteReadTotalCounter.Inc()
res, err := q.client.Read(q.ctx, query)
if err != nil {
return nil, nil, fmt.Errorf("remote_read: %v", err)