A Splunk data model is a knowledge object that gives your event data a structure: datasets with defined constraints and fields. Pivot, the tstats command and data model acceleration all depend on that structure. This page builds on the notes below. It shows how to create a data model and its datasets, add fields, use Instant Pivot, query the model with SPL and accelerate it.
Knowedge Objects that provide the data structure that drives pivot by Admin & Power users
Its kind of of Framework.
Setting=>Data Models=App=>Search & reporting
Data Model
Data Sets
Slices of Data
Instance Pivot
---------------
index=* sourcetype=access* status=404
Visualization => Pivot
Datsets
======================
host=homework
& Create it & Add a field
backupduration
backupvolume
date
destip
level
phyaddr
systemidCode language: PHP (php)
What a data model is and why it matters
A data model maps semantic knowledge about your data at search time. It does not change indexed data. Instead it defines datasets, which are named slices of events selected by constraints, and the fields each dataset exposes. Admin and power users normally build data models. Other users can then create reports and charts in Pivot without writing SPL.
Data models also feed tstats, the Common Information Model (CIM) and Splunk Enterprise Security. When a model is accelerated, searches against it read pre-built summaries, which can be much faster than searching raw events.
| Level | What it is | Example |
|---|---|---|
| Data model | A container for related datasets, stored per app | Homework |
| Root dataset | Top-level dataset defined by a constraint or search | Backup with constraint host=homework |
| Child dataset | Inherits the parent's constraints and fields, then adds its own constraint | Errors with level=ERROR |
| Field | Attribute exposed for Pivot and SPL | backupduration, destip |
| Root dataset type | Defined by | Can be accelerated |
|---|---|---|
| Root event | A simple constraint search such as index=main host=homework | Yes, together with its child datasets |
| Root search | A full search string | Only if the search uses only streaming commands |
| Root transaction | Grouping of events from other datasets | No |
Corrections to the notes above
- Knowedge Objects should read Knowledge Objects, and Datsets should read Datasets.
- Instance Pivot is called Instant Pivot. It turns the results of an ad hoc search into a Pivot without first creating a data model.
- The path
Setting=>Data Models=App=>Search & reportingmeans: go to Settings > Data models, then set the App filter or app context to Search & Reporting. The model is saved in the app you select. index=* sourcetype=access* status=404works, butindex=*searches every index you have access to. Name the index, for exampleindex=web sourcetype=access_combined status=404, so the search is faster and the resulting data model is more precise.- Instant Pivot only works on a search that has no transforming commands (no
stats,chart,timechart). Run the search, open the Statistics or Visualization tab and click the Pivot button.
Create a data model and a root dataset
The steps below repeat the host=homework example above with the settings you need to choose.
- Go to Settings > Data models and click New Data Model.
- Enter a Title (for example
Homework) and an ID. The ID may contain only letters, numbers, underscores and hyphens, and it cannot be changed later. - Choose the App (for example Search & Reporting), add a description and click Create.
- Click Add Dataset > Root Event. Give it a name such as
Backupand set the constraint toindex=main host=homework. Use the index that actually holds the data. - Click Preview to confirm that the constraint returns the events you expect, then click Save.
Note: Constraints work like the base search of a dataset. Keep them simple and selective, with index, sourcetype and host, so that the dataset can be accelerated later.
Add fields to the dataset
With the Backup dataset selected, click Add Field. The options are Auto-Extracted (fields Splunk already extracts), Eval Expression, Lookup, Regular Expression and Geo IP. For the fields in the example above, choose Auto-Extracted, tick each field and set its type and flag.
| Field | Suggested type | Reason |
|---|---|---|
| backupduration | Number | Lets you use avg, sum and max in Pivot |
| backupvolume | Number | Lets you sum volumes |
| date | String | Use _time for time-based charts; keep this as a label |
| destip | IPV4 | Allows IP-aware filtering and Geo IP fields |
| level | String | Used for split-by and filters |
| phyaddr | String | MAC address, used as a label |
| systemid | String | Identifier for row splits |
Each field also has a flag. Optional is the default. Required drops events that lack the field. Hidden keeps the field out of Pivot while child datasets and calculations can still use it. Inherited fields _time, host, source and sourcetype are added automatically.
To add a child dataset, select Backup, click Add Dataset > Child and set an extra constraint such as level=ERROR. The child inherits all of the fields above.
Query a data model with SPL
Pivot is not the only way to use a data model. The commands below all read the Homework model and its Backup dataset.
| datamodel Homework Backup search
| from datamodel:"Homework.Backup"
| stats avg(backupduration) by systemid
| tstats count avg(Backup.backupduration) AS avg_duration
from datamodel=Homework.Backup
by Backup.systemid
| pivot Homework Backup count(Backup) AS "Backups" SPLITROW systemid AS "System"Code language: PHP (php)
datamodel ... searchreturns the dataset's events, with field names prefixed by the dataset name (for exampleBackup.systemid).from datamodel:returns the dataset's events so that you can pipe them into normal SPL.tstatsis the fastest option. Intstats, dataset fields must be written with the dataset prefix, such asBackup.backupduration. Addsummariesonly=trueto read only accelerated summaries.pivotis the SPL that the Pivot editor generates. You can paste it into dashboards.
Accelerate the data model
Acceleration builds summaries in the background so that Pivot and tstats searches return quickly over long time ranges. Before you can enable it, change the model's permissions from Private to App or All apps, because private data models cannot be accelerated. Then use Edit > Edit Acceleration, tick Accelerate and choose a Summary Range such as 7 days or 1 month.
The setting is written to datamodels.conf in the app. The model definition itself is stored as JSON under data/models/ in the same app.
# $SPLUNK_HOME/etc/apps/search/local/datamodels.conf
[Homework]
acceleration = true
acceleration.earliest_time = -7dCode language: PHP (php)
Note: Summaries use disk space on the indexers and take CPU time to build. Choose the shortest summary range that covers your reports, and check build status under Settings > Data models by expanding the model's row.
Common problems and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Dataset preview shows no events | Wrong index, or the time range is too narrow | Add the correct index= to the constraint and widen the time picker |
| Field missing in Add Field > Auto-Extracted | The field is not extracted at search time for the sample events | Create a field extraction first, or add it as a Regular Expression field |
| Accelerate option is greyed out | Model is private, or the dataset is a transaction or non-streaming search dataset | Share the model at App level or wider, and use root event datasets |
tstats returns nothing for a field | Field name used without the dataset prefix | Use Backup.fieldname in tstats |
| Pivot button missing after a search | The search contains a transforming command | Remove stats, chart or timechart and run it again |
Frequently asked questions
What is the difference between a data model and a dataset in Splunk?
A data model is the container. Datasets are the hierarchical slices of data inside it, each defined by constraints and fields. Pivot and tstats always target a specific dataset within a model.
Do I need to accelerate a data model to use it?
No. Pivot, datamodel, from and tstats all work on unaccelerated models by searching raw events. Acceleration only makes those searches faster, at the cost of disk space and background processing.
What is Instant Pivot in Splunk?
Instant Pivot opens the Pivot editor directly from a non-transforming search, using a temporary data model. If you save the pivot as a report or dashboard panel, Splunk asks you to save that data model.
Why can't I enable acceleration on my data model?
Private data models cannot be accelerated, so share the model at App or global level first. Transaction datasets, and root search datasets that use non-streaming commands, also cannot be accelerated.
How do I reference data model fields in tstats?
Prefix each field with its dataset name, for example tstats count from datamodel=Homework.Backup by Backup.systemid.
Related tutorials
- Splunk Tutorials: Splunk Commands Reference
- More Splunk tutorials
- 5-Day Program: Splunk for Email Security, SIEM & Endpoint Security
- More Data Engineering & Analytics tutorials
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services โ all in one place.
Explore Hospitals