mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
5b3cbd4db1
* app/vlinsert: add support of loki push protocol - implemented loki push protocol for both Protobuf and JSON formats - added examples in documentation - added example docker-compose Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> * app/vlinsert: move protobuf metric into its own file Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> * deployment/docker/victorialogs/promtail: update reference to docker image Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> * deployment/docker/victorialogs/promtail: make volume name unique Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> * app/vlinsert/loki: add license reference Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> * deployment/docker/victorialogs/promtail: fix volume name Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> * docs/VictoriaLogs/data-ingestion: add stream fields for loki JSON ingestion example Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> * app/vlinsert/loki: move entities to places where those are used Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> * app/vlinsert/loki: refactor to use common components - use CommonParameters from insertutils - stop ingestion after first error similar to elasticsearch and jsonline Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> * app/vlinsert/loki: address review feedback - add missing logstorage.PutLogRows calls - refactor tenant ID parsing to use common function - reduce number of allocations for parsing by reusing logfields slices - add tests and benchmarks for requests processing funcs Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> --------- Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>
73 lines
1.5 KiB
Go
73 lines
1.5 KiB
Go
package loki
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logstorage"
|
|
)
|
|
|
|
func BenchmarkProcessJSONRequest(b *testing.B) {
|
|
for _, streams := range []int{5, 10} {
|
|
for _, rows := range []int{100, 1000} {
|
|
for _, labels := range []int{10, 50} {
|
|
b.Run(fmt.Sprintf("streams_%d/rows_%d/labels_%d", streams, rows, labels), func(b *testing.B) {
|
|
benchmarkProcessJSONRequest(b, streams, rows, labels)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func benchmarkProcessJSONRequest(b *testing.B, streams, rows, labels int) {
|
|
s := getJSONBody(streams, rows, labels)
|
|
b.ReportAllocs()
|
|
b.SetBytes(int64(len(s)))
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
for pb.Next() {
|
|
_, err := processJSONRequest(strings.NewReader(s), func(timestamp int64, fields []logstorage.Field) {})
|
|
if err != nil {
|
|
b.Fatalf("unexpected error: %s", err)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
func getJSONBody(streams, rows, labels int) string {
|
|
body := `{"streams":[`
|
|
now := time.Now().UnixNano()
|
|
valuePrefix := fmt.Sprintf(`["%d","value_`, now)
|
|
|
|
for i := 0; i < streams; i++ {
|
|
body += `{"stream":{`
|
|
|
|
for j := 0; j < labels; j++ {
|
|
body += `"label_` + strconv.Itoa(j) + `":"value_` + strconv.Itoa(j) + `"`
|
|
if j < labels-1 {
|
|
body += `,`
|
|
}
|
|
|
|
}
|
|
body += `}, "values":[`
|
|
|
|
for j := 0; j < rows; j++ {
|
|
body += valuePrefix + strconv.Itoa(j) + `"]`
|
|
if j < rows-1 {
|
|
body += `,`
|
|
}
|
|
}
|
|
|
|
body += `]}`
|
|
if i < streams-1 {
|
|
body += `,`
|
|
}
|
|
|
|
}
|
|
|
|
body += `]}`
|
|
|
|
return body
|
|
}
|