You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Log entry created (New Relic PHP Agent grabs the log entry and sends to NR)
Monolog runs processors
Monolog outputs the log entry
Basically, the agent grabs the log before monolog processors have a chance to run
Desired Behavior
Use of monolog processors is supported by the New Relic PHP Agent, allowing use of processors bundled with monolog, or custom processors created by users.
Additional context
A processor is used to decorate log entries, for example, to modify a log message or perhaps add data to the $context array prior to output. Some of the processors bundled with monolog are unhelpful in the context of New Relic, e.g. the WebProcessor is not really needed thanks to how this project collects that information with each Transaction (though, someone may find it helpful to have this information on log entries as well.
In our case, we use Laravel, and built a custom monolog processor to decorate all log entry $context arrays with the Laravel session ID. This is VERY important because it allows us to find all log entries tied to a specific user. I.e. a user submits a bug about an error they ran into, we can locate their session ID from their email address, then locate all logs generated by that user's journey; allowing us to identify what went wrong and in-turn guide the user or update our code.
The only way we've made this work with the current version of the New Relic PHP Agent is to log the session ID with each log entry. This has been less-than ideal as we're trying to migrate from Kibana to New Relic, and requires updating hundreds of log entries in our code base, e.g.
Also facing this issue, saw tons of Matched route "{route}". from our Symfony app, debugging locally I found that it should have been processed by \Monolog\Processor\PsrLogMessageProcessor as mentioned above. Also explains why the processor I just added to add back the log channel (which NR strips from the log line) to extra didn't seem to be working in New Relic logs!!
Guess I'll have to fall back to forwarding logs from a file via the infra agent?
We also have this issue of "missing" data that we added via a Processor
Falling back to file log forwarding might be a workaround (while logs in context within APM probably would be not working this way then)
Summary
Because of how this project grabs calls to monolog's
addRecord
, it completely bypasses any monolog processors.See https://github.com/Seldaek/monolog/blob/main/doc/02-handlers-formatters-processors.md#processors
Basically, the agent grabs the log before monolog processors have a chance to run
Desired Behavior
Use of monolog processors is supported by the New Relic PHP Agent, allowing use of processors bundled with monolog, or custom processors created by users.
Additional context
A processor is used to decorate log entries, for example, to modify a log message or perhaps add data to the $context array prior to output. Some of the processors bundled with monolog are unhelpful in the context of New Relic, e.g. the WebProcessor is not really needed thanks to how this project collects that information with each Transaction (though, someone may find it helpful to have this information on log entries as well.
In our case, we use Laravel, and built a custom monolog processor to decorate all log entry $context arrays with the Laravel session ID. This is VERY important because it allows us to find all log entries tied to a specific user. I.e. a user submits a bug about an error they ran into, we can locate their session ID from their email address, then locate all logs generated by that user's journey; allowing us to identify what went wrong and in-turn guide the user or update our code.
The only way we've made this work with the current version of the New Relic PHP Agent is to log the session ID with each log entry. This has been less-than ideal as we're trying to migrate from Kibana to New Relic, and requires updating hundreds of log entries in our code base, e.g.
Log::debug(json_encode(['message' => 'something failed', 'context' => ['session_id' => session()->getId()]]);
NRQL
SELECT message FROM Log WHERE context.session_id = 'XXYYZZ'
The text was updated successfully, but these errors were encountered: