Knowledge Management

Perform calculations on a count of EventTypes

sportauthority
New Member

I have having trouble performing basic calculations using Eval. I can do '2*2' but I cannot do this with a count of eventtype.

I have a search running, to total EventTypes that I created.

sourcetype=csv | timechart span="1d" , count(eval(eventtype="OC-Main Player_Loaded")) AS OC-Main-player-loaded, count(eval(eventtype="OC-Main User_Interacted")) AS OC-Main-User_Interacted

This creates a table, showing the time, and then a count of the EventTypes (in this case "OC-Main PlayerLoaded" and "OC-Main UserInteracted").

alt text

I want to create a 4th column, that would give me a calculation, based on these counts. What I want is a %, but at the moment I can't get anything to work.

If I add a simple Eval at the end, the result shows. eg... | eval ocper=(2*2) shows as 4
However, if I try and use the AS event names (eg: OC-Main-player-loaded) nothing shows.

My guess is, OC-Main-player-loaded is just the name of the table column, and splunk has no concept of what I am trying to multiply. I assume I need to specify that the count should be some sort of field that can be multiplied. How do I do this?

thanks in advanced.

Tags (2)
0 Karma

MHibbin
Influencer

I would firstly try simplifying the names you are using the timechart command, and use something simple like:

OC-Main-player-loaded --> loaded

Then pipe to your eval command and use the simplified field labels in your calculation. I have had issues in the past with processing certain field names.

I would then pipe to rename to change the simplified field labels to something more legible.

Hope this helps.

MHibbin
Influencer

No problem, to close this question off, can you mark the answer as accepted with the empty tick beside the answer.

Thanks.

0 Karma

sportauthority
New Member

Ok, that works. thank you very much. It's probably something I should have tried about 4 hours ago. Instead I have been reading docs, trying examples, looking in the wiki. You live and learn! cheers!

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...