cLoki / LogQL Client in vlang
Download a binary release or build from source
curl -fsSL github.com/lmangani/vLogQL/releases/latest/download/vlogql -O && chmod +x vlogql
git clone https://github.com/vlang/v
(cd v && make && v symlink)
git clone https://github.com/lmangani/vlogql
(cd vlogql && v -o vlogql -prod vlogql.v)
Usage: vlogql [options] [ARGS]
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
-c, --canary canary mode
-h, --help display this help and exit
# LOGQL_API="https://cloki: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.
# LOGQL_API="https://cloki: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.
# LOGQL_API="https://cloki:3100" ./vlogql --labels
---------- Labels:
['response', 'host', 'type']
# LOGQL_API="https://cloki:3100" ./vlogql --label type
---------- Values for: type
['clickhouse', 'prometheus']
# LOGQL_API="https://cloki: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> cloki.time_series (bfb2e93e-f78d-4692-bfb2-e93ef78d8692): Removing part from filesystem 20220318_22425079_22559905_26963
2022.03.18 16:54:51.704730 [ 1658 ] {} <Debug> cloki.time_series (bfb2e93e-f78d-4692-bfb2-e93ef78d8692): Removing part from filesystem 20220318_22559906_22559906_0
2022.03.18 16:54:51.704910 [ 1658 ] {} <Debug> cloki.time_series (bfb2e93e-f78d-4692-bfb2-e93ef78d8692): Removing part from filesystem 20220318_22559907_22559907_0
2022.03.18 16:54:51.705140 [ 1658 ] {} <Debug> cloki.time_series (bfb2e93e-f78d-4692-bfb2-e93ef78d8692): Removing part from filesystem 20220318_22559908_22559908_0
# LOGQL_API="https://cloki:3100" ./vlogql --canary
---------- Tail Canary Logs:
PUSH Successful: {"streams":[{"stream": {"canary":"canary_vgKhkQ5g3S2s","type":"canary"}, "values":[ ["1649006282946000000", "ts=1649006282946000000 type=canary data=1111111111111111111111111111111111111111111111"] ]}]}
Sleeping 10 seconds...
Log Labels: {'canary': 'canary_vgKhkQ5g3S2s', 'type': 'canary'}
ts=1649006282946000000 type=canary data=1111111111111111111111111111111111111111111111
Licensed under MIT, sponsored by qxip as part of the cLoki project