mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 13:44:05 -08:00
Fix InfluxDB retention policy usage in read adapter (#2781)
This commit is contained in:
parent
14eee34da3
commit
e0f046396a
|
@ -104,7 +104,7 @@ func (c *Client) Write(samples model.Samples) error {
|
||||||
func (c *Client) Read(req *remote.ReadRequest) (*remote.ReadResponse, error) {
|
func (c *Client) Read(req *remote.ReadRequest) (*remote.ReadResponse, error) {
|
||||||
labelsToSeries := map[string]*remote.TimeSeries{}
|
labelsToSeries := map[string]*remote.TimeSeries{}
|
||||||
for _, q := range req.Queries {
|
for _, q := range req.Queries {
|
||||||
command, err := buildCommand(q)
|
command, err := c.buildCommand(q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ func (c *Client) Read(req *remote.ReadRequest) (*remote.ReadResponse, error) {
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildCommand(q *remote.Query) (string, error) {
|
func (c *Client) buildCommand(q *remote.Query) (string, error) {
|
||||||
matchers := make([]string, 0, len(q.Matchers))
|
matchers := make([]string, 0, len(q.Matchers))
|
||||||
// If we don't find a metric name matcher, query all metrics
|
// If we don't find a metric name matcher, query all metrics
|
||||||
// (InfluxDB measurements) by default.
|
// (InfluxDB measurements) by default.
|
||||||
|
@ -143,9 +143,9 @@ func buildCommand(q *remote.Query) (string, error) {
|
||||||
if m.Name == model.MetricNameLabel {
|
if m.Name == model.MetricNameLabel {
|
||||||
switch m.Type {
|
switch m.Type {
|
||||||
case remote.MatchType_EQUAL:
|
case remote.MatchType_EQUAL:
|
||||||
from = fmt.Sprintf("FROM %q", m.Value)
|
from = fmt.Sprintf("FROM %q.%q", c.retentionPolicy, m.Value)
|
||||||
case remote.MatchType_REGEX_MATCH:
|
case remote.MatchType_REGEX_MATCH:
|
||||||
from = fmt.Sprintf("FROM /^%s$/", escapeSlashes(m.Value))
|
from = fmt.Sprintf("FROM %q./^%s$/", c.retentionPolicy, escapeSlashes(m.Value))
|
||||||
default:
|
default:
|
||||||
// TODO: Figure out how to support these efficiently.
|
// TODO: Figure out how to support these efficiently.
|
||||||
return "", fmt.Errorf("non-equal or regex-non-equal matchers are not supported on the metric name yet")
|
return "", fmt.Errorf("non-equal or regex-non-equal matchers are not supported on the metric name yet")
|
||||||
|
|
Loading…
Reference in a new issue