Influxdb v3 serverless query with curl

I am new and try something simple via a curl query on the data. The connection seems to work (return code 200) but it indicates that the database is not found. Is RP the reason? I have it on 30 days via the UI, but your docs are not clear on the rp syntax and whether is is really needed in a HTTP Get. Appreciate some guidance.

@Paul_Verhoef Are you using InfluxQL or SQL? And do you have an example of your curl command?

thanks for your help Scott. I get the same message in testing access from Grafana: database not found.

curl as follows:
curl --get
–header “Authorization: Token MY_API_TOKEN”
–header ‘Content-type: application/json’
–data-urlencode “db=PWtest1”
–data-urlencode “q=SELECT * FROM home”

There is data in the bucket and I can query it from the InfluxDB UI.

I have set the RP to 30 days (via the InfluxDB UI) but the RP mechanisms are unclear to me (eg what is a RP NAME? and what is the RP syntax?). I thought that, if it was set via the UI, then there is no need to reference it in the query (but maybe I am wrong)

sorry, with regard to your first question: SQL as the UI seems to only allow that (correct?)

Yeah, the UI supports only SQL. The HTTP API only supports InfluxQL (it’s essentially a compatibility API that enables support for existing InfluxDB clients). InfluxDB v3 SQL queries are executed using a gRPC API using the Flight protocol. There isn’t currently a way to execute SQL queries via HTTP(S), but it is in the works.

InfluxQL was built for InfluxDB v1 which had databases and retention policies as separate components in the data structure. In InfluxDB v2 and InfluxDB Cloud Serverless, databases are combined into a single unit, “bucket.” To query a bucket with InfluxQL, InfluxDB needs to map InfluxQL DB/RP combinations to a bucket. In some cases, InfluxDB Cloud Servleress automatically creates a DBRP mapping when creating a bucket, but it may not have in your case. Here’s some more information about DBRP mappings.

If the DBRP mappings are in place, your query should work, but you may need to specify the rp query parameter. Try this:

curl --get \
--header "Authorization: Token MY_API_TOKEN" \
--header 'Content-type: application/json' \
--data-urlencode "db=PWtest1" \
--data-urlencode "rp=autogen" \
--data-urlencode "q=SELECT * FROM home"

thanks, but…no result. I also created a new bucket (same RP of 30 days), same result. Would you have any further ideas? Or…can you test my buckets from your side and see what it gives?

@Paul_Verhoef Unfortunately (and fortunately) I don’t have any kind of special access to users’ organizations. Do you happen to have the v2 influx CLI installed? If so, I think you should be able to both view existing DBRP mappings and create new ones.

ssue solved. The name of the bucket needs to take in the “retention policy name” in the format: “NAME”/“RP” eg test/7d . Then in the http url include db=test&rp=7d.

Please note that writing measurements with a different RP to the same bucket will cause these to be accessible under a separate bucket name e.g test/30d

A few issues:

  • the documentation is not clear on this (in particular the examples)
  • the “retention policy name” is not a name but a formatted retention length indicator (a number followed by a letter eg 7 and d for days)

Hopes this is of use :slight_smile: