influxdata / ui

UI for InfluxDB
95 stars 42 forks source link

error generating telegraf token #577

Open russorat opened 3 years ago

russorat commented 3 years ago

To repro:

  1. in cloud, load this template through the UI: https://github.com/influxdata/community-templates/blob/master/raspberry-pi/raspberry-pi-system.yml
  2. then go to the telegrafs page and click "setup instructions" on the telegraf config
  3. Click generate token, and see the error message

expected behavior:

  1. if possible, generate the token and insert it into the script
  2. if not possible, provide a better error message letting the user know how to fix.

i tried to edit the telegraf config to have an explicit bucket instead of an env variable, but that didn't help either.

image

timhallinflux commented 3 years ago

Error message could be enriched to highlight the specific problem. Currently, it is too generic to figure out how to resolve or even where to look.

jrenee42 commented 3 years ago

@timhallinflux i'm looking at it now. the bucket for that template is not there at all. it's an NPE on the bucket. i will definitely enrich the error message; and look at the template config right now.

timhallinflux commented 3 years ago

yeah...when the template is imported, it is using an environment variable to pick-up the bucket.

However, we recently introduced a capability to edit the telegraf config from the UI. I edited the config to supply the specific bucket that I wanted to use.

I think there are potentially a few possible scenarios here to address that, but open to collaborating on the options further: 1) if there is no bucket specified (like in this case) -- when the setup instructions pop up, allow the user to select the desired bucket and ensure the config (and UI) gets updated with the selected bucket. We actually ask the use to select the bucket in the "create Telegraf config" workflow: Screen Shot 2021-01-29 at 11 12 59 AM

2) if the user manually edits the Telegraf config and changes the bucket, we need to check to see if that is indeed a valid bucket when they go to save the config, if it isn't... we shouldn't allow it. A nice to have would be to pop-up the bucket selector at that point and ask which one they really want?

3) upon template import, force the user to resolve the bucket if it's a variable.... essentially at time of import, check the telegraf config resources to see if there is a defined bucket and prompt the user to replace that env_var with a valid value?

@russorat other thoughts?

kristinarobinson commented 3 years ago

For scenario #1, where no bucket is specified AT ALL, that's a template configuration (.yml) file issue. Best practices for templates are to use an environment variable for the telegraf config file when variables are used in dashboards. I ran into this when developing the community template for Air Quality. @mhall119 can verify.

For scenario #2, this is an issue that @ssoroka has mentioned as a known problem with editable config files for telegraf. @ssoroka recommends that wide open config files be replaced with "forms" that allow only certain, defined values which can be validated. Trying to implement this in its current form would be difficult.

For scenario #3, again, this is a .yml file issue. NO variables should be used in the telegraf config file. A bucket should be defined in the telegraf config file as either hard-coded or an environment variable. There's no way to enforce that in the current paradigm unless we enforce it at the time that the community template is created. @mhall119, any comments?

kristinarobinson commented 3 years ago

@russorat and @mhall119 --would popping up the same panel as the Generate button in Tokens tab be sufficient? That panel allows you to specify buckets or ALL buckets for an ALL ACCESS token. Here's the panel:

Screen Shot 2021-01-29 at 4 00 02 PM
kristinarobinson commented 3 years ago

Fix on hold until Telegraf Assistant work is addressed.

jzahnd commented 2 years ago

@kristinarobinson any idea of the status on this?