Skip to content

Commit

Permalink
Merge pull request #120 from allproxy/v3-52-1
Browse files Browse the repository at this point in the history
Kubernettes object support
  • Loading branch information
davechri authored Nov 25, 2024
2 parents 33a7dfc + 447faae commit dc9057d
Show file tree
Hide file tree
Showing 49 changed files with 7,854 additions and 50 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<h1 align="center" style="border-bottom: none;">json-log-viewer</h1>
JSON Log Viewer is a web UI tool that makes JSON logs human readable.
<p></p>
JSON Log Viewer is a web UI tool to analyze JSON formatted data.

* It can be customized to highlight important fields.
* Kubernettes objects can be analyzed.

![Alt text](image-1.png)

Expand All @@ -23,6 +25,7 @@ JSON Log Viewer is a web UI tool that makes JSON logs human readable.
6. Log levels are colorized.
7. Display human readable or UTC timestamps.
8. Supports JSON lines and JSON file formats.
9. Analyze Kubernettes objects.

### Run Locally

Expand All @@ -41,6 +44,15 @@ To update the `allproxy` npm package run:
*NOTE**:
It is recommended that `Use hardware acceleration when available` is disabled on Chrome.

## Kubenettes Objects
The JSON output generated by `kubectl get -o json` can be imported and analyzed by `json-log-viewer`.

1. Use kubectl to get list of JSON Kubenettes objects:
```sh
kubectl get pods,deployments,configmaps,secrets -A -o json
```
2. Import the JSON output into `json-log-viewer`.

## Filtering

Advanced JSON field and boolean filters can be used to find relevant log records.
Expand Down
12 changes: 11 additions & 1 deletion briefJsonFields.json
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
{}
{
"action": true,
"status_code": true,
"StatusCode": true,
"error": true,
"Method": true,
"url": true,
"uri": true,
"path": true,
"metadata.deletionTimestamp": true
}
26 changes: 23 additions & 3 deletions docs/apFileSystem.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
{
"jsonFields": [],
"jsonFields": [
"Action",
"Body",
"Method",
"StatusCode",
"caller",
"code",
"deletionTimestamp",
"endpoint",
"error",
"id",
"kind",
"name",
"path",
"status",
"status_code",
"uri",
"url",
"userAgent",
"user_agent"
],
"method": "advanced",
"jsonLogScript": "// Function called to extract date, level, app name and message\n//\n// @param preJSONString: string - optional non-JSON string proceeding JSON object\n// @param jsonObject: {} - JSON log data\n// @returns {date: Date, level: string, category: string, appName: string, message: string, rawLine: string, additionalJSON: {} }\n//\n// category is the availability zone\n// appName is the pod name\n//\nconst extractDateLevelCategoryAppNameMessage = function (preJSONString, jsonObject) {\n let level = 'info';\n let date = new Date();\n let category = '';\n let kind = 'kind_is_not_set';\n let message = 'Message is not set - click ? and \"Edit JSON Script\"';\n // return raw JSON (optional)\n let rawLine;\n // Copy any JSON fields not defined in jsonObject\n let additionalJSON = {};\n\n // Set the level\n // level = jsonObject.m_level;\n\n // Set the date\n // date = jsonObject.my_date;\n\n // Set the kind\n //kind = jsonObject.my_kind;\n\n // Set message\n //message = jsonObject.my_message;\n\n return { date, level, category, kind, message, rawLine, additionalJSON };\n}",
"jsonLogScript": "// Function called to extract date, level, app name and message\n//\n// @param preJSONString: string - optional non-JSON string proceeding JSON object\n// @param jsonObject: {} - JSON log data\n// @returns {date: Date, level: string, category: string, appName: string, message: string, rawLine: string, additionalJSON: {} }\n//\n// category is the availability zone\n// appName is the pod name\n//\nconst extractDateLevelCategoryAppNameMessage = function (preJSONString, jsonObject) {\n let level = 'info';\n let date = new Date();\n let category = '';\n let kind = 'Kind_is_not_set';\n let message = 'Message is not set - edit or replace client/public/parsejson/plugin.js';\n let additionalJSON = {};\n const ignoreFields = [];\n // Kube object?\n if (jsonObject.kind && jsonObject.metadata) {\n kind = jsonObject.kind;\n message = jsonObject.metadata.name;\n if (jsonObject.metadata.creationTimestamp) {\n date = new Date(jsonObject.metadata.creationTimestamp);\n }\n level = '';\n additionalJSON['level'] = undefined;\n // Errors detected by the parseJson plugin?\n if (jsonObject['errors']) {\n level = 'error';\n additionalJSON['level'] = level;\n }\n }\n else { // Check for other log formats\n }\n return { date, level, category, kind, message, rawLine: undefined, additionalJSON, ignoreFields };\n}",
"queries": {},
"briefJsonFields": "{}",
"briefJsonFields": "{\n \"action\": true,\n \"status_code\": true,\n \"StatusCode\": true,\n \"error\": true,\n \"Method\": true,\n \"url\": true,\n \"uri\": true,\n \"path\": true,\n \"metadata.deletionTimestamp\": true\n}",
"jsonSubQueries": "[]",
"jsonQueries": "[]"
}
200 changes: 199 additions & 1 deletion docs/plugins/importjson/plugin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/plugins/importjson/plugin.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

95 changes: 71 additions & 24 deletions docs/plugins/parsejson/plugin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dc9057d

Please sign in to comment.