Splunk Search

How to build a timechart from a combined search

brajaram
Communicator

I have two different sources, each with information related to one another. The first source has, as part of the file, every successful page hit. The second source, has, as part of the file, every error report.

index= sourcetype=< st> source= < hit log > < some further conditions >
| stats count as total_hits 
| appendcols [search index= sourcetype=< st> source= < error log > < some otherfurther conditions > 
| stats count as total_errors ]

If I do a search like this, I successfully get the count of crashes, count of successes, and can do an eval FailureRate= total_hits/total_errors

However, I want to further do a timechart to see the failure rate over time, and this is where I am stuck. How would I propagate time throughout this process to build a timechart of a single value?

0 Karma
1 Solution

somesoni2
Revered Legend

Try like this (I'm assuming sourcetype is the only distinction between two sources. If sourcetype is same and source is different, update if condition with that)
Updated

(index= sourcetype=< st> source= < hit log > < some further conditions >) OR ( index= sourcetype=< st> source= < error log > < some otherfurther conditions >)
| eval type=if(source="< hit log > ","total_hits","total_errors")
| timechart count by type | eval FailureRate= total_hits/total_errors

View solution in original post

somesoni2
Revered Legend

Try like this (I'm assuming sourcetype is the only distinction between two sources. If sourcetype is same and source is different, update if condition with that)
Updated

(index= sourcetype=< st> source= < hit log > < some further conditions >) OR ( index= sourcetype=< st> source= < error log > < some otherfurther conditions >)
| eval type=if(source="< hit log > ","total_hits","total_errors")
| timechart count by type | eval FailureRate= total_hits/total_errors

brajaram
Communicator

Worked great, thanks! A different approach than I had, and it worked to keep the time field all the way down.

0 Karma
Get Updates on the Splunk Community!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...