{{ ansible_header | comment }} # radiusd template by erdnaxe@crans.org # Define the exported metric names. The `by' keyword indicates the metric has # dimensions. For example, `request_total' counts the frequency of each # request's "command". The name `command' will be exported as the label name # for the metric. The command provided in the code below will be exported as # the label value. counter radiusd_access_ok counter radiusd_access_refused by reason # The `syslog' decorator defines a procedure. When a block of mtail code is # "decorated", it is called before entering the block. The block is entered # when the keyword `next' is reached. def syslog { /^(?P(?P\w+\s+\d+\s+\d+:\d+:\d+)|(?P\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d+[+-]\d{2}:\d{2}))/ + /\s+(?:\w+@)?(?P[\w\.-]+)\s+(?P[\w\.-]+)(?:\[(?P\d+)\])?:\s+(?P.*)/ { # If the legacy_date regexp matched, try this format. len($legacy_date) > 0 { strptime($2, "Jan _2 15:04:05") } # If the RFC3339 style matched, parse it this way. len($rfc3339_date) > 0 { strptime($rfc3339_date, "2006-01-02T03:04:05-0700") } # Call into the decorated block next } } @syslog { # Access ok! /Access ok/ { radiusd_access_ok++ } # Bouh! /Invalid connexion \(non-contributing user\)/ { radiusd_access_refused["Did not pay"]++ } /Invalid user/ { radiusd_access_refused["Invalid user"]++ } }