Influxdb v1 compatibility 501

I am trying to use v1 compatibility mode against an influx cloud instance and I get a 501 for /query. I have followed all instructions listed here InfluxDB 1.x compatibility API | InfluxDB Cloud Documentation to query with a token. I know that my token is correct as I can use it against other endpoints. Additionally if I change my token I get a 401. This implies I have a correct token getting passed the auth, but then I get a 501 from query endpoint.

curl -v --get "" \
  --header "Authorization: Token <token>" \
  --header 'Content-type: application/json' \
  --data-urlencode "db=metrics" \
  --data-urlencode "q=SELECT * FROM cpu_usage"

results in

< HTTP/2 501 
< date: Tue, 04 Apr 2023 23:49:56 GMT
< content-type: application/json; charset=utf-8
< content-length: 54
< request-id: bd76494b5aae2bf4757fdc20c522aefb
< trace-id: 59d15201432bbc1d
< trace-sampled: false
< vary: Accept-Encoding
< x-platform-error-code: not implemented
< x-request-id: bd76494b5aae2bf4757fdc20c522aefb
< strict-transport-security: max-age=15724800; includeSubDomains
< x-influxdb-request-id: bd76494b5aae2bf4757fdc20c522aefb
< x-influxdb-build: Cloud

I have confirmed the metrics dbrp is setup

influx v1 dbrp list                                                                         
ID			Database	Bucket ID		Retention Policy	Default	Organization ID
0afe7de4228aa000	metrics		<removed>	default-rp		true	<removed>

also of note, if I use the cli with v1 shell, I get a 501 with every query as well

Hello @connr,
If you’re using InfluxDB Cloud I recommend just querying with SQL directly (now supported in InfluxDB Cloud).
Would that solve your problems?

Or do you need to use the V1 compatibility for something specific?

Hey there!
Just ran into this post here since I’m facing the same issue. A little more context:

I had to migrate to Cloud instance Now the new cloud and database architecture does not seem to support InfluxQL in Grafana any longer. In my previous cloud instance I was able to run Grafana with InfluxQL by running through the docs around DRBP mapping and token based authentication in Grafana. Same thing now gives me error 501. Like mentioned by connr, changing the token shows error 401…

Two reasons for me to stay with InfluxQL are:

  1. I have a quite large on-prem Raspberry Setup of Influx&Grafana, my cloud instance is supposed to give me a lightweight solution accessible from everywhere, 30 days data retention is fine for that. So I don’t want to re-create all dashboards in another query language. I used to copy/paste the json statements from one instance to the other for all panels with just minor adjustments on the datapoint names,…

  2. I was unable to install the FlightSQL plugin in my Grafana cloud instance, telling me that my Grafana (cloud) version isn’t compatible with the plugin (or vice versa).

Please check if there’s a possibility to implement InfluxQL for the new instances. Or if not, does that mean InfluxQL is a dead end now?

Thanks and have a good day!

I’m facing the same issue.

I have various queries done with QL and changing to flightSQL is not so straigthforward.

Any news?

Yesterday I realized that my InfluxQL queries work again in Grafana!
I don’t know the exact cut-in date for this, I didn’t check my Grafana instance lately, but kept writing into Influx. However I can’t party just yet: simple queries work well, whereever I use math or aggregations, I get error messages like this:

InfluxDB: InfluxDB Error: rpc error: code = InvalidArgument desc = Error while planning query: Error during planning: Invalid function 'moving_average'

So all expressions like moving_average, difference, integral,… don’t work.

Hopefully just a hickup along the way to fully support InfluxQL…

In my case it worked for the past 2 days and now it’s not working again :frowning:

There’s been a short outage, but I’m back to the state I described above where basic queries work but no math or aggregations…

JSON to SQL: If your data is initially in JSON format, you might need to convert it to SQL in order to query it effectively in certain contexts. You can use a library such as pandas in Python to read in JSON data and convert it to a DataFrame, which can then be queried similarly to a SQL table. Alternatively, you might use a tool like jq to manipulate JSON data directly.

SQL to JSON: The reverse conversion, from SQL to JSON, could be handled in a similar manner. After querying your data in SQL, you can convert the results back into JSON format for further processing or for returning as part of an API response.

JSON to Python: If you’re working in Python, converting JSON to Python objects is straightforward with the json module in the Python standard library. You can convert JSON data to a Python dictionary, which can then be manipulated directly or converted to other formats as needed.

Offloading computation: If you’re looking to offload some computational work to an external component, there are several approaches you might consider. One approach is to use a distributed computing framework like Apache Spark, which can handle large-scale data processing tasks across a cluster of machines. Another approach is to use a service like AWS Lambda to run code in response to events, which can be useful for handling sporadic or unpredictable computational workloads.

Building an API: If you’re looking to build an API that can handle these conversions and computations, a framework like Flask or FastAPI in Python could be a good choice. These frameworks provide tools for handling HTTP requests and responses, and can easily be extended with additional libraries or modules to handle data processing tasks.

Token security: In terms of securing API tokens in InfluxDB, the InfluxDB v1 compatibility API documentation recommends using the Token authentication scheme to authenticate to the InfluxDB API. In your API requests, send an Authorization header. For the header value, provide the word Token followed by a space and an InfluxDB API token. The word Token is case-sensitive1.

DBRP metrics setup: If you’re using InfluxDB’s v1 compatibility API, you can use the /query endpoint to query your data in a v1-compatible format. This includes specifying the bucket to query (equivalent to a database in InfluxDB v1 terminology) and the InfluxQL query to run. However, as you’ve experienced, some users have reported issues with receiving a 501 status code when attempting to use this endpoint12.

import “json”

data = "
"name": "John",
"age": 30,
"city": "New York"

jsonObj = json.parse(data: data)

// Accessing values in the JSON object
name =
age = jsonObj.age
city =

// Outputs: {name: “John”, age: 30, city: “New York”}
Unfortunately, InfluxDB’s Flux does not have built-in support for SQL or Python conversion.

For SQL, Flux is intended to replace SQL-like query syntax, and the InfluxDB team does not provide a SQL-to-Flux conversion tool. The main guidance is to familiarize yourself with Flux syntax and functions, and to rewrite your queries in Flux.

For Python, you might want to look into the InfluxDB-Python client library, which allows you to interact with InfluxDB directly from Python. This includes executing Flux queries and processing the results in Python.

In terms of offloading computation, Flux has a number of built-in functions for performing computations directly on your data as part of the query process. For more complex computations, you might consider using a separate service or application to perform the computation after retrieving the data from InfluxDB.

To handle token security in InfluxDB, you can create and manage tokens in the InfluxDB user interface or by using the InfluxDB API. Tokens can be scoped to provide different levels of access to your data.

Regarding DBRP (Database and Retention Policy) mappings, in Flux you can use the from() function to specify the bucket (which is associated with a specific DBRP mapping) to query. Here’s an example:

from(bucket: “my-bucket”)
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == “my-measurement”)

This is chatGPT 4 with bing I’m not saying saying of this is true jus trying to learn and help