generated from TrueCloudLab/basic
[#5] logs: Add Loki
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
7960099809
commit
b3ad3335ff
8 changed files with 428 additions and 4 deletions
43
logging/lokicore/loki/example/main.go
Normal file
43
logging/lokicore/loki/example/main.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/logging/lokicore/loki"
|
||||
)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
const countMsgGroup = 100
|
||||
const countMsg = 500000
|
||||
|
||||
func send(loki *loki.Client) {
|
||||
wg.Add(1)
|
||||
defer wg.Done()
|
||||
|
||||
for j := 0; j < countMsg/countMsgGroup; j++ {
|
||||
for i := 0; i < countMsgGroup; i++ {
|
||||
loki.Send(strconv.Itoa(j)+" "+strconv.Itoa(i)+" test log message", time.Now())
|
||||
}
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
loki := loki.Setup(loki.Config{
|
||||
Endpoint: "localhost:3100/api/prom/push",
|
||||
Labels: map[string]string{
|
||||
"label": "test",
|
||||
},
|
||||
BatchWait: 1000,
|
||||
BatchEntriesNumber: 200,
|
||||
Enabled: true,
|
||||
})
|
||||
go send(loki)
|
||||
send(loki)
|
||||
|
||||
wg.Wait()
|
||||
loki.Shutdown()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue