Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lmangani/vLogQL
Loki/LogQL CLI Client in V for qryn
https://github.com/lmangani/vLogQL
client grafana logql logs loki qryn query search v vlang
Last synced: 3 months ago
JSON representation
Loki/LogQL CLI Client in V for qryn
- Host: GitHub
- URL: https://github.com/lmangani/vLogQL
- Owner: lmangani
- License: mit
- Created: 2022-03-13T09:31:00.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-14T14:45:19.000Z (8 months ago)
- Last Synced: 2024-06-19T03:09:28.461Z (5 months ago)
- Topics: client, grafana, logql, logs, loki, qryn, query, search, v, vlang
- Language: V
- Homepage: https://qryn.dev
- Size: 96.7 KB
- Stars: 16
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-v - vLogQL - A tiny command-line utility to query LogQL APIs. (Applications / Command-line)
README
[![vlang-build-pipeline](https://github.com/lmangani/vLogQL/actions/workflows/vlang.yml/badge.svg?branch=main)](https://github.com/lmangani/vLogQL/actions/workflows/vlang.yml)
# vLogQL
Tiny, portable, static LogQL CLI Client in [vlang](https://vlang.io/)### Instructions
Download a [binary release](https://github.com/lmangani/vLogQL/releases/) or build from source#### 📦 Download Binary
```
curl -fsSL github.com/lmangani/vLogQL/releases/latest/download/vlogql -O && chmod +x vlogql
```#### Build Source
##### 📦 Install V
```bash
git clone https://github.com/vlang/v
(cd v && make && v symlink)
```
##### 📖 Compile
```bash
git clone https://github.com/lmangani/vlogql
(cd vlogql && v -o vlogql -prod vlogql.v)
```### 🔎 Usage
```
Usage: vlogql [options] [ARGS]Options:
-l, --limit logql query limit [LOGQL_LIMIT]
-a, --api logql api [LOGQL_API]
-q, --query logql query [LOGQL_QUERY]
-t, --labels get labels
-v, --label get label values
-z, --timestamp get timestamp
-s, --start start nanosec timestamp
-e, --end end nanosec timestamp
-x, --tail tail mode
-c, --canary canary mode
-h, --help display this help and exit
```#### ⭐ Examples
##### Query w/o Labels
```bash
# 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 ] {} MemoryTracker: Peak memory usage (for query): 8.11 MiB.
2022.03.13 10:39:19.761259 [ 29849 ] {115c1357-81d3-4277-ab04-882306f76e9d} MemoryTracker: Peak memory usage (for query): 4.12 MiB.
2022.03.13 10:39:19.761288 [ 29849 ] {} MemoryTracker: Peak memory usage (for query): 4.12 MiB.
2022.03.13 10:39:19.765798 [ 29849 ] {f050f9e5-f919-4680-b826-ea84be9542e0} MemoryTracker: Peak memory usage (for query): 8.11 MiB.
2022.03.13 10:39:19.759982 [ 29849 ] {115c1357-81d3-4277-ab04-882306f76e9d} DiskLocal: Reserving 1.00 MiB on disk `default`, having unreserved 2.63 TiB.
```##### Query w/ Labels
```bash
# 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 ] {} MemoryTracker: Peak memory usage (for query): 4.14 MiB.
2022.03.14 09:53:31.021778 [ 19639 ] {} MemoryTracker: Peak memory usage (for query): 8.18 MiB.
2022.03.14 09:53:31.021759 [ 19639 ] {785ba1fa-3be3-4023-8a95-de4b92c096a4} MemoryTracker: Peak memory usage (for query): 8.18 MiB.
2022.03.14 09:53:31.017389 [ 19639 ] {a34cbcc9-d11a-4a0a-8c7a-634e00322900} MemoryTracker: Peak memory usage (for query): 4.14 MiB.
```
##### Query Labels
```bash
# LOGQL_API="https://qryn:3100" ./vlogql --labels---------- Labels:
['response', 'host', 'type']
```
##### Query Label Values
```bash
# LOGQL_API="https://qryn:3100" ./vlogql --label type---------- Values for: type
['clickhouse', 'prometheus']
```##### Tail Logs by Tag _(websocket)_
```bash
# 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 ] {} 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 ] {} cloki.time_series (bfb2e93e-f78d-4692-bfb2-e93ef78d8692): Removing part from filesystem 20220318_22425079_22559905_26963
2022.03.18 16:54:51.704730 [ 1658 ] {} cloki.time_series (bfb2e93e-f78d-4692-bfb2-e93ef78d8692): Removing part from filesystem 20220318_22559906_22559906_0
2022.03.18 16:54:51.704910 [ 1658 ] {} cloki.time_series (bfb2e93e-f78d-4692-bfb2-e93ef78d8692): Removing part from filesystem 20220318_22559907_22559907_0
2022.03.18 16:54:51.705140 [ 1658 ] {} cloki.time_series (bfb2e93e-f78d-4692-bfb2-e93ef78d8692): Removing part from filesystem 20220318_22559908_22559908_0
```##### Canary Logs _(push + websocket)_
```bash
# LOGQL_API="https://qryn:3100" CANARY_TIMER=10 ./vlogql --canary --labels---------- Tail Canary Logs
PUSH Successful: {"streams":[{"stream": {"canary":"canary_9cwAkBFDlrcA","type":"canary"}, "values":[ ["1649007076406000000", "ts=1649007076406000000 count=3 type=canary tag=canary_9cwAkBFDlrcA"] ]}]}
Sleeping 10 seconds...
Log Labels: {'canary': 'canary_9cwAkBFDlrcA', 'type': 'canary'}
ts=1649007076406000000 count=3 type=canary tag=canary_9cwAkBFDlrcA
PUSH Successful: {"streams":[{"stream": {"canary":"canary_9cwAkBFDlrcA","type":"canary"}, "values":[ ["1649007086482000000", "ts=1649007086482000000 count=4 type=canary tag=canary_9cwAkBFDlrcA"] ]}]}
Sleeping 10 seconds...
Log Labels: {'canary': 'canary_9cwAkBFDlrcA', 'type': 'canary'}
ts=1649007086482000000 count=4 type=canary tag=canary_9cwAkBFDlrcA
```-----
### License
Licensed under MIT, sponsored by [qxip](https://metrico.in) as part of the [metrico/qryn](https://metrico.in) project