Adding Multiple Expressions to Single Searchmatch in Splunk Query

I am trying to add two different expressions in the searchmatch in below query using timechart but its giving me error. Can any one help me out with the same

Its like the count2 should increase if either of expression i.e. Expr2 or Expr3 is seen.

count1 is coming correct and count2 is giving issue as incorrect

index="abc" sourcetype="kube:container:abc_app" source="/var/log/containers/abc-env-*" 
| timechart count(eval(searchmatch("Expr1"))) as "count1", count(eval(searchmatch("Expr2" OR "Expr3"))) as "count2"
1

2 Answers

The searchmatch function takes a single string (possibly containing a pattern) as its argument, not a boolean expression. Try using two searchmatch calls.

index="abc" sourcetype="kube:container:abc_app" source="/var/log/containers/abc-env-*" 
| timechart count(eval(searchmatch("Expr1"))) as "count1", count(eval(searchmatch("Expr2") OR searchmatch("Expr3"))) as "count2"
1

You can only have a single aggregating function in a timechart call

You're trying to do two count functions

timechart will only do one

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest