Skip to content

LogQL CLI

Lorenzo Mangani edited this page Mar 10, 2023 · 3 revisions

vlang-build

vLogQL

vLogQL is a CLI Client for qryn written in vlang

Instructions

Download a binary release or build from source

📦 Download Binary

curl -fsSL github.com/lmangani/vLogQL/releases/latest/download/vlogql -O && chmod +x vlogql

Build Source

📦 Install V
git clone https://github.com/vlang/v
(cd v && make && v symlink)
📖 Compile
git clone https://github.com/lmangani/vlogql
(cd vlogql && v -o vlogql -prod vlogql.v)

🔎 Usage

vlogql v0.1.3
-----------------------------------------------
Usage: vlogql [options] [ARGS]

Description: LogQL Query CLI

Options:
  -l, --limit <int>         logql query limit [LOGQL_LIMIT]
  -a, --api <string>        logql api [LOGQL_API]
  -q, --query <string>      logql query [LOGQL_QUERY]
  -t, --labels              get labels
  -v, --label <string>      get label values
  -s, --start <string>      start nanosec timestamp
  -e, --end <string>        end nanosec timestamp
  -x, --tail                tail mode
  -h, --help                display this help and exit

Examples

Query w/o Labels

# LOGQL_API="https://qryn:3100" ./vlogql --query '{type="clickhouse"} |~ "MiB"' --limit 5

---------- Logs for: {type="clickhouse"} |~ "MiB"
2022.03.13 10:39:19.765860 [ 29849 ] {} <Debug> MemoryTracker: Peak memory usage (for query): 8.11 MiB.
2022.03.13 10:39:19.761259 [ 29849 ] {115c1357-81d3-4277-ab04-882306f76e9d} <Debug> MemoryTracker: Peak memory usage (for query): 4.12 MiB.
2022.03.13 10:39:19.761288 [ 29849 ] {} <Debug> MemoryTracker: Peak memory usage (for query): 4.12 MiB.
2022.03.13 10:39:19.765798 [ 29849 ] {f050f9e5-f919-4680-b826-ea84be9542e0} <Debug> MemoryTracker: Peak memory usage (for query): 8.11 MiB.
2022.03.13 10:39:19.759982 [ 29849 ] {115c1357-81d3-4277-ab04-882306f76e9d} <Debug> DiskLocal: Reserving 1.00 MiB on disk `default`, having unreserved 2.63 TiB.

Query w/ Labels

# LOGQL_API="https://qryn:3100" ./vlogql --query '{type="clickhouse"} |~ "MiB"' --limit 4 --labels

---------- Logs for: {type="clickhouse"} |~ "MiB"
Log Labels: {'pid': '19639', 'level': 'Debug', 'call': 'MemoryTracker', 'type': 'clickhouse'}
2022.03.14 09:53:31.017408 [ 19639 ] {} <Debug> MemoryTracker: Peak memory usage (for query): 4.14 MiB.
2022.03.14 09:53:31.021778 [ 19639 ] {} <Debug> MemoryTracker: Peak memory usage (for query): 8.18 MiB.
2022.03.14 09:53:31.021759 [ 19639 ] {785ba1fa-3be3-4023-8a95-de4b92c096a4} <Debug> MemoryTracker: Peak memory usage (for query): 8.18 MiB.
2022.03.14 09:53:31.017389 [ 19639 ] {a34cbcc9-d11a-4a0a-8c7a-634e00322900} <Debug> MemoryTracker: Peak memory usage (for query): 4.14 MiB.

Query Labels

# LOGQL_API="https://qryn:3100" ./vlogql --labels

---------- Labels:
['response', 'host', 'type']

Query Label Values

# LOGQL_API="https://qryn:3100" ./vlogql --label type

---------- Values for: type
['clickhouse', 'prometheus']

Tails Logs by Tag

# LOGQL_API="https://qryn:3100" ./vlogql --query '{type="clickhouse"}' --tail

---------- Logs Tail
Log Labels: {'pid': '1658', 'level': 'Debug', 'type': 'clickhouse'}
2022.03.18 16:54:47.634586 [ 1658 ] {} <Debug> system.query_views_log (2bbc858b-05df-49d1-abbc-858b05df69d1): Removing part from filesystem 202203_405891_405891_0
2022.03.18 16:54:51.704528 [ 1658 ] {} <Debug> qryn.time_series (bfb2e93e-f78d-4692-bfb2-e93ef78d8692): Removing part from filesystem 20220318_22425079_22559905_26963
2022.03.18 16:54:51.704730 [ 1658 ] {} <Debug> qryn.time_series (bfb2e93e-f78d-4692-bfb2-e93ef78d8692): Removing part from filesystem 20220318_22559906_22559906_0
2022.03.18 16:54:51.704910 [ 1658 ] {} <Debug> qryn.time_series (bfb2e93e-f78d-4692-bfb2-e93ef78d8692): Removing part from filesystem 20220318_22559907_22559907_0
2022.03.18 16:54:51.705140 [ 1658 ] {} <Debug> qryn.time_series (bfb2e93e-f78d-4692-bfb2-e93ef78d8692): Removing part from filesystem 20220318_22559908_22559908_0

License

Licensed under MIT, sponsored by qxip as part of the qryn project