ELK Stack — Visualizations
Visualizations
Visualizations are the building blocks of Kibana dashboards. Each visualization represents an Elasticsearch aggregation rendered as a chart, table, gauge, or other visual element. Understanding how to create and configure visualizations is essential for turning raw log data into meaningful insights.
Visualization Types
Kibana offers a wide range of visualization types, each suited to different data representation needs:
| Type | Best For |
|---|---|
| Line | Trends over time (request rate, error rate) |
| Area | Trends over time with volume emphasis |
| Bar (Vertical) | Comparing categories (errors by service) |
| Bar (Horizontal) | Comparing categories with long labels |
| Pie | Proportional breakdown (traffic by country) |
| Donut | Proportional breakdown (alternative to pie) |
| Metric | Single key number (total errors, avg response time) |
| Gauge | Current value against a threshold (CPU usage) |
| Data Table | Tabular aggregation results |
| Tag Cloud | Word frequency visualization |
| TSVB | Advanced time series with multiple panels |
| Vega/Vega-Lite | Fully custom visualizations |
| Heatmap | Density distribution across two dimensions |
| Markdown | Text annotations and notes on dashboards |
Buckets and Metrics — Core Concepts
Every aggregation-based visualization in Kibana is built from two components:
Metrics
Metrics define what you measure — the numerical calculation applied to your data:
- Count — Number of documents.
- Sum — Sum of a numeric field.
- Average — Average of a numeric field.
- Min / Max — Minimum or maximum value.
- Unique Count (Cardinality) — Number of distinct values.
- Percentiles — Distribution percentiles (p50, p95, p99).
- Top Hit — The most recent or relevant value.
Buckets
Buckets define how you group your data — they split documents into groups:
- Date Histogram — Group by time intervals (per minute, per hour, per day).
- Terms — Group by distinct values of a field (top 10 services, top 5 status codes).
- Range — Group by custom numeric ranges.
- Histogram — Group by fixed numeric intervals.
- Filters — Group by custom filter queries.
- Significant Terms — Statistically significant terms.
A visualization combines one or more metrics with zero or more buckets to produce the final chart.
Creating a Visualization — Step by Step
Step 1: Open the Visualize Library
- Click the hamburger menu (☰) → Analytics → Visualize Library.
- Click Create visualization.
- Choose the visualization type (e.g., Vertical Bar).
Step 2: Select a Data View
- Select the data view to query — for example,
app-logs-*. - The editor loads with a blank chart and the aggregation configuration panel.
Step 3: Configure Metrics
- Under Metrics, the default metric is Count (Y-axis).
- Click Count to change it. For example, select Average and choose the field
event.duration. - Add additional metrics by clicking Add under Metrics.
Step 4: Configure Buckets
- Under Buckets, click Add → X-axis.
- Choose an aggregation — for example, Date Histogram on
@timestampwith Auto interval. - To add a second grouping (split series), click Add → Split Series and choose Terms on
service.namewith size 5.
Step 5: Apply and Save
- Click the Update button (▶) to render the visualization.
- Adjust the time range using the time picker if needed.
- Click Save in the toolbar, enter a name, and save.
Creating Common Visualization Types
Line Chart — Request Rate Over Time
- Create a new visualization → select Line.
- Data view:
app-logs-*. - Metric: Count (Y-axis) — represents request volume.
- Bucket → X-axis: Date Histogram on
@timestamp, interval Auto. - Click Update. The chart shows request rate over time.
- To split by service, add Bucket → Split Series → Terms on
service.name, size 5.
Bar Chart — Errors by Service
- Create a new visualization → select Vertical Bar.
- Metric: Count.
- Bucket → X-axis: Terms on
service.name, size 10. - Add a filter in the query bar:
log.level: "ERROR". - Click Update. The chart shows which services produce the most errors.
Pie Chart — Traffic Distribution by Status Code
- Create a new visualization → select Pie.
- Metric: Count (slice size).
- Bucket → Split Slices → Terms on
http.response.status_code, size 10. - Click Update. The chart shows the proportion of 200s, 301s, 404s, 500s, etc.
Metric — Total Error Count
- Create a new visualization → select Metric.
- Metric: Count.
- Add a filter in the query bar:
log.level: "ERROR". - Click Update. A single large number displays the total error count.
- Under Options, you can set a color range — for example, green below 100, red above 1000.
Gauge — Average Response Time
- Create a new visualization → select Gauge.
- Metric: Average on
event.duration. - Under Options, set ranges:
- Green: 0–500 ms
- Yellow: 500–2000 ms
- Red: 2000–10000 ms
- Click Update. The gauge shows the current average response time with color coding.
Data Table — Top Error Messages
- Create a new visualization → select Data Table.
- Metric: Count.
- Bucket → Split Rows → Terms on
error.message, size 20. - Add a filter:
log.level: "ERROR". - Click Update. A table lists the most common error messages with their counts.
Time Series Visual Builder (TSVB)
TSVB is an advanced time-series visualization tool that offers more flexibility than standard line or area charts.
Key Features of TSVB
- Multiple metrics on the same panel with different aggregations.
- Math expressions to compute derived metrics (e.g., error rate = errors / total × 100).
- Annotations to overlay events on the timeline.
- Multiple panel types — Time Series, Metric, Top N, Gauge, Table, Markdown.
Creating a TSVB Visualization
- Create a new visualization → select TSVB.
- The TSVB editor opens with a default time-series panel.
- Under Data, configure:
- Index pattern:
app-logs-* - Time field:
@timestamp
- Index pattern:
- Under Panel options, set the data view.
- In the Series section:
- Series 1: Aggregation Count, Group by Everything — total request count.
- Click + to add Series 2: Aggregation Count, filter
log.level: "ERROR"— error count.
- Click the Options tab to customize colors, line styles, and fill.
TSVB Math Expression — Error Rate Percentage
- Add Series 1: Count of all documents. Set label to
Total. - Add Series 2: Count with filter
log.level: "ERROR". Set label toErrors. - Add Series 3: Choose Math aggregation. Enter the expression:
params.Errors / params.Total * 100. - This creates a derived error rate percentage line.
Vega and Vega-Lite
For fully custom visualizations that go beyond Kibana’s built-in options, you can use Vega or Vega-Lite — declarative visualization grammars.
When to Use Vega
- You need a visualization type not available in Kibana (e.g., Sankey diagram, network graph).
- You want complete control over every visual aspect.
- You need to combine data from multiple Elasticsearch queries.
Simple Vega-Lite Example
- Create a new visualization → select Vega.
- Replace the default spec with:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"title": "Error Count by Service",
"data": {
"url": {
"index": "app-logs-*",
"body": {
"size": 0,
"query": {
"bool": {
"filter": [
{ "term": { "log.level": "ERROR" } },
{ "range": { "@timestamp": { "gte": "now-24h" } } }
]
}
},
"aggs": {
"services": {
"terms": { "field": "service.name", "size": 10 }
}
}
}
},
"format": { "property": "aggregations.services.buckets" }
},
"mark": "bar",
"encoding": {
"x": { "field": "key", "type": "nominal", "title": "Service" },
"y": { "field": "doc_count", "type": "quantitative", "title": "Error Count" },
"color": { "field": "key", "type": "nominal" }
}
}
- Click Update to render the custom bar chart.
Saving and Embedding Visualizations
Saving
- Click Save in the visualization editor toolbar.
- Enter a descriptive name following a naming convention — for example:
[Logs] Error Count by Service — Bar. - The visualization is saved to the Visualize Library and can be added to any dashboard.
Naming Convention Best Practices
Use a consistent pattern:
[Category] Description — Chart Type
Examples:
[Logs] Request Rate Over Time — Line[Metrics] CPU Usage — Gauge[Security] Failed Logins by IP — Data Table
Embedding in Dashboards
Saved visualizations can be added to dashboards by clicking Add panel → Add from library and selecting the visualization. We’ll cover this in detail in the Dashboards section.
Quick Reference
| Task | Steps |
|---|---|
| Create visualization | Menu → Visualize Library → Create visualization |
| Set metric | Click the metric aggregation → choose type and field |
| Set bucket | Click Add → choose bucket type and aggregation |
| Add filter | Type a query in the visualization query bar |
| Split series | Add bucket → Split Series → Terms |
| Update chart | Click the ▶ Update button |
| Save visualization | Click Save → enter name → Save |
| Use TSVB | Create visualization → select TSVB |
| Use Vega | Create visualization → select Vega |
Next: Dashboards — Combine visualizations into interactive monitoring dashboards.