Dashboards & Visualizations

How to display only one row with duplicated columns

splunkkid
Path Finder

Hello,

I am trying to build Splunk Dashboard with my logs in splunk. The rows are like below.

 

[row 1]

{

 "id" : 123,
 "name" : "A",
 "sub_id" : 444,
 "count" : 25 

}

 

[row 2]

{

 "id" : 123,
 "name" : "A",
 "sub_id" : 445,
 "count" : 25 

}

 

As you can see, some of my results have the column with id value is same but sub_id is different.

I need to sum(count) only once if "id" is different, but the results came out as duplicated(not exactly twice, some results have same id with 3 or 4rows, So dividing by 2 is not a good solution.)

 

I want to build timechart with above data and made SPL like below.

host=[HOST] index=[INDEX] sourcetype=[SOURCETYPE] source=[SOURCE] | bucket span=1d _time | chart limit=0 sum(vm.count) as VM by _time

 

So, How could I sum count data if the id is same? Thank you,

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

So using the first vm.count for each vm.id in each bucket would give you the counts you need to sum?

host=[HOST] index=[INDEX] sourcetype=[SOURCETYPE] source=[SOURCE] 
| bucket span=1d _time 
| stats first(vm.count) as vm.count by _time vm.id
| chart limit=0 sum(vm.count) as VM by _time

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

When id is the same, are name and count also the same, only sub_id is different?

0 Karma

splunkkid
Path Finder

@ITWhisperer 

Yes, you're correct. I want to sum count only once by ID(But not grouping), and create timechart.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

So using the first vm.count for each vm.id in each bucket would give you the counts you need to sum?

host=[HOST] index=[INDEX] sourcetype=[SOURCETYPE] source=[SOURCE] 
| bucket span=1d _time 
| stats first(vm.count) as vm.count by _time vm.id
| chart limit=0 sum(vm.count) as VM by _time

splunkkid
Path Finder

Thank you! That is correct!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...