mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-17 08:36:55 +03:00
### Describe Your Changes
Implemented the script that generates graphs using `gnuplot`.
Those graphs show the write speed to the db.
How to use it:
1. From the root run `make tsbs`;
2. The file will be generated automatically
`/tmp/tsbs-load-100000-2025-07-22T00:00:00Z-2025-07-23T00:00:00Z-80s.csv`
4. From the root run `make tsbs-plot-load` and observe the result
5. If you have two files with the `tsbs_load_victoriametrics` output,
just define the second in the
`TSBS_LOAD_RESULT_CSV_FILE_COMPARE=/tmp/tsbs-load-10
0000-2025-07-22T01:00:00Z-2025-07-23T01:00:00Z-80s.csv
`
To plot the measurements from some other benchmark, run
`make tsbs-plot-load TSBS_LOAD_RESULT_CSV_FILE=/path/to/file.csv`
To plot the measurements from two benchmarks, run
`make tsbs-plot-load TSBS_LOAD_RESULT_CSV_FILE=/path/to/file1.csv
TSBS_LOAD_RESULT_CSV_FILE_COMPARE=/path/to/file2.csv`
This command should generate a graph like described in the picture
<img width="638" height="578" alt="Screenshot 2025-07-25 at 15 35 42"
src="https://github.com/user-attachments/assets/900b05ab-0b98-4f7f-8f2c-18d28ad2eab6"
/>
### Checklist
The following checks are **mandatory**:
- [x] My change adheres to [VictoriaMetrics contributing
guidelines](https://docs.victoriametrics.com/victoriametrics/contributing/#pull-request-checklist).
- [x] My change adheres to [VictoriaMetrics development
goals](https://docs.victoriametrics.com/victoriametrics/goals/).
---------
Signed-off-by: Artem Fetishev <rtm@victoriametrics.com>
Co-authored-by: Artem Fetishev <rtm@victoriametrics.com>
Co-authored-by: Artem Fetishev <149964189+rtm0@users.noreply.github.com>
(cherry picked from commit fd23f6bfb3)
56 lines
1.3 KiB
Bash
Executable File
56 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Check the number of arguments
|
|
if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
|
|
echo "Usage: $(basename $0) file1.csv [file2.csv]"
|
|
exit 1
|
|
fi
|
|
|
|
file1="$1"
|
|
file2="$2"
|
|
|
|
# Check if the files exist
|
|
if [ ! -f "$file1" ]; then
|
|
echo "File not found: $file1"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -n "$file2" ] && [ ! -f "$file2" ]; then
|
|
echo "File not found: $file2"
|
|
exit 1
|
|
fi
|
|
|
|
# Temporary file for plot data
|
|
plotdata="/tmp/tsbs_plot.dat"
|
|
|
|
if [ -z "$file2" ]; then
|
|
# === One file ===
|
|
awk -F, '/^Summary:/ {exit} NR > 1 {print $1, $2}' "$file1" > "$plotdata"
|
|
else
|
|
# === Two files ===
|
|
|
|
# Get time and per.metric/s from file1
|
|
awk -F, '/^Summary:/ {exit} NR > 1 {print $1, $2}' "$file1" > /tmp/file1.dat
|
|
# Get per.metric/s from file2
|
|
awk -F, '/^Summary:/ {exit} NR > 1 {print $2}' "$file2" > /tmp/file2.dat
|
|
# Merge by rows: time, val1, val2
|
|
paste /tmp/file1.dat /tmp/file2.dat | awk '{print $1, $2, $3}' > "$plotdata"
|
|
fi
|
|
|
|
# === Build plot dynamically ===
|
|
gnuplot -persist <<-EOF
|
|
set datafile separator " "
|
|
set title "per.metric/s"
|
|
set xlabel "Timestamp"
|
|
set xdata time
|
|
set timefmt "%s"
|
|
set format x "%H:%M:%S"
|
|
set ylabel "per. metric/s"
|
|
set format y "%'.0f"
|
|
set grid
|
|
|
|
plot "$plotdata" using 1:2 with lines title "$(basename "$file1")" \
|
|
$( [[ -n "$file2" ]] && echo ", \\
|
|
\"$plotdata\" using 1:3 with lines title \"$(basename "$file2")\"" )
|
|
EOF
|