[asterisk-dev] Journald support for Asterisk

Ludovic Gasc gmludo at gmail.com
Tue May 12 15:20:32 CDT 2015


2015-05-12 13:48 GMT+02:00 Tzafrir Cohen <tzafrir.cohen at xorcom.com>:

> On Mon, May 11, 2015 at 11:26:31PM +0200, Ludovic Gasc wrote:
>
> > The idea behind structured log is to retrieve easily a context with a log
> > to reduce the effort of categorization after, because you don't need to
> > parse and recognize patterns in log message.
> > Technically, instead of to have a String, you have a Dict of Strings.
>
> That's nice in theory. Could you please give an example of the required
> output? An example of how it would help?
>

For now, this is the situation to log for most applications:
1. In your source code, where you want to log, you aggregate data from
several variables to generate a log message. Example:
    logger.info('This is a call from "%s" with the uniqueid "%s" and
callerid "%s" to call "%s" extension in "%s" context', endpoint, uniqueid,
callerid, extension, context)

2. This message is stored in the text format in /var/log/asterisk/debug.log

3. For example, to retrieve all logs about a specific extension, the
sysadmin needs to use: grep -i "\"%s\"
extension" /var/log/asterisk/debug.log or write regex for a log analysis
tool, with a risk of false positive or miss something.

At the beginning, in your source code, you have structured data, you encode
as string for log.
After, to get metadata in logs, you need to decode your logs with regex to
retrieve structured data to query inside.

The final situation should be:
logger.info('This is a call from "%(endpoint)s" with the uniqueid
"%(uniqueid)s" and callerid "%(callerid)s" to call "%(extension)s"
extension in "%(context)s" context', {'endpoint': endpoint, 'uniqueid':
uniqueid, 'callerid': callerid, 'extension': extension, 'context': context})

And after, depends on the handler:
    a. For syslog, you use the dict only to replace values in string
    b. For journald, you push also the dict with the log message. With
that, you don't need to encode/decode, you retrieve directly structured
data included in message log.

And yes, ideally, it should be useful if we can generate log messages with
the structured data directly in the dialplan.
BTW, you just give me an interesting idea to have this feature easily: I
can make a FastAGI daemon that generate my journald message, based on data
pushed as parameter with a JSON dict structure.
Not really funny to write the dialplan source code, however, it will work.

If it isn't enough concrete for you, I can give you a concrete example with
a click2call HTTP endpoint, where the order starts from WebBrowser, to
finish in asterisk.


>
> --
>                Tzafrir Cohen
> icq#16849755              jabber:tzafrir.cohen at xorcom.com
> +972-50-7952406           mailto:tzafrir.cohen at xorcom.com
> http://www.xorcom.com
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20150512/fca6bd32/attachment.html>


More information about the asterisk-dev mailing list