Splunk Search

How to list datamodel name in a Table

DEAD_BEEF
Builder

I am trying to list certain datamodels in a table along with their log count but I can't seem to find how to list the datamodel name itself in the table. I tried displayName and datamodelName. The query lists everything I want except for the datamodel so it's difficult to tell which data belongs to which datamodel.

alt text

| tstats summariesonly=t min(_time) as min, max(_time) as max count from datamodel=Web 
| append 
    [| tstats summariesonly=t min(_time) as min, max(_time) as max count from datamodel=Malware] 
| append 
    [| tstats summariesonly=t min(_time) as min, max(_time) as max count from datamodel=Intrusion_Detection ] 
| eval "Start time"=strftime(min, "%c") 
| eval "End time"=strftime(max, "%c") 
| eval "Event count" = count 
| fields "Start time" "End time" "Event count"

FINAL SOLUTION

| tstats summariesonly=t min(_time) as min, max(_time) as max count from datamodel=Web 
| appendcols 
    [| datamodel Web 
    | spath displayName 
    | table displayName] 
| eval datamodel_name = Web 
| append 
    [| tstats summariesonly=t min(_time) as min, max(_time) as max count from datamodel=Malware 
    | appendcols 
        [| datamodel Malware 
        | spath displayName 
        | table displayName] 
    | eval datamodel_name = Malware] 
| append 
    [| tstats summariesonly=t min(_time) as min, max(_time) as max count from datamodel=Intrusion_Detection 
    | appendcols 
        [| datamodel Intrusion_Detection 
        | spath displayName 
        | table displayName] 
    | eval datamodel_name = Intrusion_Detection] 
| eval "Start time"=strftime(min, "%c") 
| eval "End time"=strftime(max, "%c") 
| eval "Event count" = count 
| fields "Start time" "End time" "Event count" displayName
Tags (2)
0 Karma
1 Solution

pramit46
Contributor

You can try adding the following against each entry:

| appendcols [| datamodel <>|spath displayName | table displayName]

for example:

| tstats summariesonly=t min(_time) as min, max(_time) as max count from datamodel=Web | appendcols [| datamodel Web |spath displayName | table displayName]
| append
[| tstats summariesonly=t min(_time) as min, max(_time) as max count from datamodel=Malware| appendcols [| datamodel Malware |spath displayName | table displayName]]
| append ...
|eval ...

View solution in original post

pramit46
Contributor

You can try adding the following against each entry:

| appendcols [| datamodel <>|spath displayName | table displayName]

for example:

| tstats summariesonly=t min(_time) as min, max(_time) as max count from datamodel=Web | appendcols [| datamodel Web |spath displayName | table displayName]
| append
[| tstats summariesonly=t min(_time) as min, max(_time) as max count from datamodel=Malware| appendcols [| datamodel Malware |spath displayName | table displayName]]
| append ...
|eval ...

DEAD_BEEF
Builder

This worked! I will add the working query to the initial question. Thank you @pramit46

0 Karma

pramit46
Contributor

Good to know that!!!.. Happy Splunking 🙂

0 Karma

Ravan
Path Finder

Can you try below one

 tstats summariesonly=t min(_time) as min, max(_time) as max count from datamodel=Web |eval datamodel=Web 
 | append 
     [| tstats summariesonly=t min(_time) as min, max(_time) as max count from datamodel=Malwareeval|eval datamodel=Malwareeval] 
 | append 
     [| tstats summariesonly=t min(_time) as min, max(_time) as max count from datamodel=Intrusion_Detection| eval datamodel= Intrusion_Detection] 
 | eval "Start time"=strftime(min, "%c") 
 | eval "End time"=strftime(max, "%c") 
 | eval "Event count" = count 
 | fields "Start time" "End time" "Event count" datamodel
0 Karma

DEAD_BEEF
Builder

@Ravan I tried your solution, but it returned the same thing I have now, no datamodel name listed in the table.

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...