Splunk Search

Transaction based Alert Trigger with multiple conditions

mfritsch
New Member

I like to create a trigger which fires based multiple conditions

Example Scenario:
A per person is entering a room and the door sensor sends an open event to splunk.
Next the person switch on the light. The light sensor send the "on" event to splunk.
The person leaves the room without switch the light off. A door close event is send to splunk.
Result the person forget to switch of the light. I like to detect this.

I have two indexs

Index 1: DoorSensors
Timestamp, DoorID, State
2017-10-06 12:01:30, Door1, Open
2017-10-06 12:03:50, Door1, Close

Index 2: LightSensors
Timestamp, LightSensor, State
2017-10-06 12:01:35, Light1, On

How to detected by a alert trigger that someone forgot to turn off the light?
I like to run this in real-time.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi mfritsch,
I don't see in index2 (LightSensors) the room where the light is positioned so I can image that this is an example and that i can extrapolate the room number from the LightID field number (e.g. light1 is in room1) .
So you could run something like this

index=LightSensors State="On" 
| rex field=LightSensor "Light(?<LightRoom>\d+)"
| eval DoorID="Door"+LightRoom
| search [ search index=DoorSensors | stats values(State) AS DoorState BY DoorID | search State="Open" State="Close" | fields DoorID]
| table _time DoorID

if you could have the room number in index 2 the search is easier:

index=LightSensors State="On" [ search index=DoorSensors | stats values(State) AS DoorState BY DoorID | search State="Open" State="Close" | fields DoorID]
| table _time DoorID

To manage the presence of more doors or more lights for each room you have only to find the rule to extrapolate the room number.

You could also use transaction command in the subsearch but this solution is more performant.

Bye.
Giuseppe

0 Karma
Get Updates on the Splunk Community!

Application management with Targeted Application Install for Victoria Experience

  Experience a new era of flexibility in managing your Splunk Cloud Platform apps! With Targeted Application ...

Index This | What goes up and never comes down?

January 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Splunkers, Pack Your Bags: Why Cisco Live EMEA is Your Next Big Destination

The Power of Two: Splunk &#43; Cisco at "Ludicrous Scale"   You know Splunk. You know Cisco. But have you seen ...