From e4928ee1fff09ebcadaa5648799d4d9efc16c505 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 20 May 2024 02:50:19 +0200 Subject: [PATCH] wip --- app/vlogsgenerator/README.md | 6 ++++-- app/vlogsgenerator/main.go | 5 +++++ lib/logstorage/pipe_unpack_json_test.go | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/vlogsgenerator/README.md b/app/vlogsgenerator/README.md index d0a1a821e..1e4670a4c 100644 --- a/app/vlogsgenerator/README.md +++ b/app/vlogsgenerator/README.md @@ -50,7 +50,8 @@ Below is an example output: "u64_0": "4810489083243239145", "float_0": "1.868", "ip_0": "250.34.75.125", - "timestamp_0": "1799-03-16T01:34:18.311Z" + "timestamp_0": "1799-03-16T01:34:18.311Z", + "json_0": "{\"foo\":\"bar_3\",\"baz\":{\"a\":[\"x\",\"y\"]},\"f3\":NaN,\"f4\":32}" } { "_time": "2024-05-08T14:34:00.854Z", @@ -70,7 +71,8 @@ Below is an example output: "u64_0": "6593354256620219850", "float_0": "1.085", "ip_0": "253.151.88.158", - "timestamp_0": "2042-10-05T16:42:57.082Z" + "timestamp_0": "2042-10-05T16:42:57.082Z", + "json_0": "{\"foo\":\"bar_5\",\"baz\":{\"a\":[\"x\",\"y\"]},\"f3\":NaN,\"f4\":27}" } ``` diff --git a/app/vlogsgenerator/main.go b/app/vlogsgenerator/main.go index 67f5ffca2..3fb19ffab 100644 --- a/app/vlogsgenerator/main.go +++ b/app/vlogsgenerator/main.go @@ -51,6 +51,8 @@ var ( "see https://docs.victoriametrics.com/VictoriaLogs/keyConcepts.html#data-model") timestampFieldsPerLog = flag.Int("timestampFieldsPerLog", 1, "The number of fields with ISO8601 timestamps per each log entry; "+ "see https://docs.victoriametrics.com/VictoriaLogs/keyConcepts.html#data-model") + jsonFieldsPerLog = flag.Int("jsonFieldsPerLog", 1, "The number of JSON fields to generate per each log entry; "+ + "see https://docs.victoriametrics.com/VictoriaLogs/keyConcepts.html#data-model") statInterval = flag.Duration("statInterval", 10*time.Second, "The interval between publishing the stats") ) @@ -263,6 +265,9 @@ func generateLogsAtTimestamp(bw *bufio.Writer, workerID int, ts int64, firstStre timestamp := toISO8601(int64(rand.Uint64())) fmt.Fprintf(bw, `,"timestamp_%d":"%s"`, j, timestamp) } + for j := 0; j < *jsonFieldsPerLog; j++ { + fmt.Fprintf(bw, `,"json_%d":"{\"foo\":\"bar_%d\",\"baz\":{\"a\":[\"x\",\"y\"]},\"f3\":NaN,\"f4\":%d}"`, j, rand.Intn(10), rand.Intn(100)) + } fmt.Fprintf(bw, "}\n") logEntriesCount.Add(1) diff --git a/lib/logstorage/pipe_unpack_json_test.go b/lib/logstorage/pipe_unpack_json_test.go index 01af44831..fc162b29c 100644 --- a/lib/logstorage/pipe_unpack_json_test.go +++ b/lib/logstorage/pipe_unpack_json_test.go @@ -222,7 +222,7 @@ type testPipeProcessor struct { resultRows [][]Field } -func (pp *testPipeProcessor) writeBlock(workerID uint, br *blockResult) { +func (pp *testPipeProcessor) writeBlock(_ uint, br *blockResult) { cs := br.getColumns() var columnValues [][]string for _, c := range cs {