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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...