[SOLVED] REST API: "Persistence service not modifiable: influxdb"

Hi. I’m trying to manually write data to influxdb.
When trying to insert data with REST, I get the following error:
“Persistence service not modifiable: influxdb”



I have tried unsuccessfully to figure out how to write data directly to influxdb with curl.
Is it some permissions problem?

up!

It seems you tried it with no success.

what do you mean? I can query data but can’t write.
Item should be set up ok, with persistence. Time format should be ok.

Is that all you want? To write directly to influxdb with curl? If so, see the InfluxDB documentation. There are examples here

Or do you need to make this work through the REST API?

At the moment method is not so important as long as I will get values to database.
Next step would be to automate value writing with some rule.

I checked those examples but didn’t succeed.
example: Writing data using the HTTP API

curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'

My curl test, with and without password:

Is InfluxDB running at port 8086? Your screen shot says curl can’t connect. That’s probably not a permissions problem - that’s showing the influxdb server isn’t running on port 8086. What does this show?

ps -ef | grep -i influx

Did you happen to forget to start the influxdb server or change the port it is running on?

It should be running and I haven’t changed the port.


All other persisted data is being stored which openhab manages. And I can see it in grafana and via REST.
What I can’t is /write and /put.

I assume that in order to write some data to your db you need to authenticate first ? Have you configured some users with write permissions ? I do not see in your curl that you try to authenticate

Check this link in the ‘Authenticate with the HTTP API’ section

did you try the curl command to 127.0.0.1? Your screen shot shows the curl going to 192.168.50.30 - is that the correct address? And the influxdb.conf does show port 8086? There’s something obvious that is wrong. Just after you try the curl command, do a tail of /var/log/syslog. It should show something.

192.168.50.30 is my openHAB server and influxdb.
I have used curl (git.bash) via another PC so I can’t use 127.0.0.1 there.

influxdb.cfg

url=http://localhost:8086
user=openhab
password=openhabian
db=openhab_db
retentionPolicy=autogen

influxdb.conf

[http]
  # Determines whether HTTP endpoint is enabled.
  enabled = true

  # Determines whether the Flux query endpoint is enabled.
  # flux-enabled = false

  # The bind address used by the HTTP service.
  bind-address = "localhost:8086"

  # Determines whether user authentication is enabled over HTTP/HTTPS.
  auth-enabled = false


endpoint enabled=true, I un-commented myself as did I change auth-enabled=false.
both of those recently after errors.

/var/log/syslog:
all similar log entries

Mar 22 18:21:51 openHABianPi influxd[511]: [httpd] 127.0.0.1 - openhab [22/Mar/2019:18:21:51 +0200] "POST /write?consistency=one&db=openhab_db&p=%5BREDACTED%5D&precision=n&rp=autogen&u=openhab HTTP/1.1" 204 0 "-" "okhttp/2.4.0" 99c1e48c-4cbe-11e9-8505-b827eb81a147 10121

And I have tried with authentication as well (tried different syntax versions). Still the same error:

user openhab doesn’t need to be admin to write to influxdb, does it?
image

Try running the curl command on the server that is running Influxdb. Do you have a firewall enabled on it that might be blocking access?

Your syslog entry shows success with a “204”. Do you have any entries at exactly the same time that you try to run the curl command? I don’t think you are even connecting to the InfluxDB server, so the permissions on the database are irrelevant. Otherwise you’d see an error in the syslog. You wouldn’t get connection refused. Something is blocking access entirely from your test PC. That’s why I think you should run the curl locally to see what it does.

The “bind-address” is your problem. Your InfluxDB server only accepts requests from the machine it runs on.

Try 0.0.0.0:8086 (or even keep it on :8086). After getting things to work, you can design a properly secured installation.

That was it!
Thank you!
I’m now able to write do database.
Although I still haven’t figured out the correct timestamp syntax.
If I write data without time specified - everything works.
If I try to set custom timestamp then it fails.

With Epoch time format it works.
With RFC3339 time format it doesn’t.


I’m having the same “Persistence service not modifiable” error when I try to test writing data to the influxdb persistence service using the REST API developer tool in the OpenHAB 3 UI.

I can retrieve data fine and my influxdb.conf hasn’t modified the bind-address so I believe it is defaulted to :8086. The influx database is running on my NAS whereas OpenHAB is on its own Raspberry Pi.

It looks from the REST tool as though it is sending an authorisation token so I’m stuck with what might be wrong.