ELK Stack — Kibana Advanced Exercises
Introduction
These five practice exercises cover the advanced Kibana features from this chapter — data views with runtime fields, Canvas workpads, alerting rules, Spaces management, and RBAC configuration. Each exercise increases in complexity and mirrors real-world production scenarios.
Prerequisites:
- Running Elasticsearch 8.x and Kibana instance
- Kibana sample data loaded (web logs, ecommerce, flights) — load via Home → Try sample data
- Admin access to Kibana
Exercise 1 — Data View with Runtime Fields
Difficulty: ⭐⭐ Intermediate
Scenario
Your team ingests web server logs into kibana_sample_data_logs. The bytes field stores response size as a raw number. Product managers want to see response sizes categorized as Small (< 5000 bytes), Medium (5000–10000 bytes), and Large (> 10000 bytes) without reindexing.
Requirements
- Create a data view for
kibana_sample_data_logs - Add a runtime field called
response_size_categoryof type Keyword - The runtime field should classify documents based on the
bytesfield - Verify the runtime field appears in Discover and can be used in a bar chart visualization
Show Solution
Step 1 — Create the Data View
- Open Stack Management → Data Views
- Click Create data view
- Name:
Web Logs - Index pattern:
kibana_sample_data_logs - Timestamp field:
@timestamp - Click Save data view to Kibana
Step 2 — Add the Runtime Field
- In the data view editor, click Add field
- Name:
response_size_category - Type: Keyword
- Toggle Set value on
- Enter the Painless script:
if (doc['bytes'].size() > 0) {
long b = doc['bytes'].value;
if (b < 5000) emit('Small');
else if (b <= 10000) emit('Medium');
else emit('Large');
}
- Click Save
Step 3 — Verify in Discover
- Open Discover
- Select the
Web Logsdata view - Add the
response_size_categorycolumn - Verify you see Small, Medium, and Large values
Step 4 — Create a Visualization
- Open Visualize Library → Create visualization → Lens
- Select the
Web Logsdata view - Drag
response_size_categoryto the horizontal axis - The vertical axis defaults to Count
- Choose Bar vertical chart type
- Save as
Response Size Distribution
Exercise 2 — Build a Canvas Workpad
Difficulty: ⭐⭐ Intermediate
Scenario
The VP of Engineering wants a live status board displayed on a monitor in the office. It should show key metrics from the sample web logs data — total requests, error rate, top 5 countries by traffic, and a time-series chart of requests over time.
Requirements
- Create a Canvas workpad named
Engineering Status Boardwith a 1920×1080 layout - Add a metric element showing total request count (last 24 hours)
- Add a metric element showing error rate (percentage of 5xx responses)
- Add a data table showing top 5 countries by request count
- Set auto-refresh to 30 seconds
- Use a dark background color
Show Solution
Step 1 — Create the Workpad
- Open Canvas from the side navigation
- Click Create workpad
- Name:
Engineering Status Board - Click the settings gear icon
- Set page size to 1920 × 1080
- Set background color to
#1a1a2e
Step 2 — Total Requests Metric
- Click Add element → Metric
- Click the element, then open the Expression editor (bottom of screen)
- Replace the expression with:
filters
| essql query="SELECT COUNT(*) AS total FROM \"kibana_sample_data_logs\" WHERE @timestamp > NOW() - INTERVAL 24 HOUR"
| math "total"
| metric "Total Requests (24h)"
metricFont={font size=48 family="'Open Sans', Helvetica, Arial, sans-serif" color="#00d4ff" align="center"}
labelFont={font size=14 family="'Open Sans', Helvetica, Arial, sans-serif" color="#AAAAAA" align="center"}
| render
- Position in the top-left area of the workpad
Step 3 — Error Rate Metric
- Click Add element → Metric
- Open the Expression editor and use:
filters
| essql query="SELECT ROUND(CAST(SUM(CASE WHEN response >= 500 THEN 1 ELSE 0 END) AS DOUBLE) / COUNT(*) * 100, 2) AS error_pct FROM \"kibana_sample_data_logs\" WHERE @timestamp > NOW() - INTERVAL 24 HOUR"
| math "error_pct"
| formatnumber "0.00"
| metric "Error Rate %"
metricFont={font size=48 family="'Open Sans', Helvetica, Arial, sans-serif" color="#FF4136" align="center"}
labelFont={font size=14 family="'Open Sans', Helvetica, Arial, sans-serif" color="#AAAAAA" align="center"}
| render
- Position next to the total requests metric
Step 4 — Top 5 Countries Table
- Click Add element → Data table
- Open the Expression editor:
filters
| essql query="SELECT geo.src AS country, COUNT(*) AS requests FROM \"kibana_sample_data_logs\" WHERE @timestamp > NOW() - INTERVAL 24 HOUR GROUP BY geo.src ORDER BY requests DESC LIMIT 5"
| table
| render
- Style the table with light text on dark background
Step 5 — Set Auto-Refresh
- Click the clock icon in the toolbar
- Set refresh interval to 30 seconds
- Click Full screen to test the display
Exercise 3 — Set Up Alerting Rules
Difficulty: ⭐⭐⭐ Advanced
Scenario
The SRE team needs to be alerted when the web logs show more than 20 requests with HTTP status code 503 (Service Unavailable) within a 5-minute window. The alert should post to a Slack channel and also write alert data to an Elasticsearch index for historical tracking.
Requirements
- Create a Server log connector for testing (since Slack requires external setup)
- Create an Index connector that writes to
alert-history - Create an Index threshold rule:
- Name:
503 Service Unavailable Spike - Check every: 1 minute
- Index:
kibana_sample_data_logs - Condition: count of documents where
responseis503, is above20in the last 5 minutes
- Name:
- Add two actions:
- Server log action on Active status
- Index action on Active and Recovered status
- Verify the rule appears in the rules list with correct configuration
Show Solution
Step 1 — Create the Server Log Connector
- Open Stack Management → Connectors
- Click Create connector
- Select Server log
- Name:
SRE Alert Log - Click Save
Step 2 — Create the Index Connector
- Click Create connector
- Select Index
- Name:
Alert History - Index:
alert-history - Check Define time field for each document → field name:
@timestamp - Click Save
Step 3 — Create the Alert Rule
- Open Stack Management → Rules
- Click Create rule
- Name:
503 Service Unavailable Spike - Tags:
production,availability - Check every:
1 minute
Step 4 — Configure the Condition
- Select rule type: Index threshold
- Index:
kibana_sample_data_logs - Timestamp field:
@timestamp - Configure:
- WHEN
count() - OF all documents (with KQL filter:
response: 503) - IS ABOVE
20 - FOR THE LAST
5 minutes
- WHEN
Step 5 — Add the Server Log Action
- Click Add action → Server log
- Select the
SRE Alert Logconnector - Run when: Alert is active
- Message:
🚨 503 SPIKE DETECTED
Value: {{context.value}} occurrences in last 5 minutes
Threshold: {{context.threshold}}
Time: {{context.date}}
Step 6 — Add the Index Action
- Click Add action → Index
- Select the
Alert Historyconnector - Run when: Alert is active
- Document:
{
"rule_name": "503 Service Unavailable Spike",
"status": "active",
"value": "",
"threshold": "",
"timestamp": ""
}
- Add another Index action for Recovered status:
{
"rule_name": "503 Service Unavailable Spike",
"status": "recovered",
"timestamp": ""
}
Step 7 — Save and Verify
- Click Save
- Verify the rule appears in Stack Management → Rules
- Check the rule status — it should show as OK or Active depending on current data
Exercise 4 — Configure Spaces and Copy Objects
Difficulty: ⭐⭐⭐ Advanced
Scenario
Your organization has two teams — Platform Engineering and Business Analytics. Each team needs its own Kibana Space with only the features they use. A shared dashboard [Logs] Web Traffic should be available in both Spaces.
Requirements
- Create a Space called
Platform Engineering(ID:platform) with features: Discover, Dashboard, Alerting, Dev Tools - Create a Space called
Business Analytics(ID:analytics) with features: Dashboard, Canvas, Visualize - Copy the
[Logs] Web Trafficdashboard from the Default Space to both new Spaces - Verify the dashboard and its dependencies appear in each Space
Show Solution
Step 1 — Create the Platform Engineering Space
- Open Stack Management → Spaces
- Click Create a space
- Name:
Platform Engineering - URL identifier:
platform - Description:
Infrastructure monitoring and log analysis - Color: Choose a blue shade
- Under Customize features for this space:
- Enable: Discover, Dashboard, Alerting, Dev Tools
- Disable: Canvas, Maps, Machine Learning, Visualize, Graph
- Click Create space
Step 2 — Create the Business Analytics Space
- Click Create a space
- Name:
Business Analytics - URL identifier:
analytics - Description:
Business KPI dashboards and presentations - Color: Choose a green shade
- Under Customize features:
- Enable: Dashboard, Canvas, Visualize
- Disable: Discover, Alerting, Dev Tools, Maps, Machine Learning, Graph
- Click Create space
Step 3 — Copy the Dashboard
- Make sure you are in the Default space
- Open Stack Management → Saved Objects
- Search for
[Logs] Web Traffic - Select the dashboard checkbox
- Click Copy to space
- Select both
Platform EngineeringandBusiness Analytics - Enable Include related objects (this copies dependent visualizations and data views)
- Click Copy
Step 4 — Verify
- Switch to the Platform Engineering space:
- Click the space selector (top-left Kibana logo area) → Platform Engineering
- Or navigate to:
https://localhost:5601/s/platform/app/dashboards
- Open Dashboards → verify
[Logs] Web Trafficis present - Open the dashboard → verify all visualizations render
- Repeat for the Business Analytics space
Verify via API
# List objects in the platform space
curl -X GET "https://localhost:5601/s/platform/api/saved_objects/_find?type=dashboard" \
-H "kbn-xsrf: true" \
-u elastic:changeme
# List objects in the analytics space
curl -X GET "https://localhost:5601/s/analytics/api/saved_objects/_find?type=dashboard" \
-H "kbn-xsrf: true" \
-u elastic:changeme
Exercise 5 — Set Up RBAC with Custom Roles
Difficulty: ⭐⭐⭐⭐ Expert
Scenario
Using the Spaces created in Exercise 4, implement the following access control:
- Platform engineers should have full read-write access to the
platformSpace and read-only access tologs-*andmetrics-*indices. They must NOT see theuser.emailfield (PII protection). - Business analysts should have read-only access to the
analyticsSpace and read access tokibana_sample_data_ecommerceindex only. - A test user for each role should be created and verified.
Requirements
- Create a custom role
platform-engineerwith:- Cluster privilege:
monitor - Index privileges:
read,view_index_metadataonlogs-*,metrics-*,kibana_sample_data_logs - Field-level security: exclude
user.email - Kibana privileges:
allon features in theplatformSpace
- Cluster privilege:
- Create a custom role
business-analystwith:- No cluster privileges
- Index privileges:
read,view_index_metadataonkibana_sample_data_ecommerce - Kibana privileges:
readon features in theanalyticsSpace
- Create user
platform-userwith roleplatform-engineer - Create user
analyst-userwith rolebusiness-analyst - Verify access by logging in as each user
Show Solution
Step 1 — Create the platform-engineer Role
curl -X PUT "https://localhost:9200/_security/role/platform-engineer" \
-H "Content-Type: application/json" \
-u elastic:changeme \
-d '{
"cluster": ["monitor"],
"indices": [
{
"names": ["logs-*", "metrics-*", "kibana_sample_data_logs"],
"privileges": ["read", "view_index_metadata"],
"field_security": {
"grant": ["*"],
"except": ["user.email"]
}
}
],
"applications": [
{
"application": "kibana-.kibana",
"privileges": [
"feature_discover.all",
"feature_dashboard.all",
"feature_alerting.all",
"feature_dev_tools.all"
],
"resources": ["space:platform"]
}
]
}'
Step 2 — Create the business-analyst Role
curl -X PUT "https://localhost:9200/_security/role/business-analyst" \
-H "Content-Type: application/json" \
-u elastic:changeme \
-d '{
"cluster": [],
"indices": [
{
"names": ["kibana_sample_data_ecommerce"],
"privileges": ["read", "view_index_metadata"]
}
],
"applications": [
{
"application": "kibana-.kibana",
"privileges": [
"feature_dashboard.read",
"feature_canvas.read",
"feature_visualize.read"
],
"resources": ["space:analytics"]
}
]
}'
Step 3 — Create the Test Users
# Platform user
curl -X POST "https://localhost:9200/_security/user/platform-user" \
-H "Content-Type: application/json" \
-u elastic:changeme \
-d '{
"password": "Plat4rm!User",
"roles": ["platform-engineer"],
"full_name": "Platform User",
"email": "platform@company.com"
}'
# Analyst user
curl -X POST "https://localhost:9200/_security/user/analyst-user" \
-H "Content-Type: application/json" \
-u elastic:changeme \
-d '{
"password": "An4lyst!User",
"roles": ["business-analyst"],
"full_name": "Analyst User",
"email": "analyst@company.com"
}'
Step 4 — Verify Platform User Access
- Open a private/incognito browser window
- Navigate to
https://localhost:5601/s/platform/app/discover - Log in as
platform-user/Plat4rm!User - Verify:
- ✅ Can access Discover, Dashboard, Alerting, Dev Tools in the
platformSpace - ✅ Can search
kibana_sample_data_logs - ✅ The
user.emailfield is NOT visible in Discover - ❌ Cannot access the
analyticsSpace - ❌ Cannot access Canvas or Maps
- ✅ Can access Discover, Dashboard, Alerting, Dev Tools in the
Step 5 — Verify Analyst User Access
- Open another private window
- Navigate to
https://localhost:5601/s/analytics/app/dashboards - Log in as
analyst-user/An4lyst!User - Verify:
- ✅ Can view dashboards and Canvas workpads in the
analyticsSpace - ✅ Can read ecommerce data
- ❌ Cannot create or edit dashboards (read-only)
- ❌ Cannot access the
platformSpace - ❌ Cannot access Discover or Dev Tools
- ✅ Can view dashboards and Canvas workpads in the
Cleanup (Optional)
# Delete test users
curl -X DELETE "https://localhost:9200/_security/user/platform-user" -u elastic:changeme
curl -X DELETE "https://localhost:9200/_security/user/analyst-user" -u elastic:changeme
# Delete custom roles
curl -X DELETE "https://localhost:9200/_security/role/platform-engineer" -u elastic:changeme
curl -X DELETE "https://localhost:9200/_security/role/business-analyst" -u elastic:changeme
Summary
| Exercise | Topic | Difficulty |
|---|---|---|
| 1 | Data view with runtime fields | ⭐⭐ |
| 2 | Canvas workpad for status board | ⭐⭐ |
| 3 | Alerting rules with connectors | ⭐⭐⭐ |
| 4 | Spaces and copying objects | ⭐⭐⭐ |
| 5 | RBAC with custom roles and FLS | ⭐⭐⭐⭐ |
These exercises simulate real-world scenarios you will encounter when managing a multi-team Kibana deployment. Practice them in a development environment before applying the concepts to production.
← Back to: Kibana Advanced