-
-
Notifications
You must be signed in to change notification settings - Fork 28
Example: Janus Events
Janus Event Handlers link
Just like media and transport plugins, Event Handlers plugins in Janus themselves, meaning their modular nature allows for extensibility. When enabling Event handlers, Janus and other plugins generate real-time events related to several different aspects that may be happening during its lifetime: these events are then passed to all the available event handler plugins, plugins that can then decide to do with these events whatever they want. They might choose to store these events somehow, aggregate, dump or process them, format and send them to an external application, and so on.
PaStash love Janus Events! This recipe shows how to handle them with a minimalistic approach for storage in cLoki or Loki.
Configure janus.eventhandler.sampleevh.cfg
to use paStash as event receiver:
[general]
enabled = yes
events = all
grouping = no
backend = http://localhost:8090
Configure paStash to receive and handle the events send by your Janus instance(s):
# Read Janus events from existing files or in realtime - or both!
input {
file {
path => "/var/log/janus.log"
start_index => 0
}
http {
host => 127.0.0.1
port => 8090
}
}
# Filter json events, use the real timestamp and extract tags of choice
filter {
json_fields {}
regex {
regex => /(\d{13})/
fields => [timestamp]
numerical_fields => [timestamp]
}
compute_date_field {
from_field => timestamp
field => "@timestamp"
date_format => 'YYYY-MM-DDTHH:mm:ss.SSSZ'
}
omit {
whitelist => ['@timestamp','message', 'opaque_id', 'session_id', 'type']
}
}
# Ship the tagged events to Loki or any other backend
output {
loki {
host => localhost
port => 3100
path => "/loki/api/v1/push"
}
}
That's it - your events are sitting in Loki ready to be queried and used creatively!
Let's try a filter to quickly find all events with type 32
and video
media type:
{emitter="MyJanusInstance"} | json | type="32" | event_media="video"
Let's extract a metric from our filtered logs and render it. How many packets sent
did we log?
avg_over_time({emitter="MyJanusInstance"} | json | type="32" | event_media="video" | unwrap event_packets_sent[1s]) by (type)