jsonfile
Queries data from a line-delimited JSON file.
Command properties
| Property | Value |
|---|---|
| Command type | Driver query |
| Required permission | Local file read permission |
| License usage | Counted |
| Parallel execution | Not supported |
| Distributed execution | Not supported |
Syntax
jsonfile [offset=INT] [limit=INT] [overlay={t|f}] PATH
Options
offset=INT- Number of records to skip.
limit=INT- Maximum number of records to retrieve.
overlay={t|f}- When set to
t, retains the original data while overwriting with parsed key-value pairs when an additional parser is applied. When set tofor not specified, only the parsed key-value pairs are output instead of the original.
Target
PATH- Path to the JSON file. The file must be a text file where each line is a JSON object. Wildcards (
*) are supported. Files with a.gzextension are automatically decompressed.
Output fields
| Field | Type | Description |
|---|---|---|
| (JSON key) | auto | Fields automatically mapped from JSON object key-value pairs |
| _file | string | Original file name |
| _time | timestamp | Timestamp parsed from JSON or the file modification time |
Error codes
Parsing errors
| Error code | Message | Description |
|---|---|---|
| 10902 | - | File path not specified |
| 10900 | - | File does not exist or cannot be read |
| 10901 | - | Parent directory does not exist or cannot be read |
| 10903 | - | File access denied |
Description
The jsonfile command queries data from a text file where each line separated by CR LF or LF contains JSON. Each line's JSON object is mapped to one record, and JSON key-value pairs are automatically converted to Logpresso types.
Files that include a BOM (Byte Order Mark) are automatically recognized.
Examples
-
Query a JSON file
jsonfile /opt/logpresso/data/events.jsonQueries all data from the line-delimited JSON file.
-
Query with a limit on record count
jsonfile offset=100 limit=50 /opt/logpresso/data/events.jsonSkips the first 100 records and retrieves 50 records.