From e0f046396a163913ee3c40030a7f42fbdcf1cbd5 Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Mon, 29 May 2017 16:24:24 +0200 Subject: [PATCH] Fix InfluxDB retention policy usage in read adapter (#2781) --- .../remote_storage_adapter/influxdb/client.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/documentation/examples/remote_storage/remote_storage_adapter/influxdb/client.go b/documentation/examples/remote_storage/remote_storage_adapter/influxdb/client.go index edd204abc..9b446a12c 100644 --- a/documentation/examples/remote_storage/remote_storage_adapter/influxdb/client.go +++ b/documentation/examples/remote_storage/remote_storage_adapter/influxdb/client.go @@ -104,7 +104,7 @@ func (c *Client) Write(samples model.Samples) error { func (c *Client) Read(req *remote.ReadRequest) (*remote.ReadResponse, error) { labelsToSeries := map[string]*remote.TimeSeries{} for _, q := range req.Queries { - command, err := buildCommand(q) + command, err := c.buildCommand(q) if err != nil { return nil, err } @@ -134,7 +134,7 @@ func (c *Client) Read(req *remote.ReadRequest) (*remote.ReadResponse, error) { 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)) // If we don't find a metric name matcher, query all metrics // (InfluxDB measurements) by default. @@ -143,9 +143,9 @@ func buildCommand(q *remote.Query) (string, error) { if m.Name == model.MetricNameLabel { switch m.Type { 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: - from = fmt.Sprintf("FROM /^%s$/", escapeSlashes(m.Value)) + from = fmt.Sprintf("FROM %q./^%s$/", c.retentionPolicy, escapeSlashes(m.Value)) default: // 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")