Pull to refresh
20
0
Зайцев Артём @Arepo

Пользователь

Send message

jl-sql: SQL-запросы по JSON-логами в командной строке

Reading time 8 min
Views 10K

Вступление никому не интересно, поэтому начну сразу с примеров использования


json-pipe-sql
% cat log.json

{"type": "hit", "client": {"ip": "127.1.2.3"}}
{"type": "hit", "client": {"ip": "127.2.3.4"}}
{"type": "hit", "client": {"ip": "127.3.4.5"}}
{"type": "hit", "client": {"ip": "127.3.4.5"}}
{"type": "hit", "client": {"ip": "127.1.2.3"}}
{"type": "click", "client": {"ip": "127.1.2.3"}}
{"type": "click", "client": {"ip": "127.2.3.4"}}

Выполняем запрос:


% cat log.json | jl-sql 'SELECT client.ip, COUNT(*) AS count WHERE type = "hit" GROUP BY client.ip'

{"client":{"ip":"127.1.2.3"},"count":2}
{"client":{"ip":"127.2.3.4"},"count":1}
{"client":{"ip":"127.3.4.5"},"count":2}
Читать дальше →
Total votes 39: ↑39 and ↓0 +39
Comments 23

Information

Rating
Does not participate
Location
Москва и Московская обл., Россия
Registered
Activity