{"id":30445,"date":"2026-12-05T22:05:23","date_gmt":"2026-12-05T22:05:23","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=30445"},"modified":"2026-12-05T22:05:23","modified_gmt":"2026-12-05T22:05:23","slug":"splunk-tutorials-data-models","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/splunk-tutorials-data-models\/","title":{"rendered":"Splunk Tutorials: Data Models"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">A Splunk data model is a knowledge object that gives your event data a structure: datasets with defined constraints and fields. Pivot, the <code>tstats<\/code> 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.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">Knowedge Objects that provide the data structure that drives pivot by Admin &amp; Power users\r\n\r\nIts kind of of Framework.\r\nSetting=&gt;Data Models=App=&gt;Search &amp; reporting\r\n\r\nData Model \r\n\tData Sets\r\n\t\tSlices of Data\r\n\r\nInstance Pivot\r\n---------------\r\nindex=* sourcetype=access* status=<span class=\"hljs-number\">404<\/span>\r\n\r\nVisualization =&gt; Pivot\r\n\r\nDatsets\r\n======================\r\nhost=homework\r\n\r\n&amp; Create it &amp; Add a field\r\n\r\nbackupduration\r\nbackupvolume\r\ndate\r\ndestip\r\nlevel\r\nphyaddr\r\nsystemid<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">What a data model is and why it matters<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A data model maps semantic knowledge about your data at search time. It does not change indexed data. Instead it defines <strong>datasets<\/strong>, which are named slices of events selected by constraints, and the <strong>fields<\/strong> each dataset exposes. Admin and power users normally build data models. Other users can then create reports and charts in Pivot without writing SPL.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Data models also feed <code>tstats<\/code>, 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.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Level<\/th><th>What it is<\/th><th>Example<\/th><\/tr><\/thead><tbody><tr><td>Data model<\/td><td>A container for related datasets, stored per app<\/td><td><code>Homework<\/code><\/td><\/tr><tr><td>Root dataset<\/td><td>Top-level dataset defined by a constraint or search<\/td><td><code>Backup<\/code> with constraint <code>host=homework<\/code><\/td><\/tr><tr><td>Child dataset<\/td><td>Inherits the parent&#039;s constraints and fields, then adds its own constraint<\/td><td><code>Errors<\/code> with <code>level=ERROR<\/code><\/td><\/tr><tr><td>Field<\/td><td>Attribute exposed for Pivot and SPL<\/td><td><code>backupduration<\/code>, <code>destip<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Root dataset type<\/th><th>Defined by<\/th><th>Can be accelerated<\/th><\/tr><\/thead><tbody><tr><td>Root event<\/td><td>A simple constraint search such as <code>index=main host=homework<\/code><\/td><td>Yes, together with its child datasets<\/td><\/tr><tr><td>Root search<\/td><td>A full search string<\/td><td>Only if the search uses only streaming commands<\/td><\/tr><tr><td>Root transaction<\/td><td>Grouping of events from other datasets<\/td><td>No<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Corrections to the notes above<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Knowedge Objects<\/strong> should read <strong>Knowledge Objects<\/strong>, and <strong>Datsets<\/strong> should read <strong>Datasets<\/strong>.<\/li>\n\n\n<li><strong>Instance Pivot<\/strong> is called <strong>Instant Pivot<\/strong>. It turns the results of an ad hoc search into a Pivot without first creating a data model.<\/li>\n\n\n<li>The path <code>Setting=&gt;Data Models=App=&gt;Search &amp; reporting<\/code> means: go to <strong>Settings &gt; Data models<\/strong>, then set the <strong>App<\/strong> filter or app context to <strong>Search &amp; Reporting<\/strong>. The model is saved in the app you select.<\/li>\n\n\n<li><code>index=* sourcetype=access* status=404<\/code> works, but <code>index=*<\/code> searches every index you have access to. Name the index, for example <code>index=web sourcetype=access_combined status=404<\/code>, so the search is faster and the resulting data model is more precise.<\/li>\n\n\n<li>Instant Pivot only works on a search that has <strong>no transforming commands<\/strong> (no <code>stats<\/code>, <code>chart<\/code>, <code>timechart<\/code>). Run the search, open the <strong>Statistics<\/strong> or <strong>Visualization<\/strong> tab and click the <strong>Pivot<\/strong> button.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Create a data model and a root dataset<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The steps below repeat the <code>host=homework<\/code> example above with the settings you need to choose.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to <strong>Settings &gt; Data models<\/strong> and click <strong>New Data Model<\/strong>.<\/li>\n\n\n<li>Enter a <strong>Title<\/strong> (for example <code>Homework<\/code>) and an <strong>ID<\/strong>. The ID may contain only letters, numbers, underscores and hyphens, and it cannot be changed later.<\/li>\n\n\n<li>Choose the <strong>App<\/strong> (for example <strong>Search &amp; Reporting<\/strong>), add a description and click <strong>Create<\/strong>.<\/li>\n\n\n<li>Click <strong>Add Dataset &gt; Root Event<\/strong>. Give it a name such as <code>Backup<\/code> and set the constraint to <code>index=main host=homework<\/code>. Use the index that actually holds the data.<\/li>\n\n\n<li>Click <strong>Preview<\/strong> to confirm that the constraint returns the events you expect, then click <strong>Save<\/strong>.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> 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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Add fields to the dataset<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">With the <code>Backup<\/code> dataset selected, click <strong>Add Field<\/strong>. The options are <strong>Auto-Extracted<\/strong> (fields Splunk already extracts), <strong>Eval Expression<\/strong>, <strong>Lookup<\/strong>, <strong>Regular Expression<\/strong> and <strong>Geo IP<\/strong>. For the fields in the example above, choose <strong>Auto-Extracted<\/strong>, tick each field and set its type and flag.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Field<\/th><th>Suggested type<\/th><th>Reason<\/th><\/tr><\/thead><tbody><tr><td>backupduration<\/td><td>Number<\/td><td>Lets you use avg, sum and max in Pivot<\/td><\/tr><tr><td>backupvolume<\/td><td>Number<\/td><td>Lets you sum volumes<\/td><\/tr><tr><td>date<\/td><td>String<\/td><td>Use <code>_time<\/code> for time-based charts; keep this as a label<\/td><\/tr><tr><td>destip<\/td><td>IPV4<\/td><td>Allows IP-aware filtering and Geo IP fields<\/td><\/tr><tr><td>level<\/td><td>String<\/td><td>Used for split-by and filters<\/td><\/tr><tr><td>phyaddr<\/td><td>String<\/td><td>MAC address, used as a label<\/td><\/tr><tr><td>systemid<\/td><td>String<\/td><td>Identifier for row splits<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Each field also has a flag. <strong>Optional<\/strong> is the default. <strong>Required<\/strong> drops events that lack the field. <strong>Hidden<\/strong> keeps the field out of Pivot while child datasets and calculations can still use it. Inherited fields <code>_time<\/code>, <code>host<\/code>, <code>source<\/code> and <code>sourcetype<\/code> are added automatically.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To add a child dataset, select <code>Backup<\/code>, click <strong>Add Dataset &gt; Child<\/strong> and set an extra constraint such as <code>level=ERROR<\/code>. The child inherits all of the fields above.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Query a data model with SPL<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Pivot is not the only way to use a data model. The commands below all read the <code>Homework<\/code> model and its <code>Backup<\/code> dataset.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">| datamodel Homework Backup search\n\n| from datamodel:<span class=\"hljs-string\">\"Homework.Backup\"<\/span>\n| stats avg(backupduration) by systemid\n\n| tstats count avg(Backup.backupduration) <span class=\"hljs-keyword\">AS<\/span> avg_duration\n    from datamodel=Homework.Backup\n    by Backup.systemid\n\n| pivot Homework Backup count(Backup) <span class=\"hljs-keyword\">AS<\/span> <span class=\"hljs-string\">\"Backups\"<\/span> SPLITROW systemid <span class=\"hljs-keyword\">AS<\/span> <span class=\"hljs-string\">\"System\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ul class=\"wp-block-list\">\n<li><code>datamodel ... search<\/code> returns the dataset&#039;s events, with field names prefixed by the dataset name (for example <code>Backup.systemid<\/code>).<\/li>\n\n\n<li><code>from datamodel:<\/code> returns the dataset&#039;s events so that you can pipe them into normal SPL.<\/li>\n\n\n<li><code>tstats<\/code> is the fastest option. In <code>tstats<\/code>, dataset fields must be written with the dataset prefix, such as <code>Backup.backupduration<\/code>. Add <code>summariesonly=true<\/code> to read only accelerated summaries.<\/li>\n\n\n<li><code>pivot<\/code> is the SPL that the Pivot editor generates. You can paste it into dashboards.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Accelerate the data model<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Acceleration builds summaries in the background so that Pivot and <code>tstats<\/code> searches return quickly over long time ranges. Before you can enable it, change the model&#039;s permissions from <strong>Private<\/strong> to <strong>App<\/strong> or <strong>All apps<\/strong>, because private data models cannot be accelerated. Then use <strong>Edit &gt; Edit Acceleration<\/strong>, tick <strong>Accelerate<\/strong> and choose a <strong>Summary Range<\/strong> such as 7 days or 1 month.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The setting is written to <code>datamodels.conf<\/code> in the app. The model definition itself is stored as JSON under <code>data\/models\/<\/code> in the same app.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># $SPLUNK_HOME\/etc\/apps\/search\/local\/datamodels.conf<\/span>\n&#91;Homework]\nacceleration = <span class=\"hljs-keyword\">true<\/span>\nacceleration.earliest_time = <span class=\"hljs-number\">-7<\/span>d<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> 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 <strong>Settings &gt; Data models<\/strong> by expanding the model&#039;s row.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common problems and fixes<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Symptom<\/th><th>Likely cause<\/th><th>Fix<\/th><\/tr><\/thead><tbody><tr><td>Dataset preview shows no events<\/td><td>Wrong index, or the time range is too narrow<\/td><td>Add the correct <code>index=<\/code> to the constraint and widen the time picker<\/td><\/tr><tr><td>Field missing in Add Field &gt; Auto-Extracted<\/td><td>The field is not extracted at search time for the sample events<\/td><td>Create a field extraction first, or add it as a Regular Expression field<\/td><\/tr><tr><td>Accelerate option is greyed out<\/td><td>Model is private, or the dataset is a transaction or non-streaming search dataset<\/td><td>Share the model at App level or wider, and use root event datasets<\/td><\/tr><tr><td><code>tstats<\/code> returns nothing for a field<\/td><td>Field name used without the dataset prefix<\/td><td>Use <code>Backup.fieldname<\/code> in <code>tstats<\/code><\/td><\/tr><tr><td>Pivot button missing after a search<\/td><td>The search contains a transforming command<\/td><td>Remove <code>stats<\/code>, <code>chart<\/code> or <code>timechart<\/code> and run it again<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">What is the difference between a data model and a dataset in Splunk?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Do I need to accelerate a data model to use it?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What is Instant Pivot in Splunk?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why can&#039;t I enable acceleration on my data model?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I reference data model fields in tstats?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Prefix each field with its dataset name, for example <code>tstats count from datamodel=Homework.Backup by Backup.systemid<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related tutorials<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/splunk-tutorials-splunk-commands-reference\/\">Splunk Tutorials: Splunk Commands Reference<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/category\/monitoring-observability\/splunk\/\">More Splunk tutorials<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/5-day-program-splunk-for-email-security-siem-endpoint-security\/\">5-Day Program: Splunk for Email Security, SIEM &amp; Endpoint Security<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/category\/data-engineering-analytics\/\">More Data Engineering &amp; Analytics tutorials<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5207,26158],"tags":[26271],"class_list":["post-30445","post","type-post","status-publish","format-standard","hentry","category-splunk","category-data-engineering-analytics","tag-splunk-spl"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/30445","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=30445"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/30445\/revisions"}],"predecessor-version":[{"id":80686,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/30445\/revisions\/80686"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=30445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=30445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=30445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}