Error 401 every time I try to use influx v1 shell


I just installed influxDB 2 and telegraf. They are on different servers. Both installations are made without sudo privileges which I think is the key thing here.

I have no problem using the CLI for influx user create and all the other commands. Did my account via the UI and all looks good.

But when I try to influx v1 shell and create user or show DB or create DB and etc. I get error 401.

Also when I try to start telegraf with telegraf --conf /etc/telegraf/telegraf.conf I get the same error 401 because it cannot create the DB.

I think for some reason by default is trying to create all of those in /var/libs where root is the owner.

Can you tell me how to change the target dir for creation.

PS I am doing it on RHEL 7.

Ah yes authentication issues…

For InfluxDB, when running without sudo privileges and to avoid using directories owned by root (like /var/lib), you’ll need to configure both InfluxDB and Telegraf to use directories where your non-root user has write permissions. Here’s how you can approach resolving these issues:

For influxdb consider…

  1. Data Storage Directory: If you’ve installed InfluxDB without sudo privileges, ensure that the configuration file (influxdb.conf) is pointing to directories that your user has access to. The configuration file should have settings for the data storage directory (data-dir), the WAL (Write Ahead Log) directory (wal-dir), and possibly others, depending on your setup. You can find and edit these settings in the influxdb.conf file, which might be located in a user-specific directory if you’ve installed InfluxDB without root privileges.
  2. Environment Variables: Another approach is to set environment variables to override the default paths. InfluxDB respects several environment variables that can dictate where it looks for files. For example, INFLUXDB_DATA_DIR can be set to change where data is stored. You can set these variables in your shell initialization file (like .bashrc or .bash_profile) to ensure they are always set when you start a new shell session.

For telegraf consider…

  1. Configuration File: Make sure the telegraf.conf file is correctly pointing to your InfluxDB instance with the correct authentication credentials. Since you’re seeing a 401 error, it’s crucial to ensure that the [outputs.influxdb] section of your telegraf.conf has the correct urls, token, and organization (for InfluxDB 2.x).
  2. Database Creation: InfluxDB v2 doesn’t use databases and users in the same way as InfluxDB 1.x. Instead, it uses buckets and has a different authentication model based on tokens. Make sure your Telegraf configuration reflects this if you’re working with InfluxDB 2.x. You cannot create a database with InfluxDB 2.x using the v1 compatibility API without first setting up a mapping between the old database/user model and the new bucket/token model. This setup is done in the UI or through the InfluxDB 2 CLI using the influx v1 commands.

Also welcome @Aleks_Angelov! out of curiosity what are you looking to use InfluxDB for?

I need to use it on infra with around 400 unix servers but I saw that in InfluxDB v2 buckets are being used but when I try to integrate it with telegraf I need to create different measurements for system, files and etc which would not be optimal for 400 servers…

Can you please advise?