Splunk Search

Why does appendcols produce the same result for two different searches?

saradachelluboy
Explorer

The below search String works same for approved and decline. Can some let me know where the error is?

All the time it executes index="pg_int" sourcetype="pg" (responseCode=00) for approved and declined. Please help.

index="pg_int" sourcetype="pg"  (responseCode=00) | timechart count as approved | appendcols [search index="pg_int" sourcetype="pg"  (responseCode!=00)| timechart count as declined]
Tags (2)
0 Karma
1 Solution

sundareshr
Legend

For the appendcols to align correctly, try adding a span to your timechart. Something like this

index="pg_int" sourcetype="pg"  (responseCode=00) | timechart span=1d count as approved | appendcols [search index="pg_int" sourcetype="pg"  (responseCode!=00)| timechart span=1d count as declined]

Having said that, a faster approach may be this...

index="pg_int" sourcetype="pg"  responseCode=* | eval response_cd=if(responseCode="00", "approved" , "declined") | timechart span=1h count by response_cd

View solution in original post

0 Karma

sundareshr
Legend

For the appendcols to align correctly, try adding a span to your timechart. Something like this

index="pg_int" sourcetype="pg"  (responseCode=00) | timechart span=1d count as approved | appendcols [search index="pg_int" sourcetype="pg"  (responseCode!=00)| timechart span=1d count as declined]

Having said that, a faster approach may be this...

index="pg_int" sourcetype="pg"  responseCode=* | eval response_cd=if(responseCode="00", "approved" , "declined") | timechart span=1h count by response_cd
0 Karma

saradachelluboy
Explorer

Thanks Sundar!!!

The faster approach worked fine but I wonder why the appendcols still didn't work after the changes.I am using Splunk 6.1 and IE11

0 Karma

saradachelluboy
Explorer

Can you please help me how to restrict specific responseCode for decline?
responseCode =90 or responseCode = 08 consider as Decline.

0 Karma

sundareshr
Legend

Change the eval segment like this

.... | eval response_cd=case(responseCode="00", "approved", responseCode="90" OR responseCode="08", "declined", 1=1, "other")

The other for all other responseCodes. If you don't want to show that field, you can add this to the end of the query

| fields - other
0 Karma
Get Updates on the Splunk Community!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...