Это старая версия документа!


Loki фильтры

Взять любые значения и применить к ним фильтр json:

{stream=~".+", job=~".*", instance=~".*", cluster=""} | json

эквивалент:

{stream=~".+"} | json

В распарсенном json поискать значения парочки ключей:

{stream=~".+"} | json | http_host=`site.ru` | status > 299

Вот так я ищу ошибку в monolog:

{stream=~".+"} | json | message=`error message`

Найти точно по левой части и что-угодно справа:

request_uri=~"^/foo(.*)"

Найти по части совпадения строки:

{stream=~".+"}|~ "(.*)Find and save image problems(.*)"

Тоже самое, но сначала распарсить json:

{stream=~".+"} | json | message=~`(.*)Uncaught PHP Exception Doctrine(.*)`

OR условие:

... | json | scheme=`https` | status=~"301|302" [$__auto])))

Отрицание:

http_referer !~`(http|https)://yapro.ru(.*)`

Сформировать строку из разных значений:

| line_format "➡️ {{.request_method}} {{.request_uri}} with HTTP status: {{.status}} "
sum(count_over_time({app="servicefoundry-server"}[24h]))
{namespace="truefoundry", app!="grafana"} |= "[UNIQUE-STATIC-LOG] ID=abc123 XYZ"
{app="servicefoundry-server"} |= ":3000"
{namespace="truefoundry"} |= "non-existent log line"
{namespace="truefoundry"} |= "non-existent log line"

{container_name="nextcloud-cron-1"} | json | line_format `{{.log_raw}}`
{container_name="nextcloud-cron-1"} | json | line_format `{{.level}}`