Giter Site home page Giter Site logo

victorialogs's Introduction

Loki On VictoriaMetrics

This project experimentally supports the loki protocol on the VictoriaMetrics Cluster, and the performance may be better than original loki.

More discussion can be found at VictoriaMetrics#816

Supported

  • LogQL, extends MetricsQL to support filter expressions and full PromQL & MetricsQL support for querying metrics.
  • Major HTTP API
    • /loki/api/v1/query
    • /loki/api/v1/query_range
    • /loki/api/v1/label & /loki/api/v1/labels
    • /loki/api/v1/label/<name>/values
    • /loki/api/v1/tail (websocket)
    • /loki/api/v1/push
  • Additional support for prometheus-style data writing via tcp, like loki{component="parser",level="WARN"} "app log line"

How to build & run

$ make all
$ bin/vmstorage
$ bin/vmselect -storageNode 127.0.0.1:8401
$ bin/vminsert -storageNode 127.0.0.1:8400 -importerListenAddr 127.0.0.1:2003

Set loki datasource endpoint as http://127.0.0.1:8481/select/0/, If you call it manually, the full URL is http://127.0.0.1:8481/select/0/loki/api/v1/query_range.

Test insert logs with tcp:

$ nc 127.0.0.1 2003
loki{component="parser",level="WARN"} "app log line"

If you want to call push api to insert data, use http://127.0.0.1:8480/insert/0/loki/api/v1/push.

For more details, please refer to VictoriaMetrics Cluster

Screenshot

loki-query-range

loki-live-tail

victorialogs's People

Contributors

belm0 avatar bigfish02 avatar buhrietoe avatar clmssz avatar cristaloleg avatar ctrlok avatar denisgolius avatar f41gh7 avatar faceair avatar foobar avatar freeseacher avatar glebsam avatar hagen1778 avatar hanzai avatar hekmon avatar jtyr avatar kreedom avatar langecode avatar mpoindexter avatar nezed avatar ofen avatar soffokl avatar stianovrevage avatar tenmozes avatar torwig avatar unflag avatar valyala avatar weenxin avatar xbsura avatar yinchuang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

victorialogs's Issues

Build Instructions

Hello @faceair - Great project here! I run cLoki, similiar initiative in NodeJS for clickhouse.

Could you share or add the intended basic build instructions to generate and test a local binary?

Querying returns broken/invalid results

I've been playing with this and querying seems fundamentally broken. I've built from db39e42 and have been sending data with netcat. I get a strange issue where characters from log lines overwrite characters in other log lines.

Here's a quick and nasty script to demonstrate:

pkill vmstorage
pkill vmselect
pkill vminsert

sleep 5

rm -rf vmstorage-data/

nohup bin/vmstorage > vmstorage.log 2>&1 &
nohup bin/vmselect -storageNode 127.0.0.1:8401 > vmselect.log 2>&1 &
nohup bin/vminsert -storageNode 127.0.0.1:8400 -importerListenAddr 127.0.0.1:2003 > vminsert.log 2>&1 &

sleep 30

echo 'loki{foo="bar"} "The course of true love never did run smooth."' | nc -vN 127.0.0.1 2003
sleep 1
curl -s http://127.0.0.1:8481/select/0/loki/api/v1/query_range --data-urlencode 'query={foo="bar"}' --data-urlencode 'step=60' | jq

echo 'loki{foo="bar"} "All that glisters is not gold."' | nc -vN 127.0.0.1 2003
sleep 2
curl -s http://127.0.0.1:8481/select/0/loki/api/v1/query_range --data-urlencode 'query={foo="bar"}' --data-urlencode 'step=60' | jq

echo 'loki{foo="bar"} "Whats in a name? That which we call a rose By any other name would smell as sweet."' | nc -vN 127.0.0.1 2003
sleep 3
curl -s http://127.0.0.1:8481/select/0/loki/api/v1/query_range --data-urlencode 'query={foo="bar"}' --data-urlencode 'step=60' | jq

echo 'loki{foo="bar"} "Once more unto the breach, dear friends, once more, Or close the wall up with our English dead!"' | nc -vN 127.0.0.1 2003
sleep 4
curl -s http://127.0.0.1:8481/select/0/loki/api/v1/query_range --data-urlencode 'query={foo="bar"}' --data-urlencode 'step=60' | jq

echo 'loki{foo="bar"} "By the pricking of my thumbs, Something wicked this way comes. Double, double toil and trouble; Fire burn, and cauldron bubble."' | nc -vN 127.0.0.1 2003
sleep 5
curl -s http://127.0.0.1:8481/select/0/loki/api/v1/query_range --data-urlencode 'query={foo="bar"}' --data-urlencode 'step=60' | jq

