Splunk Search

How to keep null results from Stats Count by field to match the whole table

angelcat
Engager

I have 4 types of devices, a column for total number, and I need to count by type. But some of the result are null, then it will skip the types with null values. How can I keep the null value to make the results match the types? Below is the expected result:

Type Total Count
A 10 null
B 20 null
C 30 5
D 40 6

I can only get the result like this:

Type Total Count
A 10 5
B 20 6
C 30

D 40

I have tried fillnull before and after count , but it does not work.

Tags (1)
0 Karma
1 Solution

somesoni2
Revered Legend

Try like this

index="scan" 
|stats count as Total by Type 
| append [search index=vm |join type=outer ip [search
index="scan" |fields Type ip]
|stats count by Type]
| stats values(Total) as Total values(count) as count by Type

View solution in original post

somesoni2
Revered Legend

Try like this

index="scan" 
|stats count as Total by Type 
| append [search index=vm |join type=outer ip [search
index="scan" |fields Type ip]
|stats count by Type]
| stats values(Total) as Total values(count) as count by Type

richgalloway
SplunkTrust
SplunkTrust

Please share your query.

---
If this reply helps you, Karma would be appreciated.
0 Karma

angelcat
Engager

index="scan"
|stats count as Total by Type
|appendcols [search index=vm |join type=outer ip [search
index="scan" |fields Type ip]
|stats count by Type

]
|table Type Total count

0 Karma
Get Updates on the Splunk Community!

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...