influxdb icon indicating copy to clipboard operation
influxdb copied to clipboard

Retention policy parameter ignored in queries?

Open paulgoldbaum opened this issue 11 years ago • 5 comments

Using master:

curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE test_database"
curl -G http://localhost:8086/query --data-urlencode "q=CREATE RETENTION POLICY custom_retention_policy ON test_database DURATION 1w REPLICATION 1"

curl -XPOST "http://localhost:8086/write?db=test_database&rp=custom_retention_policy" --data-binary "cpu value=61"

Issuing a query like this:

curl -G http://localhost:8086/query --data-urlencode "q=SELECT * FROM cpu" --data-urlencode "db=test_database" --data-urlencode "rp=custom_retention_policy"

returns an empty result.

On the other hand:

curl -G http://localhost:8086/query --data-urlencode "q=SELECT * FROM custom_retention_policy.cpu" --data-urlencode "db=test_database"

returns the expected result.

Am I missing something?

paulgoldbaum avatar Oct 12 '15 15:10 paulgoldbaum

There is no support for specifying the retention policy as a URL query parameter. Only your second example is valid.

On Monday, October 12, 2015, Paul Goldbaum [email protected] wrote:

Using master:

curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE test_database" curl -G http://localhost:8086/query --data-urlencode "q=CREATE RETENTION POLICY custom_retention_policy ON test_database DURATION 1w REPLICATION 1"

curl -XPOST "http://localhost:8086/write?db=test_database&rp=custom_retention_policy" --data-binary "cpu value=61"

Issuing a query like this:

curl -G http://localhost:8086/query --data-urlencode "q=SELECT * FROM cpu" --data-urlencode "db=test_database" --data-urlencode "rp=custom_retention_policy"

returns an empty result.

An the other hand:

curl -G http://localhost:8086/query --data-urlencode "q=SELECT * FROM custom_retention_policy.cpu" --data-urlencode "db=test_database" --data-urlencode "custom_retention_policy"

return the expected result.

Am I missing something?

— Reply to this email directly or view it on GitHub https://github.com/influxdb/influxdb/issues/4413.

otoolep avatar Oct 12 '15 15:10 otoolep

@otoolep, ok that clears it up :) I'm not sure if I misunderstood the documentation then. From https://influxdb.com/docs/v0.9/query_language/query_syntax.html#retention-policy

Retention Policy
Use the rp=<retention_policy> query string parameter to supply a target retention policy for the query. If not specified, the default retention policy for the target database will be used.

is this outdated information?

paulgoldbaum avatar Oct 12 '15 15:10 paulgoldbaum

Well, that is news to me. Let me double check the code for you. I may be mistaken.

On Monday, October 12, 2015, Paul Goldbaum [email protected] wrote:

@otoolep https://github.com/otoolep, ok that clears it up :) I'm not sure if I misunderstood the documentation then. From https://influxdb.com/docs/v0.9/query_language/query_syntax.html#retention-policy

Retention Policy Use the rp=<retention_policy> query string parameter to supply a target retention policy for the query. If not specified, the default retention policy for the target database will be used.

is this outdated information?

— Reply to this email directly or view it on GitHub https://github.com/influxdb/influxdb/issues/4413#issuecomment-147445394.

otoolep avatar Oct 12 '15 16:10 otoolep

The documents are incorrect. As I originally stated rp is only supported as a query parameter for writes, not queries.

I will open a ticket regarding the docs.

otoolep avatar Oct 12 '15 16:10 otoolep

Got it. Thanks for the help!

paulgoldbaum avatar Oct 12 '15 16:10 paulgoldbaum