Page MenuHomePhabricator

Log message templates
Closed, ResolvedPublic

Description

Error messages often contain "variable" parts (a username, a process ID, a timestamp etc); these make it hard to group messages in interfaces like fatalmonitor and thus to spot frequent issues early. PSR-3 logging provides a nice mechanism to abstract these variable part away: one can pass the logger a message template like $logger->log( 'DB error when {user} tried to save {page}', array( 'user' => $username, 'page' => $pageId ) ); and the variables will be interpolated by Monolog.

We should store the message templates in a separate field, and use them in fatalmonitor for faceted search.

Event Timeline

Tgr raised the priority of this task from to Needs Triage.
Tgr updated the task description. (Show Details)
Tgr added a project: MediaWiki-Debug-Logger.
Tgr subscribed.
bd808 triaged this task as Medium priority.Feb 2 2016, 5:51 AM
bd808 subscribed.

The Logstash configuration used by the WMF already creates a "normalized_message" value in post-processing from the expanded message. Those Logstash rules could be changed to use an existing value in the log event if there was a better one.

This could be implemented with a Monolog processor that fires before the PsrLogMessageProcessor and copies the message to a new key. Since processors are only called after a handler has been found for a log event this should be fairly inexpensive.

Change 269063 had a related patch set uploaded (by BryanDavis):
Monolog: normalize messages before PSR3 expansion

https://gerrit.wikimedia.org/r/269063

Change 269063 merged by jenkins-bot:
Monolog: normalize messages before PSR3 expansion

https://gerrit.wikimedia.org/r/269063

Looks to be not working quite as expected yet. I'm still seeing expanded messages in the Kibana interface.

There may be an ordering issue in the way that the Processors are handled.

bd808 raised the priority of this task from Medium to High.Feb 9 2016, 8:50 PM

Change 269539 had a related patch set uploaded (by BryanDavis):
Monolog: reorder Monolog processors

https://gerrit.wikimedia.org/r/269539

Change 269539 merged by jenkins-bot:
Monolog: reorder Monolog processors

https://gerrit.wikimedia.org/r/269539

Changing the order of the Processors fixed it. Now seeing entries like Session "{session}": Metadata merge failed: {exception} in normalized_message.