📈 Setup InfluxDB — Time-Series Database
Deploy InfluxDB time-series database on Ubuntu using Docker — high write throughput for IoT metrics, server monitoring, and Flux queries.
📦 Resources & Setup Scripts
Grab the automated bash script from GitHub to follow along with the video.
Quick Install:
wget https://raw.githubusercontent.com/mhmdali94/Docker/main/databases/influxdb/influxdb-ubuntu.sh
chmod +x influxdb-ubuntu.sh
sudo bash influxdb-ubuntu.sh
Tutorial Steps
1 Download the Script
wget https://raw.githubusercontent.com/mhmdali94/Docker/main/databases/influxdb/influxdb-ubuntu.sh
2 Make it Executable
chmod +x influxdb-ubuntu.sh
3 Run the Installer
The script installs Docker if needed, then deploys InfluxDB 2.x with built-in web UI.
sudo bash influxdb-ubuntu.sh
4 Access Web UI
Open browser and navigate to:
http://<your-server-ip>:8086
5 Create Organization and First Bucket
Complete the setup wizard — create your organization, a bucket for your metrics, and generate an API token for your data sources.
# Via CLI inside container
docker exec -it influxdb influx setup \
--username admin \
--password YourPassword \
--org MyOrg \
--bucket metrics \
--force
Ports Used
| Port | Purpose |
|---|---|
| 8086 | InfluxDB Web UI + API |
Overview
InfluxDB is a purpose-built open-source time-series database optimised for storing and querying metrics, events, and real-time analytics at high write throughput. It is the standard choice for infrastructure monitoring, IoT sensor data, and application performance tracking.
Why Use It
InfluxDB is purpose-built for time-series data — it outperforms general-purpose databases (PostgreSQL, MySQL) by orders of magnitude for time-ordered inserts and range queries. If you're collecting IoT sensor readings, server metrics, application performance data, or any measurement that changes over time, InfluxDB handles millions of inserts per second and compresses the data efficiently. Version 2.x adds a built-in UI and Flux query language.
When You Need It
Who Should Use It
Real Use Cases
Main Features
How to Use After Installation
Security Best Practices
Ports and Firewall Notes
Port 8086 for both the web UI and the InfluxDB HTTP API. Keep it internal — your monitoring agents (Telegraf, apps) connect to it locally. Use a reverse proxy on 443 if you need external access to the UI.
Backup and Maintenance
Common Mistakes
Troubleshooting
Alternatives
Direct alternatives: Prometheus (pull-based, better for Kubernetes, shorter retention by default), TimescaleDB (PostgreSQL extension — SQL + time-series), VictoriaMetrics (faster, InfluxDB line protocol compatible). For IoT: InfluxDB wins. For Kubernetes monitoring: Prometheus + Thanos/Cortex. For SQL: TimescaleDB.
When Not to Use It
Don't use InfluxDB if you only need Prometheus-style scraping for Kubernetes — Prometheus is purpose-built for that ecosystem. And if you need ACID transactions or relational joins, a general-purpose database is better. InfluxDB excels specifically at high-throughput time-ordered data.
PrismaTechWork Professional Help
PrismaTechWork provides end-to-end infrastructure services — from initial deployment and security hardening to ongoing monitoring, automated backups, and dedicated support. Whether you need a single-server setup or a multi-site network, our team ensures your infrastructure is built right, secured properly, and maintained reliably.
Frequently Asked Questions
What is the difference between InfluxDB 1.x and 2.x?
InfluxDB 2.x is a complete rewrite with a built-in web UI, Flux query language (replacing InfluxQL), built-in Telegraf configuration, and unified API. InfluxDB 1.x used InfluxQL (SQL-like) and had no built-in UI. Most new deployments should use 2.x.
Can I use InfluxDB with Grafana?
Yes — Grafana has a native InfluxDB datasource plugin supporting both InfluxQL and Flux. For InfluxDB 2.x, use the Flux query language mode. Add the datasource in Grafana with your InfluxDB URL and a read-only API token.
What is Telegraf and do I need it?
Telegraf is InfluxDB's open-source collection agent with 300+ plugins for system metrics, databases, APIs, and IoT devices. You don't need it — you can write directly to InfluxDB via the HTTP API — but Telegraf makes collecting from standard sources (CPU, disk, Docker, MySQL) trivial.
What is Flux and how is it different from SQL?
Flux is a functional data scripting language designed for time-series operations. Instead of SQL's `SELECT ... GROUP BY`, Flux chains operations: `from(bucket: 'metrics') |> range(start: -1h) |> filter(fn: (r) => r._measurement == 'cpu') |> mean()`. It's more powerful for time-series math.
How do I set data retention policies?
Set retention when creating a bucket or update it: `influx bucket update --name mybucket --retention 30d`. Data older than the retention period is automatically deleted. Create multiple buckets with different retentions (e.g., raw 7d, hourly 365d).
What is high cardinality and why does it matter?
High cardinality means having tags with many unique values (e.g., a `user_id` tag with millions of unique users). InfluxDB indexes all tag values, so high-cardinality tags create massive indexes that slow writes and queries. Store high-cardinality values as fields, not tags.
Can InfluxDB handle millions of writes per second?
Yes — InfluxDB is designed for high write throughput. A single node can handle hundreds of thousands to millions of points per second depending on hardware. The TSM storage engine batches and compresses writes for efficiency.
How do I upgrade InfluxDB?
Run `docker compose pull && docker compose up -d`. Always back up data before upgrading. For minor versions (2.x → 2.y), upgrades are usually seamless. Check the InfluxDB changelog for any breaking changes in Flux behavior or API.