-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
159 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,167 +5,28 @@ | |
[![Go Report Card](https://goreportcard.com/badge/github.com/hedhyw/json-log-viewer)](https://goreportcard.com/report/github.com/hedhyw/json-log-viewer) | ||
[![Coverage Status](https://coveralls.io/repos/github/hedhyw/json-log-viewer/badge.svg?branch=main)](https://coveralls.io/github/hedhyw/json-log-viewer?branch=main) | ||
|
||
It is an **interactive** tool for viewing and analyzing complex structured [json-log](assets/example.log) files. | ||
An interactive tool for viewing and analyzing complex structured JSON logs. | ||
|
||
![Animation](./assets/animation.webp) | ||
|
||
Main features: | ||
1. It is interactive. | ||
2. It displays a compact list of log entries. | ||
3. It is possible to expand the log and see the full prettified JSON tree. | ||
4. All non-json logs are captured. | ||
5. Fields are [customizable](#customization). | ||
6. Filtering is easy to use. | ||
7. Log levels are colorized. | ||
8. Transforming numeric timestamps. | ||
## Installation | ||
|
||
It uses [antonmedv/fx](https://github.com/antonmedv/fx) for viewing JSON records and [charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) for organizing the terminal UI. The tool is inspired by the project [json-log-viewer](https://github.com/gistia/json-log-viewer) which is unfortunately outdated and deserted. | ||
|
||
The application is designed to help in visualization, navigation, and analyzing of JSON-formatted log data in a user-friendly and interactive manner. It provides a structured and organized view of the JSON logs, making it easier to comprehend the hierarchical nature of the data. It uses collapsible/expandable tree structures, indentation, and color-coded syntax to represent the JSON objects and arrays. It is possible to search for specific keywords, phrases, or patterns within the JSON logs. So it helps to significantly simplify the process of working with JSON logs, making it more intuitive and efficient. It is easy to troubleshoot issues, monitor system performance, or gain a deeper understanding of the application's behavior by analyzing its log data in post-mortem. | ||
|
||
## Table of content | ||
|
||
- [JSON Log Viewer](#json-log-viewer) | ||
- [Table of content](#table-of-content) | ||
- [Usage](#usage) | ||
- [Reading from file](#reading-from-file) | ||
- [Reading from Stdin](#reading-from-stdin) | ||
- [Hotkeys](#hotkeys) | ||
- [Install](#install) | ||
- [MacOS/Linux HomeBrew](#macoslinux-homebrew) | ||
- [Package](#package) | ||
- [Standalone Binary](#standalone-binary) | ||
- [Source](#source) | ||
- [Customization](#customization) | ||
- [Time Formats](#time-formats) | ||
- [`time`](#time) | ||
- [`numerictime`](#numerictime) | ||
- [`secondtime`](#secondtime) | ||
- [`millitime`](#millitime) | ||
- [`microtime`](#microtime) | ||
- [Resources](#resources) | ||
- [Contribution](#contribution) | ||
- [License](#license) | ||
|
||
## Usage | ||
|
||
### Reading from file | ||
```shell | ||
jlv assets/example.log | ||
jlv -config example.jlv.jsonc assets/example.log | ||
``` | ||
|
||
### Reading from Stdin | ||
|
||
```shell | ||
jlv < assets/example.log | ||
``` | ||
|
||
Common applications: | ||
### Homebrew | ||
|
||
```shell | ||
curl https://raw.githubusercontent.com/hedhyw/json-log-viewer/main/assets/example.log | jlv | ||
|
||
jlv << EOF | ||
{"time":"1970-01-01T00:00:00.00","level":"INFO","message": "day 1"} | ||
{"time":"1970-01-02T00:00:00.00","level":"INFO","message": "day 2"} | ||
EOF | ||
|
||
kubectl logs pod/POD_NAME -f | jlv | ||
docker logs -f 000000000000 2>&1 | jlv | ||
``` | ||
|
||
### Hotkeys | ||
|
||
| Key | Action | | ||
|--------|-------------------| | ||
| Enter | Open log | | ||
| Esc | Back | | ||
| F | Filter | | ||
| R | Reverse | | ||
| Ctrl+C | Exit | | ||
| F10 | Exit | | ||
| ↑↓ | Line Up / Down | | ||
| Home | Navigate to Start | | ||
| End | Navigate to End | | ||
|
||
> Attempting to navigate past the last line in the log will put you in follow mode. | ||
## Install | ||
|
||
### MacOS/Linux HomeBrew | ||
|
||
```sh | ||
brew install hedhyw/main/jlv | ||
# jlv application.log | ||
``` | ||
|
||
### Package | ||
|
||
Latest DEB and RPM packages are available on [the releases page](https://github.com/hedhyw/json-log-viewer/releases/latest). | ||
|
||
### Standalone Binary | ||
|
||
Download latest archive `*.tar.gz` for your target platform from [the releases page](https://github.com/hedhyw/json-log-viewer/releases/latest) and extract it to `/usr/local/bin/jlv`. Add this path to `PATH` environment. | ||
|
||
### Source | ||
|
||
```sh | ||
git clone [email protected]:hedhyw/json-log-viewer.git | ||
cd json-log-viewer | ||
make build | ||
cp ./bin/jlv /usr/local/bin | ||
chmod +x /usr/local/bin/jlv | ||
|
||
# jlv application.log | ||
``` | ||
|
||
## Customization | ||
|
||
The application will look for the config `.jlv.jsonc` in the working directory or in the home directory: | ||
- `$PWD/.jlv.jsonc`; | ||
- `$HOME/.jlv.jsonc`. | ||
|
||
It's also possible to define the path to the configuration using "-config" flag. | ||
|
||
The Json path supports the described in [yalp/jsonpath](https://github.com/yalp/jsonpath#jsonpath-quick-intro) syntax. | ||
|
||
Example configuration: [example.jlv.jsonc](example.jlv.jsonc). | ||
|
||
### Time Formats | ||
JSON Log Viewer can handle a variety of datetime formats when parsing your logs. | ||
The value is formatted by default in the "[RFC3339](https://www.rfc-editor.org/rfc/rfc3339)" format. The format is configurable, see the `time_format` field in the [config](example.jlv.jsonc). | ||
|
||
#### `time` | ||
This will return the exact value that was set in the JSON document. | ||
|
||
#### `numerictime` | ||
This is a "smart" parser. It can accept an integer, a float, or a string. If it is numeric (`1234443`, `1234443.589`, `"1234443"`, `"1234443.589"`), based on the number of digits, it will parse as seconds, milliseconds, or microseconds. The output is a UTC-based RFC 3339 datetime. | ||
|
||
If a string such as `"2023-05-01T12:00:34Z"` or `"---"` is used, the value will just be carried forward to your column. | ||
|
||
If you find that the smart parsing is giving unwanted results or you need greater control over how a datetime is parsed, considered using one of the other time formats instead. | ||
|
||
#### `secondtime` | ||
This will attempt to parse the value as number of seconds and render as a UTC-based RFC 3339. Values accepted are integer, string, or float. | ||
|
||
#### `millitime` | ||
Similar to `secondtime`, this will attempt to parse the value as number of milliseconds. Values accepted are integer, string, or float. | ||
|
||
#### `microtime` | ||
Similar to `secondtime` and `millistime`, this will attempt to parse the value as number of microseconds. Values accepted are integer, string, or float. | ||
|
||
## Resources | ||
|
||
Alternatives: | ||
- [mightyguava/jl](https://github.com/mightyguava/jl) - Pretty Viewer for JSON logs. | ||
- [pamburus/hl](https://github.com/pamburus/hl) - A log viewer that translates JSON logs into human-readable representation. | ||
- [json-log-viewer](https://github.com/gistia/json-log-viewer) - Powerful terminal based viewer for JSON logs using ncurses. | ||
|
||
## Contribution | ||
### Standalone Binary, DEB or RPM packages | ||
|
||
Check [open unassigned issues](https://github.com/hedhyw/json-log-viewer/issues), write comments, ask questions, fork, and create a pull request. | ||
https://github.com/hedhyw/json-log-viewer/releases/latest | ||
|
||
## License | ||
## Documentation | ||
|
||
[MIT License](LICENSE). | ||
- [Features](docs/features.md). | ||
- [Install from source](docs/install-from-source.md). | ||
- [Usage](docs/usage.md). | ||
- [Customization](docs/customization.md). | ||
- [Resources](docs/resources.md). | ||
- [Contribution](docs/CONTRIBUTING). | ||
- [MIT License](LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
# Contribution | ||
|
||
- Check [open unassigned issues](https://github.com/hedhyw/json-log-viewer/issues); | ||
- Write comments; | ||
- Ask questions; | ||
- Fork; | ||
- Create a PR with your changes. | ||
|
||
Thank you! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Customization | ||
|
||
The application will look for the config `.jlv.jsonc` in the working directory or in the home directory: | ||
- `$PWD/.jlv.jsonc`; | ||
- `$HOME/.jlv.jsonc`. | ||
|
||
It's also possible to define the path to the configuration using "-config" flag. | ||
|
||
The Json path supports the described in [yalp/jsonpath](https://github.com/yalp/jsonpath#jsonpath-quick-intro) syntax. | ||
|
||
Example configuration: [example.jlv.jsonc](../example.jlv.jsonc). | ||
|
||
## Time Formats | ||
JSON Log Viewer can handle a variety of datetime formats when parsing your logs. | ||
The value is formatted by default in the "[RFC3339](https://www.rfc-editor.org/rfc/rfc3339)" format. The format is configurable, see the `time_format` field in the [config](../example.jlv.jsonc). | ||
|
||
### `time` | ||
This will return the exact value that was set in the JSON document. | ||
|
||
### `numerictime` | ||
This is a "smart" parser. It can accept an integer, a float, or a string. If it is numeric (`1234443`, `1234443.589`, `"1234443"`, `"1234443.589"`), based on the number of digits, it will parse as seconds, milliseconds, or microseconds. The output is a UTC-based RFC 3339 datetime. | ||
|
||
If a string such as `"2023-05-01T12:00:34Z"` or `"---"` is used, the value will just be carried forward to your column. | ||
|
||
If you find that the smart parsing is giving unwanted results or you need greater control over how a datetime is parsed, considered using one of the other time formats instead. | ||
|
||
### `secondtime` | ||
This will attempt to parse the value as number of seconds and render as a UTC-based RFC 3339. Values accepted are integer, string, or float. | ||
|
||
### `millitime` | ||
Similar to `secondtime`, this will attempt to parse the value as number of milliseconds. Values accepted are integer, string, or float. | ||
|
||
### `microtime` | ||
Similar to `secondtime` and `millistime`, this will attempt to parse the value as number of microseconds. Values accepted are integer, string, or float. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Features | ||
|
||
It is an **interactive** tool for viewing and analyzing complex structured [json-log](../assets/example.log) files. | ||
|
||
Main features: | ||
1. It is interactive. | ||
2. It displays a compact list of log entries. | ||
3. It is possible to expand the log and see the full prettified JSON tree. | ||
4. All non-json logs are captured. | ||
5. Fields are [customizable](./customization.md). | ||
6. Filtering is easy to use. | ||
7. Log levels are colorized. | ||
8. Transforming numeric timestamps. | ||
|
||
It uses [antonmedv/fx](https://github.com/antonmedv/fx) for viewing JSON records and [charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) for organizing the terminal UI. The tool is inspired by the project [json-log-viewer](https://github.com/gistia/json-log-viewer) which is unfortunately outdated and deserted. | ||
|
||
The application is designed to help in visualization, navigation, and analyzing of JSON-formatted log data in a user-friendly and interactive manner. It provides a structured and organized view of the JSON logs, making it easier to comprehend the hierarchical nature of the data. It uses collapsible/expandable tree structures, indentation, and color-coded syntax to represent the JSON objects and arrays. It is possible to search for specific keywords, phrases, or patterns within the JSON logs. So it helps to significantly simplify the process of working with JSON logs, making it more intuitive and efficient. It is easy to troubleshoot issues, monitor system performance, or gain a deeper understanding of the application's behavior by analyzing its log data in post-mortem. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Install from source | ||
|
||
## Requirements | ||
- `git`; | ||
- `make`; | ||
- `go` 1.23+. | ||
|
||
## Run | ||
|
||
Get the source code: | ||
```shell | ||
git clone [email protected]:hedhyw/json-log-viewer.git && cd json-log-viewer | ||
``` | ||
|
||
Compile: | ||
```shell | ||
make build | ||
``` | ||
|
||
Install: | ||
```shell | ||
cp ./bin/jlv /usr/local/bin | ||
chmod +x /usr/local/bin/jlv | ||
``` | ||
|
||
Use as [jlv](usage.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Resources | ||
|
||
Alternative applications: | ||
- [mightyguava/jl](https://github.com/mightyguava/jl) - Pretty Viewer for JSON logs. | ||
- [pamburus/hl](https://github.com/pamburus/hl) - A log viewer that translates JSON logs into human-readable representation. | ||
- [json-log-viewer](https://github.com/gistia/json-log-viewer) - Powerful terminal based viewer for JSON logs using ncurses. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Advanced usage | ||
|
||
## Hotkeys | ||
|
||
| Key | Action | | ||
|--------|-------------------| | ||
| Enter | Open log | | ||
| Esc | Back | | ||
| F | Filter | | ||
| R | Reverse | | ||
| Ctrl+C | Exit | | ||
| F10 | Exit | | ||
| ↑↓ | Line Up / Down | | ||
| Home | Navigate to Start | | ||
| End | Navigate to End | | ||
| ? | Show/Hide help | | ||
|
||
> Attempting to navigate past the last line in the log will put you in follow mode. | ||
## Configuration | ||
|
||
```shell | ||
jlv -config example.jlv.jsonc assets/example.log | ||
jlv -config example.jlv.jsonc < assets/example.log | ||
``` | ||
|
||
## Pull logs by URL | ||
|
||
```shell | ||
URL="https://raw.githubusercontent.com/hedhyw/json-log-viewer/main/assets/example.log" | ||
curl "$URL" | jlv | ||
``` | ||
|
||
## Preview logs from string | ||
|
||
```shell | ||
jlv << EOF | ||
{"time":"1970-01-01T00:00:00.00","level":"INFO","message": "day 1"} | ||
{"time":"1970-01-02T00:00:00.00","level":"INFO","message": "day 2"} | ||
EOF | ||
``` | ||
|
||
## Show kubernetes logs | ||
|
||
```shell | ||
kubectl logs pod/POD_NAME -f | jlv | ||
``` | ||
|
||
## View docker logs | ||
|
||
```shell | ||
docker logs -f 000000000000 2>&1 | jlv | ||
``` |