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!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

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 ...