From 790f4db6f093b1c69cf886ccc3de3bf8138fa45c Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Fri, 10 May 2024 23:30:18 +0200 Subject: [PATCH] wip --- app/vlogsgenerator/README.md | 4 ++++ app/vlogsgenerator/main.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/app/vlogsgenerator/README.md b/app/vlogsgenerator/README.md index a7fca95f3..d0a1a821e 100644 --- a/app/vlogsgenerator/README.md +++ b/app/vlogsgenerator/README.md @@ -37,6 +37,7 @@ Below is an example output: "_msg": "message for the stream 8 and worker 0; ip=185.69.136.129; uuid=b4fe8f1a-c93c-dea3-ba11-5b9f0509291e; u64=8996587920687045253", "host": "host_8", "worker_id": "0", + "run_id": "f9b3deee-e6b6-7f56-5deb-1586e4e81725", "const_0": "some value 0 8", "const_1": "some value 1 8", "const_2": "some value 2 8", @@ -56,6 +57,7 @@ Below is an example output: "_msg": "message for the stream 9 and worker 0; ip=164.244.254.194; uuid=7e8373b1-ce0d-1ce7-8e96-4bcab8955598; u64=13949903463741076522", "host": "host_9", "worker_id": "0", + "run_id": "f9b3deee-e6b6-7f56-5deb-1586e4e81725", "const_0": "some value 0 9", "const_1": "some value 1 9", "const_2": "some value 2 9", @@ -72,6 +74,8 @@ Below is an example output: } ``` +The `run_id` field uniquely identifies every `vlogsgenerator` invocation. + ### How to write logs to VictoriaLogs? The generated logs can be written directly to VictoriaLogs by passing the address of [`/insert/jsonline` endpoint](https://docs.victoriametrics.com/victorialogs/data-ingestion/#json-stream-api) diff --git a/app/vlogsgenerator/main.go b/app/vlogsgenerator/main.go index 225e59e19..67f5ffca2 100644 --- a/app/vlogsgenerator/main.go +++ b/app/vlogsgenerator/main.go @@ -220,6 +220,8 @@ func generateLogs(bw *bufio.Writer, workerID, activeStreams, totalStreams int) { } } +var runID = toUUID(rand.Uint64(), rand.Uint64()) + func generateLogsAtTimestamp(bw *bufio.Writer, workerID int, ts int64, firstStreamID, activeStreams int) { streamID := firstStreamID timeStr := toRFC3339(ts) @@ -228,6 +230,7 @@ func generateLogsAtTimestamp(bw *bufio.Writer, workerID int, ts int64, firstStre uuid := toUUID(rand.Uint64(), rand.Uint64()) fmt.Fprintf(bw, `{"_time":%q,"_msg":"message for the stream %d and worker %d; ip=%s; uuid=%s; u64=%d","host":"host_%d","worker_id":"%d"`, timeStr, streamID, workerID, ip, uuid, rand.Uint64(), streamID, workerID) + fmt.Fprintf(bw, `,"run_id":"%s"`, runID) for j := 0; j < *constFieldsPerLog; j++ { fmt.Fprintf(bw, `,"const_%d":"some value %d %d"`, j, j, streamID) }