311 karma · joined Aug 30, 2013 (13y ago) · 137 submissions
comment 3y ago · link · parent
Yes, I should mention it on the features page. It's currently only mentioned in the main docs:
comment 3y ago · link · parent
Identifiers, like process-names/pids/IPs, are semantically highlighted by default to make it easier to visually match up values that are the same. And, it's this way because I like it this way, so that's the default.
> For example the http 403/404 is red but it does not stand out.
To me, the red stands out. But, I would also have a much wider window, so the red would stand out even more with the rest of the text.
> Also why a 404 would be red in the first place.
Because 4XX are error codes.
Of course, lnav is pretty customizable at this point, so you can adjust it to your liking. The theme can be changed to something less colorful and the log format definitions can be patched to change their behavior.
comment 3y ago · link · parent
If you want to write more complicated queries, lnav exposes log data through SQLite vtables[1]. So, you can do a SQL query and get a simple bar chart visualization.
[1] - https://docs.lnav.org/en/latest/sqlext.html#sqlite-interface
comment 3y ago · link · parent
For logfmt, I seem to remember the spec not being very clear on quoting semantics (maybe I'm wrong). Anyhow, I would suggest using JSON since it has pretty broad support at this point.
comment 3y ago · link · parent
> something to probably add to my clean up script.
These capture files are deleted if they are older than a day the next time lnav is run.
(I realize they should've been stored in ~/.local/state instead of ~/.config ...)
comment 3y ago · link · parent
You can adjust the timestamps for a file using the ":adjust-log-time" command (https://docs.lnav.org/en/latest/commands.html#adjust-log-tim...). For example, if you wanted to shift the timestamps back an hour, you can do:
:adjust-log-time -1h
The shift is applied to the messages in the file that the top line in the view belongs to.If you want to do the shift programmatically, you can UPDATE the "time_offset" column of the "lnav_file" table directly (see https://docs.lnav.org/en/latest/sqltab.html#lnav-file)
comment 3y ago · link · parent
comment 3y ago · link · parent
It works by uploading a stub that is an "actually portable executable" to the remote over ssh. lnav then talks to the stub to sync files back to the local host. I don't know the scale of the hosts or files, but if they're not too big, it might work fine.
comment 3y ago · link · parent
$ multitail /var/log/install.log -I /var/log/system.log
You get a view with the tail from one file followed by the tail from the other, they are not collated by timestamp. In contrast, if you do the same thing in lnav: $ lnav /var/log/install.log /var/log/system.log
You will get a single view with all of the log messages from both files and they're sorted by their timestamps. Here is all of what lnav is doing: * Monitoring files/directories for updates
* Decompressed files/archives
* Detected the log format for each file
* Created SQLite vtables that provide access to log messages
* Built an index of all the log messages in all the files so
you can jump to a certain point in time or to the
next/previous error message.
* Display all log messages with syntax highlightingcomment 3y ago · link · parent
(You might question why a log file viewer needs markdown support... It's used mainly to make the builtin help text look nicer. But, it can also be used in other places, like adding comments to log messages and generating reports. It's even used to implement an interactive tutorial[2].)
[1] - https://lnav.org/2022/08/06/markdown-support.html [2] - https://lnav.org/2022/09/01/playground.html
comment 4y ago · link · parent
That tool is the Logfile Navigator (https://lnav.org). It's a TUI that reads plaintext logs, JSON-lines logs, and others. It will collate messages from all the files into a single log view that you can filter and search. The logs are also plumbed through SQLite virtual tables, so you can do fancy queries.
When setting up ELK or paying for Splunk/Sumologic is too much, lnav is a pretty good alternative.
comment 4y ago · link · parent
No benchmarks, though.
comment 4y ago · link · parent
CREATE VIRTUAL TABLE students_json_read USING lines_json_read(schema="students-schema.json);
Then, that one table could be used for multiple files: SELECT * FROM students_json_read('school1-students.json');
SELECT * FROM students_json_read('school2-students.json');comment 4y ago · link · parent
The PRQL pipeline syntax would make for a much better experience for lnav since you're able to progressively refine a query without having to jump around. (You've probably noticed that many log services, like Sumologic, already provide a pipeline-style syntax instead of something SQL-like.) The nice thing is that you can simply keep typing to get the results you want and get a preview at each stage. For example, entering "from" and then pressing <TAB> would make it clear to the program that table-names should be suggested. The program could then show the first few lines of the table. Typing "from syslog_log | filter " and then pressing <TAB> would make it clear that columns from the syslog_log table should be suggested (along with some other expression stuff). And, then, the preview of the filtered output could be shown.
In the current implementation, pressing <TAB> just suggests every possible thing in the universe, whether it's appropriate or not. This leaves the poor with not much help after they've typed "SELECT". I find myself having to lookup docs/source to figure out column names or whatever and I wrote the darn thing. Ultimately, I think the analysis functionality just doesn't get used because interactively writing SQL is so user-hostile. So, I'm looking forward to seeing this succeed so that I can integrate it and still be able to use SQLite in the backend.
comment 4y ago · link · parent
It's not specific to JSON/XML either, it works on any text that follows the usual conventions for structuring data in a textual way.
You can filter by level as well, but, usually I just press e/E to jump to the next/previous error from the current location.
There are, of course, many other features as well.
comment 4y ago · link · parent
The documentation for writing a format file is here -- https://docs.lnav.org/en/latest/formats.html
The format file tells lnav what common fields are in the log messages and how to format them into plaintext for display. Here's an example configuration for JSON logs -- https://github.com/tstack/fullsail_lnav_config/blob/master/f...
comment 4y ago · link · parent
comment 4y ago · link · parent
As for integrating with a “genders” host DB, there’s no direct support for it. But, lnav is scriptable, so I’m pretty sure it’s possible to write a script that does what you want. I can help with that if post in the github discussion: https://github.com/tstack/lnav/discussions
84.
Ask HN: Tools to generate coverage of user documentation for code
6 points · by tstack · 4y ago · 6 comments
comment 4y ago · link · parent
comment 4y ago · link · parent
comment 5y ago · link · parent
(Sorry this is a little off topic, but there’s a lot of room for improvement for working with log files over a text editor without scaling up to a log service)
comment 5y ago · link · parent
https://lnav.org/2021/05/03/tailing-remote-files.html
The main advantages of lnav over multitail is that it collates log files by time and does syntax highlighting. There are many other features as well -- https://lnav.org/features
comment 5y ago · link · parent