Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telegraf user requires ALL PRIVILEGES else it gets "not authorized to execute statement CREATE DATABASE" #2496

Closed
Robpol86 opened this issue Mar 6, 2017 · 8 comments · Fixed by #3941
Assignees
Labels
area/influxdb bug unexpected problem or unintended behavior
Milestone

Comments

@Robpol86
Copy link
Contributor

Robpol86 commented Mar 6, 2017

Bug report

Telegraf (master @ 1074464) using a user with only WRITE privileges on an already-existing "telegraf" database cannot add data due to this error:

2017-03-06T05:10:22Z E! Database creation failed: Response Error: Status Code [403], expected [200], [error authorizing query: telegraf_filesrv not authorized to execute statement 'CREATE DATABASE telegraf', requires admin privilege]

This worked back in July 2016 when I last setup InfluxDB+Telegraf but since then it appears CREATE DATABASE is run every time by Telegraf. The only way to let Telegraf write to my database is to GRANT ALL TO telegraf_filesrv.

Perhaps #2231 ran into this but failed to include any details? I wouldn't mind having such a configuration option in Telegraf.

Relevant telegraf.conf:

[[outputs.influxdb]]
  urls = ["https://filesrv.rob86.net:8086"] # required
  database = "telegraf" # required
  retention_policy = ""
  write_consistency = "any"
  timeout = "5s"
  username = "telegraf_filesrv"
  password = "REPLACE_ME"
  ssl_ca = "/etc/filesrv.rob86.net.cert.pem"

System info:

Telegraf vdev-72-g1074464 (git: master 1074464)
Connected to https://localhost:8086 version 1.2.0
Linux filesrv.rob86.net 4.9.10-200.fc25.x86_64 #1 SMP Wed Feb 15 23:28:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Fedora release 25 (Twenty Five)

Steps to reproduce:

CREATE DATABASE telegraf
CREATE USER telegraf_filesrv WITH PASSWORD 'REPLACE_ME'
GRANT WRITE ON telegraf TO telegraf_filesrv

Expected behavior:

Telegraf is able to add metrics to the database with only WRITE privileges if the "telegraf" database has already been created.

Actual behavior:

Telegraf fails to execute query to add data due to no permission to run "CREATE DATABASE telegraf"

Feature Request

Add option to prevent Telegraf from trying to execute "CREATE DATABASE" and just write data.

Use case:

Allows Telegraf users to be locked down to just WRITE vs ALL PRIVILEGES.

@sparrc sparrc added this to the 1.3.0 milestone Mar 6, 2017
@sparrc
Copy link
Contributor

sparrc commented Mar 6, 2017

sure, seems reasonable

@WaterByWind
Copy link

This seems perhaps also related to #1655

I haven't found that further writes are broken if the database already exists despite the CREATE failure, but it does create a log entry each time Telegraf starts.

@samcraigjohnson
Copy link

Hello, is this being actively worked on? I would be happy to implement this as it is a blocker to some work I am doing.

@danielnelson
Copy link
Contributor

@sjohnson540 My understanding of the current state of this issue is that Telegraf always tries to create a database on startup, but if it fails then it will continue and write successfully. I would still like to add an option to not create the database but it shouldn't affect operation.

@samcraigjohnson
Copy link

@danielnelson oh interesting, I see that now, sorry for the confusion.

@danielnelson danielnelson added this to the 1.6.0 milestone Mar 20, 2018
@danielnelson danielnelson self-assigned this Mar 20, 2018
@JeffAshton
Copy link
Contributor

@danielnelson Are you going to do the work for this one? I have a interest. :)

image

@danielnelson
Copy link
Contributor

Yes, should be ready in the next few days.

@danielnelson
Copy link
Contributor

You can now use skip_database_creation = true in the influxdb output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/influxdb bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants