How to Visualize Time‑Series Data with InfluxDB and Grafana: A Step‑by‑Step Guide
This article walks through the fundamentals of InfluxDB as a time‑series database, demonstrates how to write data via its HTTP API, and shows how to configure Grafana for real‑time visualization, high‑availability deployment, and alerting in a big‑data monitoring scenario.
1. InfluxDB Overview
InfluxDB is an open‑source, distributed time‑series database written in Go that requires no external dependencies. It stores data points that include a timestamp, fields (value columns), and tags (indexed attributes). Its three main features are:
Time‑Series functions (max, min, sum, etc.)
Metrics for real‑time aggregation
Event support for arbitrary data
Key advantages include zero‑dependency installation, built‑in data expiration, fine‑grained table‑level permissions, native HTTP API, and a SQL‑like query language.
Core terminology (compared with relational databases):
database – the InfluxDB instance
measurement – analogous to a table
point – a single row consisting of time, fields, and tags
Example of inserting a point via the HTTP API:
curl -v -XPOST "http://localhost:8086/write?db=Internet&u=user&p=password" \
--data-binary "Internet_users,users=小区上网用户,mobile=移动端上网用户,users_num=56,mobile_num=21 1493571600000000000"The request parameters are: db=Internet – target database Internet_users – measurement (table) name
Tags: users and mobile Fields: users_num and mobile_num Timestamp in nanoseconds
2. Grafana Overview
Grafana is a powerful HTML/JavaScript dashboard tool that can query InfluxDB without cross‑origin restrictions. After adding InfluxDB as a data source, charts are created by configuring queries, panels, and optional alert rules.
Key steps:
Configure the InfluxDB data source (URL, database, authentication).
Build queries using InfluxQL functions (e.g.,
SELECT mean(value) FROM measurement WHERE time > now() - 1h GROUP BY time(5m)).
Design panels to visualize metrics such as CPU, memory, or custom business KPIs.
Enable alerting (email, Slack, webhook) by defining a query, threshold, and evaluation interval.
Grafana’s alerting was introduced in version 4.0 and supports multiple notification channels.
3. Practical Implementation
Data collection planning : Metrics are harvested from Hadoop JMX, queue statistics, and Oracle logs, then written to InfluxDB via custom scripts.
InfluxDB permission configuration :
ADMIN – full control
READ – read‑only access (used by Grafana)
WRITE – write access for ingestion programs
Enable authentication by editing /etc/InfluxDB/InfluxDB.conf and setting auth-enabled = true under the [http] section:
[http]
enabled = true
bind-address = ":8086"
auth-enabled = true
log-enabled = true
write-tracing = false
pprof-enabled = false
https-enabled = false
https-certificate = "/etc/ssl/InfluxDB.pem"High‑availability deployment : Two virtual machines (Localhost‑01 and Localhost‑02) each run InfluxDB + Grafana. A virtual IP (VIP) and load balancer map ports 8083/8086/3000 to the active node, providing failover.
Load‑balancer configuration includes:
VIP for primary and standby IPs
Port mapping (e.g., VPORT 8083 for InfluxDB UI)
Round‑robin algorithm
TCP health checks
Grafana data source URLs use the shared domain (e.g., http://xxx.xxx.com:3000) to ensure seamless failover.
Grafana dashboard setup : After connecting to InfluxDB, panels are created for HDFS directory quota, HDFS space usage, and other cluster metrics. Alerts are defined on CPU and memory thresholds using the Query‑based condition.
With the above configuration, the monitoring system provides real‑time visualization, alerting, and resilience against node failures.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
dbaplus Community
Enterprise-level professional community for Database, BigData, and AIOps. Daily original articles, weekly online tech talks, monthly offline salons, and quarterly XCOPS&DAMS conferences—delivered by industry experts.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
