@sigyn/logql
v2.1.0
Published
Parse and serialize LogQL queries
Downloads
164
Readme
🚧 Requirements
- Node.js version 18 or higher
🚀 Getting Started
This package is available in the Node Package Repository and can be easily installed with npm or yarn
$ npm i @sigyn/logql
# or
$ yarn add @sigyn/logql
📚 Usage
Build your LogQL
import { LogQL } from "@sigyn/logql";
const logql = new LogQL("foo");
logql.streamSelector.set("env", "prod");
logql.lineEq("bar");
logql.lineNotEq("baz");
// {env=\"prod\"} |= `foo` |= `bar` != `baz`
console.log(logql.toString());
Parse your LogQL
import { LogQL } from "@sigyn/logql";
const logql = new LogQL("{app=\"foo\", env=\"preprod\"} |= `foo` != `bar`");
console.log([...logql.streamSelector.entries()]);
console.log(logql.lineFilters.lineContains());
console.log(logql.lineFilters.lineDoesNotContain());
🌐 API
Individual LogQL parts (used in the parent class). You can also use them individually for separate needs.
{env="staging"} |= "req-xxx" | pattern `ok: <ok>` | ok = "true" | unpack
^^^ ^^^ ^^^ ^^^ ^
StreamSelector LineFilters ParserExpression LabelFilters ParserExpression
License
MIT