Influxdb password max and Corlysis

Hi michal,

There are a couple of users here that are interested in using your service. IoTaWatt supports direct uploading to influxDB, but the differences between influx and your product are restricting use of that support.

I don’t know yet if the native influx POST upload is going to work because we have not been able to get past the initial query to determine where to begin. IoTaWatt saves all of it’s measurements, and when beginning to upload to influx, checks the time of the last uploaded measurement. It then resumes uploads from that time so that the data is continuous even if there was a communication or server interruption. That query is currently a POST query. It’s possible to change to a GET, but there are a couple of other issues:

influxDB accepts an authorization header with the user and password. This works fine with influx. Corlysis does not seem to recognize the base64 encoded basic authorization header and seems to require that the password is sent plaintext in the very exposed GET URL.

Corlysis seems to require specific syntax in the key value field. Specifically, IoTaWatt always sends key values as single quoted strings. They do not appear to be acceptable to Corlysis.

These query issues need to be resolved in order to be able to move on to the measurement write POSTS, which will probably work (maybe problems with quoted key values).

Bottom line is that this is a hybrid protocol that isn’t very well documented, so there is a need to figure out what’s different. That users are successfully uploading with other software isn’t the issue. IoTaWatt users are successfully uploading to influx. Reconciling the differences is what’s needed and supporting features like POST query and authorization headers would go a long way to making influx support more compatible with your product.

The rookie restrictions on your new account have been removed.

we SUPPORT base64 encoded basic authorization header! We do not send password by plaintext!!! Our recommendation is to use HTTPS and “basic authorization” as I wrote:
curl -G 'CORLYSIS_URL/query?db=emon' -u token:AABBCC --data-urlencode "q=select last(value) from Volt"

It is absolutely clear and correct!

We use standard line protocol:InfluxDB line protocol tutorial | InfluxDB OSS v1 Documentation
So “solar value=2944.6 1523810195” will works.

I think that there is only one issue and that is that you have to change query from HTTP POST to HTTP GET and thats all.

OK, you are right about the authorization. Turns out the header wasn’t being sent in the conversion to GET. Fixed that, and so here’s where it’s at:

Sending this GET request:

corlysis.com:8087/query?&db=iotadb&epoch=s&q=SELECT%20LAST(value)%20FROM%20voltage%20WHERE%20unit=iotatest

and get back this response with code 400

{“error”:“missing required parameter "q"”}

This works with influx, so if you could take a look and see if you can spot something wrong with the “q” parameter. Note: when it works with influx, it’s the payload of a POST transaction and not URL encoded. In order to append the query to the GET URL, it was necessary to convert spaces to %20. That seems to be working OK.

there is a mistake. The correct query is:
curl -G 'https://corlysis.com:8086/query?db=DB_NAME&q=select%20last%28value%29%20from%20meas_test' -u token:AAAA

you can use e.g. https://www.urlencoder.io/ to convert your query to the URL encoded

for more info please read the InfluxDB doc: Querying data with the InfluxDB API | InfluxDB OSS 1.7 Documentation
To perform a query send a GET request to the /query endpoint, set the URL parameter db as the target database, and set the URL parameter q as your query.

HTTP GET request

http://corlysis.com:8087/query?db=iota&epoch=s&q=SELECT LAST(value) FROM Volt

works

No “urlencodifiying” needed

So Corlysis wants the query as a parameter.

in Postman…

IoTaWatt cannot do HTTPS. That’s just not going to happen. So port 8087 seems to be the correct port for HTTP.

IoTaWatt doesn’t use curl. It builds the URL in c++.

These are the differences that I see between what I posted and the above

  • IoTaWatt also sends &epoch=s
  • The IoTaWatt uses capitalized keywords
  • The IoTaWatt is using a where clause to discriminate by key value
  • Curl urlencodes the parenthesis in LAST(value)

If you see anything else, please point it out.

It’s important to note that the IoTaWatt query does work fine with influx, but I’m open to someone pointing out where it nevertheless violates the influx query specification.

I’ll try urlencoding the parenthesis.

The where clause is an important part of how IoTaWatt maintains its upload context, so removing that is not on the table.

I have tried going lower case on the keywords with no success.

I don’t believe the epoch is an issue, but I will see what happens if I remove it. Potentially the returned time of the last measurement requested will be in milliseconds, and that would be a compatibility issue for bona-ride influxDB users.

@michal, @Bali

I did a little more research and found that the problem appears to be the where clause. When I remove it, the query works fine.

The good news is that once past the query, data writes work fine.

The bad news is that, as mentioned above, the where clause to disambiguate measurements with the same name from different sources must be supported. You can read more about how the wrere clause is used in queries here: https://docs.influxdata.com/influxdb/v1.7/query_language/data_exploration/#the-basic-select-statement

The urlencoded parenthesis doesn’t seem to matter, and the epoch doesn’t seem to be a problem, nor the capitalized keywords.

Revisiting the documentation is always a good idea. I found this:

You may also use a POST request by sending the same parameters either as URL parameters or as part of the body with application/x-www-form-urlencoded .

Which is what IoTaWatt does successfully using the bona-fide influx interface.

While we seem to be zeroing in on the incompatibilities, I want to caution the participants that I would be in no hurry to change the query over to use GET, for two reasons:

  1. The current POST works fine and exposes less data through the URL.
  2. There are hundreds of satisfied users relying on the current support and using many varied installations of influxDB. A change like this requires a lot of testing and field trials to avoid disruption.

That said, simply adding support for POST in Corlysis should be relatively straightforward, and IMO a better solution.

I have not reverted back to post and tried without the where clause, so I’ll reserve final word until I try that. It could be that the issue is only the where clause.

UPDATE: Tried using POST without the where clause. Get the missing q message.

@overeasy

There are many reasons why the world (and influxdb) is moving away away from GET, least of all because data sent is part of the URL.

Your excellent asyncHTTPrequest would need some rewriting to accommodate this service. I will fork it and see if I can find time to add.

IoTaWatt does use asyncHTTPrequest to send data to influx, and it was easy to change to GET (although there was a sequencing problem with the authorization header). What in particular do you think needs to be changed here?

As it is influxDB.cpp and asyncHTTPrequest send

reqData.printf_P(PSTR("db=%s&epoch=s&q=SELECT LAST(%s) FROM %s"), influxDataBase, influxVarStr(influxFieldKey, script).c_str(), influxVarStr(influxMeasurement, script).c_str());

as a body. Corlysis wants the GET query as parameter.

I understand. What you are looking at is the released code. In the tests that I did, I added the query to the URL. The problem seems to be the where clause. Without that, my expanded GET URL worked fine.

Not too clear on what kind of change would facilitate marrying the URL and Query in asyncHTTPrequest.

I looked over your PR for absolute URL, and will have to look further at both the change and the implementation. My world is getting more complicated with so many dependent users. I’m afraid to break something.

:grin: Not a part of corlysis

Thank you to @overeasy, @Bali, and @michal (Corlysis) to work with other to understand the issue and work towards a solution.

As someone who is new to Iotawatt, but already looking to install my third unit, I love how supportive this community is.

-JR