Splunk Search

Having Problems with timechart's searching

venterdaniel
Engager

Hi,

I am trying to do a timechart which shows the amount of sessions opened/closed.
Where the Opened and Closed are 2 separate lines.

The Current search I have looks as follows:

index="main" ("session" ("closed" OR "opened") AND NOT "cron:session")
| timechart
count(eval("session opened")) AS Opened,
count(eval("session closed")) AS Closed

Now the problem I am having is that they both show as the same 'count' amount.
When I separate this timechart into 2 different charts it works fine.

The log looks as follows:

Oct 19 09:06:10 YYY sshd[16997]: pam_unix(sshd:session): session opened for user XXX by (uid=0)
Oct 19 09:02:07 YYY sshd[13684]: pam_unix(sshd:session): session closed for user XXX
Oct 19 08:57:13 YYY sshd[13684]: pam_unix(sshd:session): session opened for user XXX by (uid=0)
Oct 19 00:26:43 YYY sshd[8577]: pam_unix(sshd:session): session opened for user XXX by (uid=0)

Daniel

Tags (1)
0 Karma
1 Solution

jflomenberg
Splunk Employee
Splunk Employee

You first need to create a filed for open/closed using the field extractor workflow or by defining a regex. eval in count is generally used along the lines of

... | timechart count(eval(field="value"))

The way you have crafted your eval without a field is basically causing the search to perform an arbitrary evaluation that roughly evaluates to

... | timechart count(TRUE)

which I think is just counting everything

View solution in original post

jflomenberg
Splunk Employee
Splunk Employee

You first need to create a filed for open/closed using the field extractor workflow or by defining a regex. eval in count is generally used along the lines of

... | timechart count(eval(field="value"))

The way you have crafted your eval without a field is basically causing the search to perform an arbitrary evaluation that roughly evaluates to

... | timechart count(TRUE)

which I think is just counting everything

venterdaniel
Engager

thank you for the clarification on requiring a field extractor, i downloaded the 'Field Extractor' App which helped create the new field called session which can either be "opened", "closed", "failure;" or "pass;"
(it picked up a few fields from authentication as well but that is alright xD)

Current search which is working

index="main" ("session" AND NOT "cron:session")
| timechart
count(eval(session="opened")) AS Opened,
count(eval(session="closed")) AS Closed

0 Karma
Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

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

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...