Splunk Search

help on tsats command with datamodel

jip31
Motivator

Hi

I have created a basic datamodel called "TEST"

I try to query on this datamodel with tstats but the only piece of code which return value is :

 

| tstats count from datamodel=TEST

 

 But i cant se the events related to this request

And if i try to be more explicit in my request like below, I have no results

 

| tstats count from datamodel=TEST where EventCode=100

 

 So what is the problem?

Other question : what is the interest to use datamodel and pivot command since it's possible to query on a datamodel without SPL?

Thanks

Tags (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jip31,

as you can read at https://docs.splunk.com/Documentation/Splunk/9.1.1/Knowledge/Aboutdatamodels , data models are tables containing the fields extracted from your events, but yu don't have the events, so youcannot see then in search results.

Data models are very useful because they are very fast in searching for fields.

they have a very fixed syntax in the order of options (as oter Splunk commands) so you have to put exactly the option in the required order.

Then when you use data model fields, you have to remember to use the datamodel name, so, in in your TEST datamodel you have the EventCode field, you have to use:

| tstats count from datamodel=TEST where TEST.EventCode=100

Datamodel are very important when you have structured data to have very fast searches on large amount of data.

Ciao.

Giuseppe

0 Karma

jip31
Motivator

Hi Gcusello

I can see the fields extracted in my datamodel

jip31_0-1698654397189.png

And even if i use your search below I have no results

| tstats count from datamodel=TEST where TEST.EventCode=100

 

I have only results heriteld fields like host, sourcetype, source

jip31_1-1698654573699.png

 

 

Tags (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jip31,

are you sure that data are in your datamodel?

test this using pivot.

Ciao.

Giuseppe

0 Karma

jip31
Motivator

it seems to be

jip31_0-1698656244917.png

 

I have also the message Datamodel 'TEST' had an invalid search, cannot get indexes to search

0 Karma
Get Updates on the Splunk Community!

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...