About API Token

Hi i have a genuine question
like 1-2 weeks ago i make literally basic project to how influxdb work and make sure my sensor can gather data and put it in influx

my question is

...
urls = ["https://us-east-1-1.aws.cloud2.influxdata.com"]
token = "<Token>"
...

in this snippet of whole telegraf configuration the first time i try to ran the telegraf config with actual API token put in the token, it said this error in shells:

Error getting HTTP config.  Retry 0 of 3 in 10s.  Status=401

but after i make an environment of it in my computer without changing my telegraf config, it suddenly worked. my log running, my data succesfully sent in my database is there a reasons why my computer is set in that ways?
thx

There are a few things that could explain this:

  • Was this a brand new token you created moments before starting Telegraf? Depending on the version of InfluxDB your using, there can actually be a delay between when a token is created vs when it’s registered and usable.

  • There possible could have been an extra whitespace in your token string literal or something similar that wasn’t included when you added it as an environment variable.

The answer is no? This token already up like 2-3 days. Everytime i need to activate my telegraf i always do this first:

  1. Check my local host ip (its always change 1 numbers randomly) and if changed i renew my config
  2. Add new environment for token just for my telegraf to function

Im using influxdb cloudless

The funny thing is if i do it like this

Token=$env:myToken

The system gonna tell is 401 unauthorized in the telegraf log