FreeBSD 14
Sponsored Link

InfluxDB : Install2024/08/26

 

Install Time Series Database, InfluxDB.

[1] Install InfluxDB and client tools.
root@dlp:~ #
pkg install -y influxdb influxdb2-cli curl
root@dlp:~ #
service influxd enable

influxd enabled in /etc/rc.conf
root@dlp:~ #
service influxd start

Starting influxd.
[2] Configure InfluxDB.
By default, authentication is disabled, all users can use InfluxDB with privileges. So enable authentication first.
# create an admin user
# [admin] ⇒ specify any username you like
# [adminpassword] ⇒ set any password

root@dlp:~ #
influx -execute "create user admin with password 'adminpassword' with all privileges"

root@dlp:~ #
influx -execute "show users"

user  admin
----  -----
admin true

root@dlp:~ #
vi /usr/local/etc/influxd.conf
[http]
  # Determines whether HTTP endpoint is enabled.
  # enabled = true

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

  # Determines whether user authentication is enabled over HTTP/HTTPS.
  # line 263 : uncomment and change
  auth-enabled = true

root@dlp:~ #
service influxd restart
[3] After enabling authentication, access InfluxDB CLI like follows.
# run InfluxDB CLI and authenticate as an user

root@dlp:~ #
influx

Connected to http://localhost:8086 version 1.8.10
InfluxDB shell version: 1.8.10
> auth
username: admin
password:

> exit

# add user info on CLI

root@dlp:~ #
influx -username admin -password adminpassword

Connected to http://localhost:8086 version 1.8.10
InfluxDB shell version: 1.8.10
> exit

# set user info on environment variables

root@dlp:~ #
export INFLUX_USERNAME=admin

root@dlp:~ #
export INFLUX_PASSWORD=adminpassword

root@dlp:~ #
influx

Connected to http://localhost:8086 version 1.8.10
InfluxDB shell version: 1.8.10
> exit

# authenticate on HTTP API

root@dlp:~ #
curl -G http://localhost:8086/query?pretty=true -u admin:adminpassword --data-urlencode "q=show users"

{
    "results": [
        {
            "statement_id": 0,
            "series": [
                {
                    "columns": [
                        "user",
                        "admin"
                    ],
                    "values": [
                        [
                            "admin",
                            true
                        ]
                    ]
                }
            ]
        }
    ]
}
Matched Content