Important
This is an ongoing work in progress. Expect to encounter bugs. We expect this tool to improve over time as we use it and learn what we want out of it.
This tool reads, parses, and presents New Relic Node.js Agent troubleshooting logs.
$ nrlv -f newrelic_agent.log 2>nrlv.logLines with » preceding the message string have more information available by
selecting the line and pressing the enter key.
Note: the log viewer writes its own internal logs to stderr.
This tool supports being installed directly with the
go install command:
go install github.com/newrelic/node-log-viewer@latestThis tool is installable via Homebrew:
brew install newrelic/agents/node-log-viewerNote: this is the preferred installation method. This is the easiest way to install the tool on macOS without needing to utilize the "open anyway" work around.
The intended typical use case is:
nrlv newrelic_agent.logThe result of that will be a TUI representation of the log file that looks similar to the following screenshot:
Sometimes we are only concerned with the logs around sending data to the remote collection server. We can filter a log file down to only the relevant remote communication logs like so:
nrlv newrelic_agent.log --dump-remote-payloads > remote.log
# Which can also be viewed with the viewer:
nrlv remote.logThe log viewer parses the agent log file and stores the parsed data in a temporary SQLite database. If a log file is particularly large it can be helpful to retain the cache for use with subsequent runs:
nrlv newrelic_agent.log --cache-file ./cache.sqlite --keep-cache
# Or a little less verbose:
nrlv newrelic_agent.log -c ./cache.sqlite -kIf the --keep-cache switch is omitted, the cache file will be removed when
the log viewer exits.
The application has two distinct views: "lines view" and "line detail view." The lines view is a scrollable list of all log lines showing the timestamp, log level, log component, and log message for each log line. The line detail view is what is shown when choosing a log line from the lines view to inspect. It shows all pertinent information from the log along with any embedded data in an easy to review format.
- Lines view:
up arrow,j: move line selection downdown arrow,k: move line selection upenter: view detail of selected lines: open search boxg: open go to line boxq,ctrl+c: quit the application
- Line detail view:
- up/down navigation is same as lines view
esc: return to lines view
Create a directory named local in the root of the project, and you can store
local test resources within it. These resources will not be added to the
project.
It is easiest to verify your changes are working by actually trying to use them in the application and referring to the logs when something breaks. To do so:
go run ./... local/some.logfile -l trace -k -c cache.sqlite 2>viewer.logThat will build the current source code, read the log file, cache it to a
local cache.sqlite file (which will be retained [-k]), and write trace
level application logs to viewer.log. Neither the cache.sqlite nor
viewer.log file will be added to the project. Remember to remove the
cached SQLite file after you are done with it, or omit -k if you do not
need to work with the SQLite file outside of the log viewer.
