Skip to content

InfluxQLQueryAPI isn't compatible with InfluxDB 1.8+ #458

@btasker

Description

@btasker

In #365 / #366 new functionality was added to allow InfluxQL queries to be run against the compatibility API using the client.

However, this change is not compatible with Influx 1.8.x because of an implementation detail in InfluxQLQueryService

That interface does the following

	@Headers({ "Accept:application/csv", "Content-Type:application/vnd.influxql" })
	@POST("query")
	Call<ResponseBody> query(
			@Body String query,
			@Nonnull @Query("db") String db,
			@Query("rp") String retentionPolicy,
			@Query("epoch") String epoch,
			@Header("Zap-Trace-Span") String zapTraceSpan
	);

This sends the InfluxQL query as the request body, with a content-type of application/vnd.influxql

This is broadly equivalent to doing

curl -H "Authorization: Token $MYTOK" -d "select last(download) from internet_speed limit 1" -v "http://192.168.3.5:18086/query?db=telegraf" -H "Content-Type: application/vnd.influxql"

However, InfluxDB 1.8.x does not support this, and requires that the query be sent with the query in q

ben@bumblebee:~$ curl -H "Authorization: Token $MYTOK" -d "select last(download) from internet_speed limit 1" -v "http://192.168.3.84:8086/query?db=telegraf" -H "Content-Type: application/vnd.influxql"
*   Trying 192.168.3.84:8086...
* Connected to 192.168.3.84 (192.168.3.84) port 8086 (#0)
> POST /query?db=telegraf HTTP/1.1
> Host: 192.168.3.84:8086
> User-Agent: curl/7.81.0
> Accept: */*
> Authorization: Token <redacted>
> Content-Type: application/vnd.influxql
> Content-Length: 49
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 400 Bad Request
< Content-Type: application/json
< Request-Id: 3775f635-5456-11ed-8071-0242ac130002
< X-Influxdb-Build: OSS
< X-Influxdb-Error: missing required parameter "q"
< X-Influxdb-Version: 1.8.10
< X-Request-Id: 3775f635-5456-11ed-8071-0242ac130002
< Date: Tue, 25 Oct 2022 11:14:39 GMT
< Content-Length: 45
< 
{"error":"missing required parameter \"q\""}

2.x can support either format, so it would probably make most sense to adjust the interface to send a form-encoded request body.

Steps to reproduce:
List the minimal actions needed to reproduce the behavior.

  1. Run InfluxDB 1.8.10
  2. Use getInfluxQLQueryApi() to get the API
  3. Run an InfluxQL query
  4. Receive {"error":"missing required parameter \"q\""}

Expected behavior:
The query should run

Actual behavior:
The query is not run

Specifications:

  • Client Version: 6.6.0
  • InfluxDB Version: 1.8.10
  • JDK Version: Any
  • Platform: Any

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions