Splunk tstats & CIM Data Model Guide (Examples & Performance)

By Splunky · Updated November 20, 2026

Short answer: | tstats runs statistical aggregations directly against Splunk's high-speed TSIDX index files and accelerated Common Information Model (CIM) data models rather than decompressing raw events. Use summariesonly=t for predictable sub-second detections, filter early inside WHERE, and pair CIM Technology Add-ons with Authentication, Network_Traffic, Web, Endpoint, and Risk data models.

Whether you are tuning Splunk Enterprise Security (ES) correlation searches, studying for SPLK-1002, SPLK-1004, or SPLK-5001 (CDA), or replacing slow dashboards, mastering tstats and CIM acceleration is the highest-leverage performance skill in SPL. For general search commands, keep our SPL Cheat Sheet open alongside this guide.

1. tstats vs datamodel vs raw search | stats

Standard Splunk searches retrieve compressed raw events from bucket journals (journal.zst) and extract fields at search time. tstats bypasses raw event retrieval completely by reading .tsidx lexicon files and Data Model Acceleration (DMA) summary buckets.

Dimension| tstats| datamodel / | pivotRaw search | stats
Underlying data storePre-computed TSIDX summary files (DMA) plus bucket-level TSIDX lexicon metadataReads accelerated DMA summaries when available, or expands to raw events on un-accelerated modelsDecompresses and scans raw journal.zst / journal.gz event slices from disk
Typical query speedSub-second to a few seconds across weeks or months of dataFast when summarized, but significantly slower when unpacking or pivoting raw eventsSeconds to minutes (scales linearly with raw event volume and time range)
Eligible fieldsIndexed fields (index, host, source, sourcetype, _time), PREFIX()/TERM() tokens, and accelerated DM fieldsAll fields defined in the data model (including search-time calculated fields)Every field: indexed metadata plus search-time rex, eval, FIELDALIAS, and lookups
Resource trade-offConsumes extra indexer disk (~3.4x raw for high-cardinality DMA) and periodic summarization CPULower setup cost if un-accelerated, higher search-head/indexer CPU per queryZero DMA disk overhead, highest search-time I/O and CPU cost
Best use casesES correlation searches, RBA risk rules, SOC dashboards, high-volume metrics and trendingInteractive Pivot exploration, inspecting a data model schema during TA validationAd-hoc forensic investigation, raw payload grep, un-modeled custom fields

2. tstats syntax & essential flags

tstats is a generating command, meaning it must start with a leading pipe (| tstats) before any search terms. Its core anatomy follows:

| tstats [summariesonly=t|f] [allow_old_summaries=t|f] [prestats=t|f]
    <stats-aggregates>
  FROM datamodel=<Model_Name>[.<Dataset>]
  WHERE <tsidx-or-dm-filters>
  BY <indexed-or-dm-fields> [_time span=<interval>]
Argument / ClauseBehaviorWhen to use it
summariesonly=tReads only completed DMA summary buckets; skips unsummarized hot-bucket tails.Mandatory for scheduled ES correlation searches to prevent raw-scan CPU spikes.
allow_old_summaries=tIncludes older DMA buckets created before the data model definition was edited.Useful after adding a field to a DM without waiting for a full rebuild; beware schema drift.
prestats=tOutputs raw statistical state instead of formatted rows for downstream stats or timechart.Combine multiple tstats searches with append=t or feed timechart for multi-dataset charts.
PREFIX(key=)Extracts values immediately following an indexed key= prefix directly from TSIDX.Fast aggregations on key=value logs (for example PREFIX(action=)) without an accelerated DM.
WHERE ... vs | whereFilters inside tstats WHERE before aggregation; nodename= restricts to a child dataset.Post-pipe | where evaluates only after TSIDX aggregation (use it for aggregate thresholds like count > 50).

Using prestats=t and PREFIX() in practice

prestats=t lets you combine multiple accelerated queries with append=t or feed timechart without losing statistical accuracy (for example distinct counts or averages across datasets):

| tstats prestats=t summariesonly=t count
  FROM datamodel=Authentication
  WHERE Authentication.action="failure"
  BY _time span=1h, Authentication.action
| tstats prestats=t summariesonly=t append=t count
  FROM datamodel=Authentication
  WHERE Authentication.action="success"
  BY _time span=1h, Authentication.action
| timechart span=1h count BY Authentication.action

Meanwhile, TERM() in WHERE and PREFIX() in BY unlock fast TSIDX aggregations on un-modeled key=value logs without building a Data Model (note that BY PREFIX(action=) outputs a column named action=):

| tstats count WHERE index=firewall sourcetype=pan:traffic TERM(action=*)
  BY PREFIX(action=), host
| rename "action=" AS fw_action

WHERE vs post-pipe | where

Put every event-level filter inside tstats ... WHERE (including nodename= for child datasets). Reserve post-pipe | where strictly for filtering aggregated metrics such as | where count > 50 or | where risk_total >= 100.

3. CIM data models & copy-ready SPL examples

The Splunk Common Information Model (CIM) standardizes vendor fields across firewalls, EDR agents, proxies, and identity providers so one detection works across all data sources. Below are the five high-frequency models used in SIEM operations and Splunk certifications.

Authentication

Datasets: Authentication (root), Failed_Authentication, Successful_Authentication, Default_Authentication
Key fields: Authentication.action, Authentication.user, Authentication.src, Authentication.dest, Authentication.app
Primary use case: Brute-force and password-spray detection across Windows Security, Entra ID, Okta, SSH, and VPN logs.

| tstats summariesonly=t count, dc(Authentication.user) AS targeted_users
  FROM datamodel=Authentication
  WHERE nodename=Authentication.Failed_Authentication
  BY Authentication.src, _time span=10m
| where count >= 50 AND targeted_users >= 10

Network_Traffic

Datasets: All_Traffic (root)
Key fields: All_Traffic.action, All_Traffic.src, All_Traffic.dest, All_Traffic.dest_port, All_Traffic.bytes_out
Primary use case: Blocked egress spikes, C2 beaconing port sweeps, and anomalous outbound data transfer volume.

| tstats summariesonly=t count, sum(All_Traffic.bytes_out) AS total_bytes
  FROM datamodel=Network_Traffic.All_Traffic
  WHERE All_Traffic.action="allowed" AND All_Traffic.dest_port IN (22, 445, 3389)
  BY All_Traffic.src, All_Traffic.dest, All_Traffic.dest_port
| eval mb_out=round(total_bytes/1024/1024, 2)
| sort - mb_out

Web

Datasets: Web (root), Proxy
Key fields: Web.status, Web.http_method, Web.url, Web.src, Web.dest, Web.http_user_agent
Primary use case: HTTP 5xx service outage spikes, directory brute-forcing, and suspicious POST bursts.

| tstats summariesonly=t count, dc(Web.url) AS distinct_uris
  FROM datamodel=Web
  WHERE Web.status>=400 AND Web.http_method="POST"
  BY Web.src, Web.dest, _time span=5m
| where count > 100 AND distinct_uris > 25

Endpoint (Processes)

Datasets: Processes, Ports, Services, Filesystem, Registry
Key fields: Processes.process_name, Processes.process, Processes.parent_process_name, Processes.dest, Processes.user
Primary use case: Living-off-the-Land (LOLBins) and encoded PowerShell execution spawned by office or web processes.

| tstats summariesonly=t count, values(Processes.process) AS cmdlines
  FROM datamodel=Endpoint.Processes
  WHERE Processes.process_name="powershell.exe"
    AND Processes.parent_process_name IN ("winword.exe", "excel.exe", "w3wp.exe")
  BY Processes.dest, Processes.user, _time span=15m

Risk (RBA)

Datasets: All_Risk (root)
Key fields: All_Risk.risk_object, All_Risk.risk_object_type, All_Risk.risk_score (or All_Risk.calculated_risk_score), All_Risk.annotations.mitre_attack.mitre_tactic_id
Primary use case: Risk-Based Alerting (RBA) Risk Incident Rules firing when cumulative entity risk crosses 100 across multiple MITRE tactics.

| tstats summariesonly=t
    sum(All_Risk.risk_score) AS risk_total,
    dc(All_Risk.annotations.mitre_attack.mitre_tactic_id) AS tactic_count,
    values(All_Risk.search_name) AS risk_rules
  FROM datamodel=Risk.All_Risk
  BY All_Risk.risk_object, All_Risk.risk_object_type
| where risk_total >= 100 AND tactic_count >= 3

4. CIM onboarding & acceleration checklist

