Splunk Search

Transaction to Streamstats

tb5821
Communicator

I'm trying to move from using a transaction command to a streamstats - I get most of the way there but I can't figure out the 'reset' with streamstats to proper group starts and ends together. Here's my current query which isn't finding the right end time since my BY query will match multiple places and the latest(_time) will change to the wrong latest time but yet the actual latest time ...

 

 

 

index="logfiles" appType=reports* "Generating * Status Report" | rex \.(?<reportName>Generate\w*) 
| eval reportName=replace (reportName,"Generate","")
| eval reportName=replace (reportName,"Report","")
| streamstats earliest(_time) as stime by reportName appType
| join appType,reportName [search index="logfiles" appType=reports* "Report generated successfully" | rex \.(?<reportName>\w+)ReportGenerator
| streamstats reset_on_change=true reset_after="("searchmatch(\"Report generated successfully\")")" latest(_time) as etime BY reportName appType]
| eval diff=etime-stime
| eval hhmmss=tostring(diff, "duration")
| convert timeformat=" %a  %b  %d %I:%M:%S.%3N %p %Z" ctime(stime) as StartTime
| table StartTime appType reportName hhmmss
|rename hhmmss as RunDuration

 

 

 

Labels (2)
Tags (1)
0 Karma

niketn
Legend

@tb5821 for the community to assist you better please provide more details like some sample (cooked up event, should have masking and anonymization for any sensitive data). Also provide your current SPL with transaction command which is also doing the job (but I am guessing it is not performing).

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

tb5821
Communicator

anyone?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

@tb5821 Do you have some sample events you can share to show what you are dealing with?

0 Karma

tb5821
Communicator

the events are long and span hours if not close to a day... but the beginning of the event starts with the generating line and ends with a completed log line. The problem is that if server 1 picks up job A and runs for 28hrs. Then server 2 will pick up job A 12 hours into server 1's run. This is fine b/c they are different servers. BUT now the issue comes in ~24hours after server1 starts is that its time for the next run, and server 1 again on a different thread picks up that run. So its the same server1 and same job A but its start and end should be different.

 

Yet whats happening is my streamstats for the first event computes the event end as the end for the last (latest) run.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Hi @tb5821 

By events I meant splunk event e.g. log entries. What is the data you are trying to process with splunk?

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...