InfluxDB #
Folder Structure #
# Create folder structure
sudo mkdir -p /opt/influxdb/{config,data} && cd /opt/influxdb
Environment File #
# Create .env file
sudo vi .env
# .env
DOCKER_INFLUXDB_INIT_MODE=setup
DOCKER_INFLUXDB_INIT_USERNAME=admin
DOCKER_INFLUXDB_INIT_PASSWORD=admin-password # Define admin PW
DOCKER_INFLUXDB_INIT_ORG=jklug.work
DOCKER_INFLUXDB_INIT_BUCKET=storage-bucket-1
DOCKER_INFLUXDB_INIT_RETENTION=1w
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=kjnYdKk7V44AULwm7VEsDW3E
Docker Compose File #
# Create Docker Compose file
sudo vi docker-compose.yml
# docker-compose.yml
version: "3.9"
services:
influxdb:
image: influxdb:2.7.4
container_name: influxdb
env_file:
- .env
restart: unless-stopped
ports:
- "8086:8086"
security_opt:
- no-new-privileges:true
volumes:
- ./config:/etc/influxdb2
- ./data:/var/lib/influxdb2
Note: Remove to environment file if you want to manually setup InfluxDB from the GUI.
Start Container #
# Create / start Docker stack
sudo docker compose up -d
Reverse Proxy #
Certbot #
# Install Certbot
sudo apt install certbot -y
# Create certificate
sudo certbot certonly --standalone -d influxdb.jklug.work
Nginx #
# Install nginx
sudo apt install nginx -y
# Copy default config
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/influxdb.jklug.work
# Edit config
sudo vi /etc/nginx/sites-available/influxdb.jklug.work
# influxdb.jklug.work
server {
listen 443 ssl;
server_name influxdb.jklug.work;
ssl_certificate /etc/letsencrypt/live/influxdb.jklug.work/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/influxdb.jklug.work/privkey.pem;
location / {
proxy_pass http://127.0.0.1:8086/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
# Disable default config
sudo rm /etc/nginx/sites-enabled/default
# Enable config
sudo ln -s /etc/nginx/sites-available/influxdb.jklug.work /etc/nginx/sites-enabled/
# Restart Nginx
sudo systemctl restart nginx
InfluxDB GUI #
Login #
# Open URL
influxdb.jklug.work
# Use username & pw defined in .env file
Create Configuration #
# Copy token
export INFLUX_TOKEN=kbGI64EWaacQYXWKCUgKPYPerUYeMiwqSlxVBqIvOgXN5691MXPEhaeNaAI30J-Tr5tdyeXT6pB8GU2_6ka0oA==
# Copy the part after "export INFLUX_TOKEN="
kbGI64EWaacQYXWKCUgKPYPerUYeMiwqSlxVBqIvOgXN5691MXPEhaeNaAI30J-Tr5tdyeXT6pB8GU2_6ka0oA==
Telegraf #
Install Telegraf #
# Download package
wget https://dl.influxdata.com/telegraf/releases/telegraf_1.28.5-1_amd64.deb
# Install Telegraph
sudo dpkg -i telegraf_1.28.5-1_amd64.deb
Create Configuration #
# Remove default Telegraf configuration
sudo rm /etc/telegraf/telegraf.conf
# Create new Telegraf configuration
sudo vi /etc/telegraf/telegraf.conf
# telegraf.conf
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = ""
hostname = "Server1" # Define server name
omit_hostname = false
[[outputs.influxdb_v2]]
urls = ["http://127.0.0.1:8086"] # Define URL
token = "kbGI64EWaacQYXWKCUgKPYPerUYeMiwqSlxVBqIvOgXN5691MXPEhaeNaAI30J-Tr5tdyeXT6pB8GU2_6ka0oA==" # Use token from InfluxDB
organization = "jklug.work" # Define org from .env file
bucket = "storage-bucket-1" # Define bucket from .env file
[[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false
[[inputs.disk]]
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
[[inputs.diskio]]
[[inputs.mem]]
[[inputs.net]]
[[inputs.processes]]
[[inputs.swap]]
[[inputs.system]]
# Define InfluxDB IP for external server monitoring: For example
[[outputs.influxdb_v2]]
urls = ["http://192.168.30.4:8086"]
Restart Telegraf #
# Restart Telegraf
sudo systemctl restart telegraf
# Check status
sudo systemctl status telegraf
Testing #
Install Stress #
# Install stress package
sudo apt-get install stress
# Utilize all cpu cores for 10 seconds
stress --cpu $(nproc) --timeout 10s
InfluxDB Monitoring #
Links #
InfluxDB
# DockerHub
https://hub.docker.com/_/influxdb
# Official Documentation
https://docs.influxdata.com/influxdb/v2/install/?t=Docker
# Github
https://github.com/influxdata/influxdb
Telegraf
# Official Documentation
https://docs.influxdata.com/telegraf/v1/install/