Splunk Search

Multiple stats counts in string, need to divide one count by 2

tbrown110
New Member

This is my string

.....| eval actionSend=if(action="Send", 1, null) | eval actionRecv=if(action="Receive", 1, null) | eval actionLogon=if(action="Logon", 1, null) | convert timeformat="%m-%d-%Y" ctime(_time) AS date | stats values(date) values(datacenter) count(actionLogon) count(actionSend) count(actionRecv) by user | sort -count(actionLogon) | uniq datacenter

I need to divide the count(actionLogon) by 2

I have tried | eval actionLogon=actionLogon/2 at the end of my string, it doesnt fail, but it also doesnt divide the column/value being displayed in count(actionLogon)

Thanks!

Tags (1)
0 Karma
1 Solution

gyslainlatsa
Motivator

hi,

write this : count(actionLogon) AS Num_actionLogon and |eval logon= Num_actionLogon/2

and give you something like this:

....| eval actionSend=if(action="Send", 1, null) | eval actionRecv=if(action="Receive", 1, null) | eval actionLogon=if(action="Logon", 1, null) | convert timeformat="%m-%d-%Y" ctime(_time) AS date | stats values(date) values(datacenter) count(actionLogon) AS Num_actionLogon count(actionSend) count(actionRecv) by user | sort -count(actionLogon) | uniq datacenter |eval logon= Num_actionLogon/2

View solution in original post

gyslainlatsa
Motivator

hi,

write this : count(actionLogon) AS Num_actionLogon and |eval logon= Num_actionLogon/2

and give you something like this:

....| eval actionSend=if(action="Send", 1, null) | eval actionRecv=if(action="Receive", 1, null) | eval actionLogon=if(action="Logon", 1, null) | convert timeformat="%m-%d-%Y" ctime(_time) AS date | stats values(date) values(datacenter) count(actionLogon) AS Num_actionLogon count(actionSend) count(actionRecv) by user | sort -count(actionLogon) | uniq datacenter |eval logon= Num_actionLogon/2

tbrown110
New Member

That worked. Thank you!

0 Karma

gyslainlatsa
Motivator

your welcome, don't forget to vote

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...