RousselTMLEARNING

Article · Splunk: from discovery to expertise

Advanced SPL and knowledge objects

1. Knowledge objects #

Giving meaning to data.

Overview #

Knowledge objects
ObjectRole
Lookupenriches with a table (CSV, KV store, external): host owner, code label
Event typenamed search classifying events (eventtype=failed_login)
Taglabel on a value or event type (tag=authentication)
Alias, calculated fieldharmonize names (src_ip → src) and compute on the fly
Macroreusable SPL fragment: `web_errors(5)`
Data modelhierarchical schema (CIM) used by dashboards and tstats

Each object has an owner and a scope (private, app, global): share at app level what the team uses.

Lookups #

| inputlookup http_status.csv
index=web | lookup http_status.csv status OUTPUT category
index=web | stats count BY client_ip | lookup geo_clients client_ip OUTPUT country
index=security action=blocked | stats latest(_time) AS seen BY src_ip | outputlookup blocked_ips.csv
Best practice : For tables that change often or exceed a few tens of thousands of rows, use a KV store collection rather than a CSV.

2. Advanced statistics #

Comparing each event with its group.

eventstats and streamstats #

-- Requests 3 times slower than their URL's average
index=web | eventstats avg(duration_ms) AS avg BY uri | where duration_ms > 3*avg

-- Gap between two successive logins of the same user
index=security action=success | sort 0 user _time
| streamstats current=f last(_time) AS previous BY user | eval gap_min = round((_time-previous)/60)

transaction or stats? #

Relative cost
-- Session duration: transaction (simple but costly)
index=web | transaction session_id maxspan=30m | stats avg(duration)
-- Same result with stats (much faster)
index=web | stats min(_time) AS start, max(_time) AS end BY session_id | eval duration = end - start | stats avg(duration)

transaction keeps events in memory and does not distribute across indexers; keep it for cases where order or start and end markers (startswith, endswith) are essential.

3. tstats, data models and CIM #

Searching indexes, not events.

tstats #

| tstats count WHERE index=web BY sourcetype, host
| tstats count WHERE index=* BY _time span=1h, index
| tstats summariesonly=true count FROM datamodel=Web WHERE Web.status>=500 BY Web.uri_path
| tstats summariesonly=true dc(Authentication.user) FROM datamodel=Authentication WHERE Authentication.action=failure BY Authentication.src
  • tstats reads index files (tsidx) instead of raw events: on indexed fields (index, sourcetype, host, source, _time) or on an accelerated data model, it answers in seconds over billions of events.
  • The CIM (Common Information Model) defines common models: Authentication, Network Traffic, Web, Endpoint, Malware… Add-ons map their data to it, making Enterprise Security and dashboards source-independent.
  • Data model acceleration builds summaries continuously, at the cost of disk space and indexer compute.

Optimizing a search #

  1. Restrict index, sourcetype and time range as early as possible.
  2. Put filters in the initial search rather than in a later where.
  3. Use fields early to keep only useful fields.
  4. Prefer stats to transaction, join and subsearches.
  5. Switch to tstats as soon as the question involves indexed fields or a data model.
  6. Check the cost with the Job Inspector (time per command, events scanned).
Good to know : SPL2, used by Edge Processor, Ingest Processor and some apps, revisits SPL with a more SQL-like syntax (from, where, select); SPL remains the search language in Splunk Enterprise.

Commands to know #

Commands to know
  • | tstats count where index=web by sourcetype : count without reading events
  • | lookup http_status.csv status OUTPUT categorie : enrich with a table
  • | eventstats avg(x) as moy by groupe : add a group statistic to each event
  • | datamodel Web search : explore a data model
  • `ma_macro(arg)` : call a macro

Sources #

Checked in November 2026 (Splunk Enterprise 10.6): check the release notes before relying on a detail, Splunk Cloud Platform evolves faster than the on-premises version.

📄 Advanced SPL and knowledge objects →

My progress

  • ⏱ Estimated time : ≈ 6 min

Sign in to track your progress and take notes. Sign in

⭐ Rate this lesson

5.0 initial rating from the teaching team

Sign in to rate this lesson →

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

Recommended Articles

Kibana and Elastic Observability best practices

Checklist for running Kibana in production: versions, security, spaces and roles, versioned dashb...

Dynatrace security and governance: advanced IAM, policies, SSO, audit and data protection

Secure and govern Dynatrace: SSO and SCIM, groups, IAM policies with conditions, security context...

Sources, destinations and routes in Cribl Stream

Receiving and sending data with Cribl Stream: push, pull, collector and internal sources, event b...

Logs with OpenTelemetry: data model, appenders, correlation and collection

Master the log signal: the LogRecord data model, the Logs Bridge API and appenders (Logback, Log4...

The observability trilemma: cost, completeness and performance, and how solutions resolve it

Understanding the observability trilemma (cost, data completeness, query performance), its three ...

IaaS, PaaS, SaaS: differences and examples of cloud service models

IaaS, PaaS, SaaS: what is the difference? Definitions, concrete examples (AWS, Azure, Google Clou...

Ansible: generating dynamic files with Jinja2 and facts

Create dynamic configuration files: Jinja2 templates, variables, facts, filters, loops, condition...

Advanced Kibana: data views, Lens, dashboards, alerting and reporting

Use Kibana in depth: data views and runtime fields, Discover, Lens and formulas, dashboards and c...

Datadog platform architecture: sites, organizations, keys and data model

Understand Datadog's architecture: data sources (agent, cloud integrations, SDKs, OpenTelemetry),...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!