All Apps and Add-ons

Dashboard monitoring: Is there a way to check what the last message was when no event existed at a given time frame?

pratapak
Explorer

Hi,

Is there a way to check what the last message was when no event existed at a given time frame?

Problem statement:
I am creating a widget to display connection status. If connection is successful, I'm displaying "0" and for failed connection I'm displaying "1" , and it's working fine

Log message:

11:30:15.623 AM logger:  com.nsc.ingestion.hono.receiver.HonoReceiver   
     message:    2018-09-22T11:30:15,622+0000 comp=hub-lora-ingestor-0 [vert.x-eventloop-thread-0] INFO  com.bosch.iot.deepfield.ingestion.hono.receiver.HonoReceiver - Connected successfully, creating telemetry consumer ...

11:20:15.127 AM logger:  com.nsc.ingestion.hono.receiver.HonoReceiver   
     message:    2018-09-22T11:30:15,127+0000 comp=hub-lora-ingestor-0 [vert.x-eventloop-thread-0] INFO  com.bosch.iot.deepfield.ingestion.hono.receiver.HonoReceiver - Connecting ...

My search query

(index="05c48b55-c9aa-4743-aa4b-c0ec618691dd"  ( "Connecting ..." OR "Connected successfully, creating telemetry consumer ...")) 
| rex field=_raw "-\s(?<status_message>.*)" 
| eval status=if(like(status_message,"%Connected successfully, creating telemetry consumer%"), 0, 1)
| timechart latest(status) as status span=10m 
| rename status as "Connection Status (0=success, 1=failed/reconnecting)"

Chart is displaying "1" at 11:20 and "0" at 11:30, but for 11:40 also it's displaying "0" because it's considering no value as "0" as there is not log message at 11:40.

So, how can I get the last log message (latest message) when event doesn't exist at a given time frame and evaluate?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try this untested query:

(index="05c48b55-c9aa-4743-aa4b-c0ec618691dd"  ( "Connecting ..." OR "Connected successfully, creating telemetry consumer ...")) 
| rex field=_raw "-\s(?<status_message>.*)" 
| eval status=if(like(status_message,"%Connected successfully, creating telemetry consumer%"), 0, 1)
| timechart latest(status) as status span=10m 
| filldown status
| rename status as "Connection Status (0=success, 1=failed/reconnecting)"
---
If this reply helps you, Karma would be appreciated.
0 Karma

pratapak
Explorer

@richgalloway thanks for the answer. But unfortunately it's not working.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...