Skip to content

Latest commit

 

History

History

logql

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

LogQL

Parse and serialize LogQL query

npm version size ossf scorecard license

🚧 Requirements

🚀 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