Let me make you clear about InfluxDB first. It provides the ease of a powerful API for making apps without any complicated coding forms. It is generally with less code, effortless and fewer configurations as well.
HelptoInstall’s Expert Admin Panel is recommended to have an Ubuntu Server and a Sudo user in order to begin.
Download And Install The InfluxDB Package
First of all, we have to install the influx DB server by pulling the installation from the official repository.
We will SSH to the server. After that, we have to download and add the influx DB GPG key into the server we run.
$ sudo curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add - The command will be resulted in an OK message. Then, we will add a new influxdb.list repo file to the available packages list. $ sudo echo "deb https://repos.influxdata.com/ubuntu bionic stable" | sudo tee /etc/apt/sources.list.d/influxdb.list After that, the next thing we have to do is the updation of package information index: $ sudo apt update Then, we have to install the package information index: $ sudo system ctl start influxdb The package will be active and loaded on the server. Influxdb.service- influx DB is an open-source, distributed, time ser loaded : C/lib/systemd/system/influxdb-service;enabled;vendc Active:active (running) since Fri 2021-09-03 06:08:59 UTC;2min3s Docs:https://docs.influxdata.com/influxdb/
Configuration Of The InfluxDB Server
After all, we have to configure a new admin user along with root privileges for the influx DB server.
For this, we have to execute the influx command.
$ influx
This help you to see the current connection, port, and version number.
Connected to http://localhost:8086 version 1.8.9 influx DB shell version: 1.8.9
>
(It means that the influx DB is ready to accept commands)
For creating an admin account, we run:
CREATE USER admin WITH PASSWORD ‘EXAMPLE_PASSWORD WITH ALL PRIVIL
Additionally, you should make sure to replace EXAMPLE_PASSWORD along with a strong value.
Then, we exit from the influxDB shell: > quit
Fina;lly, we will have to get the authentication enabled. We have to modify the main influxDB configuration file for doing it.
Use nano to open the /etc/influxdb/influxdb.conf file.
$sudo nano /etc/influxdb/influxdb.conf
Then we locate the line #auth-enabled = false under the (http) section
…
(http)
…
#determines whether user authentication is enabled over HTTP/HTTPS.
#auth-enabled=false
…
Now, we can change the value of enabled auth to true and remove the leading symbol from the line to uncomment the setting
…
(http)
…
#determines whether user authentication is enabled over HTTP/HTTPS.
auth-enabled = true
…
Finally, we save and close the file.
Then, the next step is to load the new security setting, we have to restart the influxdb service.
$sudo system ‘t’ restart influxdb. Then, we can go and log into the influxDB server with the username of admin and password that we set: $influx – username ‘admin’ – password “EXAMPLE PASSWORD”
For verifying the commands and to make sure everything is working, we run
> SHOW DATABASES
After that, we will see a default, internal databvase in the list like :
name : databases
name
………
-internal
To Create An InfluDB Database
Moving on, we will set up a sample database a strong matrix.
We create the water-DB database on the influx shell. To do that, we have to run:
CREATE DATABASE water_db.
and we should click enter.
That will show the symbol “>”, that means the command execution has no errors.
Then, we can verify whether we have successfully set up the ater_db database or not.
>SHOW DATBASES
This will give us two databases list
name: database
name
——-
_internal
water_db
The database is all set to accept new data.
Write influxDB Data
Execute additional InfluxQL statements against the new water-DB database.
Switch to the new water_db database. For the web have to run:
>USE water_db
We will get similar output like on the following line
Using database water_db
Now, this database can accept writes and queries.
InfluxDB HTTP API
We all know that InfluxDB is built for developers. It has a very useful API querying metrics with common tools that are allowed without writing additional codes.
For that we run
S Curl – G ‘https : localhost : 8086 / query?
Pretty=true-uadmin : EXAMPLE
Ensure to replace EXAMPLE_PASSWORD with the correct password value.
The outlook will be similar as follows
The output will look similar to this:
{ "results": [ { "statement_id": 0, "series": [ { "name": "water_level", "columns": [ "time", "tank_location", "value_in_ft" ], "values": [ [ "2021-09-03T09:07:04.738274574Z", "MIAMI", 10 ], [ "2021-09-03T09:07:13.290269685Z", "SEATTLE", 5.4 ], [ "2021-09-03T09:07:29.030041003Z", "DALLAS", 3.2 ], [ "2021-09-03T09:08:16.340252215Z", "LOS-ANGELES", 1.3 ] ] } ] } ] }
Eventually, the Influx DB Server and API will work.
Consider HelptoInstall if you face any issues.