frostfs-observability/logging/lokicore/loki/example/main.go

44 lines
769 B
Go
Raw Normal View History

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()
}