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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...