Getting Data In

How do you group Start and End times from a set of log events?

OnderSentira
Path Finder

OnderSentira_0-1634045026217.png

How can I group the start and end time of an station like attachment shows? The startime with X I want to skip, 

Labels (1)
Tags (1)
0 Karma
1 Solution

OnderSentira
Path Finder

Hi @gcusello 

The following solution is working for me: 

| rex "(?<TimeStamp>\d+-\d+-\d+ \d+:\d+:\d+\.\d+ \+02:00)\s+[^ ]"
| fields - _time
| eval _time=strptime(TimeStamp,"%Y-%m-%d %H:%M:%S.%3N %:z")
| sort -_time
| eval ret_event = split(_raw, ":")
| eval owcs_msg = mvindex(ret_event,4)
| eval owcs_msg_splited = split(owcs_msg, ";")
| eval owcs_msg_id = mvindex(owcs_msg_splited,0)
| eval owcs_msg_station = mvindex(owcs_msg_splited,1)
| eval owcs_msg_status = mvindex(owcs_msg_splited,2)
| where owcs_msg_status = 57 OR owcs_msg_status = 59 
| transaction owcs_msg_station endswith=owcs_msg_status=59 keepevicted=true
| eval counter=1
| accum counter as Row
| mvexpand TimeStamp
| stats min(_time) AS NotAvailableTimeStamp max(_time) AS AvailableTimeStamp BY owcs_msg_station Row field1
| eval NotAvailableTimeStamp=strftime(NotAvailableTimeStamp,"%Y-%m-%d %H:%M:%S.%3N"), AvailableTimeStamp=strftime(AvailableTimeStamp,"%Y-%m-%d %H:%M:%S.%3N")
| eval ts1=substr(field1,0,30)
| eval _time1=strptime(ts1,"%Y-%m-%d %H:%M:%S.%3N %:z")
| eval owcs_msg_splited1 = split(field1, ";")
| eval owcs_msg_station1 = mvindex(owcs_msg_splited1,1)
| eval owcs_msg_status1 = mvindex(owcs_msg_splited1,2)
| stats min(_time1) AS NotAvailableTimeStamp max(_time1) AS AvailableTimeStamp  by owcs_msg_station1 Row
| eval NotAvailableTimeStamp=strftime(NotAvailableTimeStamp,"%Y-%m-%d %H:%M:%S.%3N"), AvailableTimeStamp=strftime(AvailableTimeStamp,"%Y-%m-%d %H:%M:%S.%3N")

 

View solution in original post

0 Karma

OnderSentira
Path Finder

Hi @gcusello 
when I use the following script then I get the result below:

.......
| mvexpand TimeStamp
| stats min(_time) AS NotAvailableTimeStamp max(_time) AS AvailableTimeStamp BY owcs_msg_station Row field1
| eval NotAvailableTimeStamp=strftime(NotAvailableTimeStamp,"%Y-%m-%d %H:%M:%S.%3N"), AvailableTimeStamp=strftime(AvailableTimeStamp,"%Y-%m-%d %H:%M:%S.%3N")

The result: There is "field1" column with correct information. 

OnderSentira_0-1634211651454.png

 

0 Karma

OnderSentira
Path Finder

Hi @gcusello 

I have used your script but the both TS column have same value now:

OnderSentira_0-1634209528645.png

 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @OnderSentira,

what's the problem?

im my test I have for each Station more transactions with start and end time.

please give me a sample of the result tha you have and the ones you want, e.g. for one Station.

Ciao.

Giuseppe

0 Karma

OnderSentira
Path Finder

Hi Giuseppe

The both column have same timestamp.

OnderSentira_0-1634130446386.png

 

0 Karma

OnderSentira
Path Finder
Spoiler

Hi Giuseppe,

See part of the events below. And I have used the following Script to extract the fields from the events:

my Search "MyApp<<<--MQ: 025;"
| eval ret_event = split(_raw, ":")
| eval owcs_msg = mvindex(ret_event,4)
| eval owcs_msg_splited = split(owcs_msg, ";")
| eval owcs_msg_id = mvindex(owcs_msg_splited,0)
| eval owcs_msg_station = mvindex(owcs_msg_splited,1)
| eval owcs_msg_status = mvindex(owcs_msg_splited,2)
| eval start = if(owcs_msg_status = 57,_time,"")
| eval stop = if(owcs_msg_status = 59,_time,"")
| eval start= strftime(start,"%Y-%m-%d %H:%M:%S.%3N")
| eval stop= strftime(stop,"%Y-%m-%d %H:%M:%S.%3N")

 

  

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @OnderSentira,

sorry, but what's the correlation rule?

in other words: why do you exclude some values and takes some other?

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Shape the Future of Splunk: Join the Product Research Lab!

Join the Splunk Product Research Lab and connect with us in the Slack channel #product-research-lab to get ...