Installing a Technology Add-on (TA) alone does not automatically populate tstats dashboards. Verify all five steps end-to-end before promoting a correlation search:

  1. Verify field normalization (props.conf): Confirm the TA maps vendor fields to CIM names via FIELDALIAS- and EVAL- (for example normalizing Permit and Allow to action="allowed").
  2. Confirm Event Types and Tags (eventtypes.conf / tags.conf): CIM models match events by tag constraints (for instance authentication, network, and communicate). Missing tags silently exclude events from the data model.
  3. Whitelist custom indexes in CIM macros: Update macros such as cim_Authentication_indexes or cim_Network_Traffic_indexes (in macros.conf) so Splunk limits DMA summarization to relevant indexes instead of scanning index=*.
  4. Enable Data Model Acceleration (DMA): Set an appropriate summary range (commonly 1 to 7 days for high-volume Endpoint/Network models, longer for Authentication) and monitor rebuild status in the Data Models manager.
  5. Validate coverage with a baseline tstats check: Run the audit query below to confirm each expected sourcetype appears in the accelerated summary:
| tstats summariesonly=t count, latest(_time) AS last_seen
  FROM datamodel=Authentication
  BY index, sourcetype
| eval last_seen=strftime(last_seen, "%Y-%m-%d %H:%M:%S")
| sort - count

5. Common tstats & CIM pitfalls

  • Querying search-time rex or eval fields directly with tstats: tstats reads only TSIDX lexicons and accelerated data model summaries. A field extracted on the fly with | rex or created in props.conf as a non-accelerated EXTRACT- stanza will return zero results in tstats.
  • Omitting summariesonly=t in scheduled correlation searches: By default, summariesonly=false. If an indexer falls behind on DMA summarization, Splunk falls back to scanning raw buckets on every 5-minute cron cycle, causing search concurrency bottlenecks.
  • Using post-pipe | where instead of tstats ... WHERE: Putting field filters after the first pipe forces tstats to aggregate every event in the time window before discarding unwanted rows. Always push equality, wildcard, IN(), and nodename= predicates inside the WHERE clause.
  • Missing dataset prefixes or wrong All_Risk score field: Data model fields require their dataset prefix (for example All_Traffic.dest or Processes.user, not bare dest). In the Risk data model, verify whether your Splunk ES version populates All_Risk.risk_score or All_Risk.calculated_risk_score.
  • Forgetting cim_<model>_indexes macro whitelists: Even with a compliant TA installed, CIM searches stay empty if custom indexes are not added to the cim_Authentication_indexes or cim_Network_Traffic_indexes macros and tagged properly in tags.conf.

Frequently asked questions

Why does | tstats return zero results on a field I extracted with rex?

tstats never opens raw event payloads; it queries only TSIDX metadata (index, host, source, sourcetype, _time, PREFIX/TERM tokens) and pre-built Data Model Acceleration summaries. To query a field with tstats, either accelerate it inside a CIM Data Model or configure an index-time extraction.

What is the difference between summariesonly=true and summariesonly=false?

With summariesonly=true (or summariesonly=t), tstats reads strictly from accelerated DMA TSIDX summaries and skips unsummarized hot-bucket events. With summariesonly=false (the default), Splunk also scans raw events in buckets that have not been summarized yet, which guarantees completeness at the cost of higher CPU and slower runtime.

When should I use prestats=true with tstats?

Use prestats=true when you need to pass intermediate statistical counts into a downstream transforming command such as | timechart or | stats, or when combining results from multiple tstats queries via | tstats prestats=t append=t before a final aggregation.

How do I verify that a CIM data model is accelerated and populated for my sourcetype?

Run | tstats summariesonly=t count FROM datamodel=Authentication BY index, sourcetype across a recent window such as earliest=-24h. If expected indexes are missing, check eventtypes.conf, tags.conf, and the cim_Authentication_indexes macro, then confirm acceleration status under Settings > Data models.

Can I use tstats without an accelerated Data Model?

Yes. You can query any index using indexed metadata fields (index, host, source, sourcetype, _time) and TSIDX word-boundary tokens via TERM() in WHERE and PREFIX(key=) in BY, for example | tstats count WHERE index=firewall TERM(action=*) BY PREFIX(action=) (which outputs a column named action=).

Practice tstats & CIM in interactive labs