echo 'loki{foo="bar"} "log log log log"' | nc -vN 127.0.0.1 2003
curl -s http://127.0.0.1:8481/select/0/loki/api/v1/query_range --data-urlencode 'query={foo="bar"}' --data-urlencode 'step=60' | jq

sleep 15
curl -s http://127.0.0.1:8481/select/0/loki/api/v1/query_range --data-urlencode 'query={foo="bar"}' --data-urlencode 'step=60' | jq

The expected final response is 5 Shakespeare quotes and the line "log log log log" but what we actually get is:

{
  "status": "success",
  "data": {
    "resultType": "streams",
    "result": [
      {
        "stream": {
          "__name__": "loki",
          "foo": "bar"
        },
        "values": [
          [
            "1606968840550000000",
            "By the pricking of my thumbs, Something wicke"
          ],
          [
            "1606968841583000000",
            " this way comes. Double, doubl"
          ],
          [
            "1606968843619000000",
            " toil and trouble; Fire burn, and cauldron bubble.\u000flog log log log smell as sweet."
          ],
          [
            "1606968846650000000",
            "Once more unto the breach, dear friends, once more, Or close the wall up with our English dead!"
          ],
          [
            "1606968850686000000",
            "By the pricking of my thumbs, Something wicked this way comes. Double, double toil and trouble; Fire burn, and cauldron bubble."
          ],
          [
            "1606968855719000000",
            "log log log log"
          ]
        ]
      }
    ]
  }
}

You'll notice that my "log" messages are truncated, repeating, missing and (most surprising of all, "log log log log" is overlaid over the top of (half) a Shakespeare quote: "toil and trouble; Fire burn, and cauldron bubble.\u000flog log log log smell as sweet."

If you review the output of vminsert (e.g with tail vminsert.log), there was no problems reported writing the logs (e.g I've seen missing a end quote char will correctly return an error about being unable to umarshal.)

In Grafana, it looks like this (now-15m to now):
image

Furthermore, if I change the Time Range in Grafana, entire log lines disappear:
now-1h to now:
image
Note: There are less lines than above!

now-6h to now:
image
Note There are even less lines than above!

corrupted logs

loki query: {app="search-es"}
normal result:
image
unexpected result:
image

and these corrupted logs were stored in vmstorage. zstdgrep could find these logs in values.bin.

any debug tips?

metric is already registered

I just cloned master and built with make all and got the following error:

$ bin/vmselect -storageNode 127.0.0.1:8401

panic: BUG: metric "vm_cache_requests_total{type=\"promql/regexp\"}" is already registered

goroutine 1 [running]:
github.com/VictoriaMetrics/metrics.(*Set).mustRegisterLocked(0xc000146300, 0xa3b576, 0x2d, 0xae3120, 0xc00012c070)
	/root/go/pkg/mod/github.com/!victoria!metrics/[email protected]/set.go:450 +0x2ae
github.com/VictoriaMetrics/metrics.(*Set).registerMetric(0xc000146300, 0xa3b576, 0x2d, 0xae3120, 0xc00012c070)
	/root/go/pkg/mod/github.com/!victoria!metrics/[email protected]/set.go:433 +0xda
github.com/VictoriaMetrics/metrics.(*Set).NewGauge(0xc000146300, 0xa3b576, 0x2d, 0xc000110ea0, 0x0)
	/root/go/pkg/mod/github.com/!victoria!metrics/[email protected]/set.go:250 +0x89
github.com/VictoriaMetrics/metrics.NewGauge(...)
	/root/go/pkg/mod/github.com/!victoria!metrics/[email protected]/gauge.go:24
github.com/VictoriaMetrics/VictoriaLogs/lib/logql.glob..func1(0x7ff8000000000001)
	/usr/share/victorialogs/VictoriaLogs/lib/logql/regexp_cache.go:36 +0xbe
github.com/VictoriaMetrics/VictoriaLogs/lib/logql.init()
	/usr/share/victorialogs/VictoriaLogs/lib/logql/regexp_cache.go:46 +0xa39
root@victorialogs-0:/usr/share/victorialogs/VictoriaLogs#

To fix it, I had to do the following in lib/logql/regexp_cache.go:

-       "github.com/VictoriaMetrics/metrics"

and

-       metrics.NewGauge(`vm_cache_requests_total{type="promql/regexp"}`, func() float64 {
-               return float64(rc.Requests())
-       })
-       metrics.NewGauge(`vm_cache_misses_total{type="promql/regexp"}`, func() float64 {
-               return float64(rc.Misses())
-       })
-       metrics.NewGauge(`vm_cache_entries{type="promql/regexp"}`, func() float64 {
-               return float64(rc.Len())
-       })

After I did that, it make all ran successfully and the binaries appeared in bin/.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.