Skip to content

Example: Janus Events

Lorenzo Mangani edited this page Oct 3, 2021 · 16 revisions

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.

Settings

Configure janus.eventhandler.sampleevh.cfg to use paStash as event receiver:

[general]
enabled = yes
events = all
grouping = no
backend = http://localhost:8090

Recipe

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 => "/opt/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"
  }
}

Use it

That's it - your events are sitting in Loki ready to be queried and used creatively!

Clone this wiki locally