Splunk Search

Help in timechart

vrmandadi
Builder

Hello I have the below two queries

QUERY1

index=abc  NOT *UNKNOWN*  HTTP_Code=404|stats count by HTTP_Code  AS "ACTUAL COUNT"

OUTPUT

HTTP_COde      Count
404              50

QUERY2

 index=abc *UNKNOWN* HTTP_Code=404 |stats count by HTTP_Code as UNKNOWN_COUNT

OUTPUT

HTTP_COde      Count
404              80

I am trying to do a timechart ,where in the chart one line shows the unknown count and other shows the actual count .

Thanks in advance

0 Karma

woodcock
Esteemed Legend

Like this:

index=abc
| timechart count(eval(searchmatch("NOT *UNKNOWN*"))) AS ActualCount count(eval(searchmatch("*UNKNOWN*"))) AS UnknownCount BY HTTP_Code

OR
Like this:

index=abc HTTP_Code=404
| timechart count(eval(searchmatch("NOT *UNKNOWN*"))) AS ActualCount_404 count(eval(searchmatch("*UNKNOWN*"))) AS UnknownCount_404
0 Karma

vrmandadi
Builder

It did not work ,I tried using append and it worked

index=abc UNKNOWN |timechart span=1h count(HTTP_Code) as "UNKNOWN 404 Count" |append[search index=abc NOT UNKNOWN HTTP_Code=404 |timechart span=1h count(HTTP_Code) as "OTHER 404 Count"]

0 Karma

somesoni2
Revered Legend

GIve this a try

index=abc HTTP_Code=404 | eval Unknown=if(searchmatch("UNKNOWN"),1,0) | eval Actual=abs(1-Unknown) 
| timechart sum(Unknown) as UNKNOWN_COUNT sum(Actual) as ACTUAL_COUNT
0 Karma

vrmandadi
Builder

It did not work ,I tried using append and it worked

index=abc UNKNOWN |timechart span=1h count(HTTP_Code) as "UNKNOWN 404 Count" |append[search index=abc NOT UNKNOWN HTTP_Code=404 |timechart span=1h count(HTTP_Code) as "OTHER 404 Count"]

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!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...