What is the role of the stats, eval, and timechart commands in SPL? [Intermediate]
Answer
In SPL, stats calculates aggregate summaries, eval creates or modifies fields using expressions, and timechart builds time-series aggregations for charts. Together they cover most operational log analytics use cases.
Technical explanation
stats is used for counts, averages, percentiles, distinct counts, and grouping by fields.
eval is used for derived fields such as severity normalization, boolean flags, or latency buckets.
timechart groups results into time buckets, which makes it ideal for trends and incident timelines.
Hands-on example
Examples:
index=prod_app level=ERROR | stats count by service,error_code
index=prod_app | eval is_error=if(level='ERROR',1,0) | stats sum(is_error) by service
index=prod_app service=checkout | timechart span=5m count by levelPreparing for an interview?
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Observability interview questions
- What is a Splunk source, sourcetype, and host? [Intermediate]
- What is the difference between a universal and a heavy forwarder? [Intermediate]
- What is the difference between a Splunk forwarder, indexer, and search head? [Intermediate]
- How do you build a Splunk dashboard, and when is it better than Grafana? [Advanced]
- What is the Splunk data pipeline (input, parsing, indexing, search)? [Intermediate]
- What is data retention and a bucket lifecycle (hot, warm, cold, frozen) in Splunk? [Advanced]
- How do you correlate logs and metrics during an incident? [Advanced]
- What is Wavefront (Tanzu Observability), and what is it used for? [Advanced]