Skip to content

Commit 9d9707c

Browse files
committed
Fixed scripts
1 parent 3a5cfed commit 9d9707c

File tree

7 files changed

+163
-33
lines changed

7 files changed

+163
-33
lines changed

ydb/tests/tools/fqrun/flame_graph.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ fi
99

1010
SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
1111

12-
$SCRIPT_DIR/../kqprun/flame_graph.sh ${1:-'30'} ${2:-''} fqrun
12+
$SCRIPT_DIR/../kqprun/scripts/flame_graph.sh ${1:-'30'} ${2:-''} fqrun

ydb/tests/tools/kqprun/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ For profiling memory allocations build kqprun with ya make flag `-D PROFILE_MEMO
88

99
* `flame_graph.sh` - script for collecting flame graphs in svg format, usage:
1010
```(bash)
11-
./flame_graph.sh [graph collection time in seconds] [use sudo]
11+
./scripts/flame_graph.sh [graph collection time in seconds] [use sudo]
12+
```
13+
14+
* `start_prometheus.sh` - script for starting prometheus web UI, can be used for counters visualisation (kqprun should be runned with flag `-M <monitoring port>`), usage:
15+
```(bash)
16+
./scripts/start_prometheus.sh <monitoring port> <web UI port> [config path]
17+
```
18+
19+
* `start_connector.sh` - script for starting local FQ connector, usage:
20+
```(bash)
21+
./scripts/start_connector.sh <connector port>
1222
```
1323
1424
## Examples
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
global:
2+
scrape_interval: 5s
3+
evaluation_interval: 5s
4+
5+
scrape_configs:
6+
- job_name: "ydb_dynamic"
7+
metrics_path: "/counters/counters=ydb/name_label=name/prometheus"
8+
static_configs:
9+
- targets: ["localhost:${TARGET_PORT}"]
10+
labels:
11+
container: ydb-dynamic
12+
metric_relabel_configs:
13+
- source_labels: ["__name__"]
14+
target_label: "__name__"
15+
replacement: "ydb_$1"
16+
- job_name: "utils_dynamic"
17+
metrics_path: "/counters/counters=utils/prometheus"
18+
static_configs:
19+
- targets: ["localhost:${TARGET_PORT}"]
20+
labels:
21+
container: ydb-dynamic
22+
metric_relabel_configs:
23+
- source_labels: ["__name__"]
24+
target_label: "__name__"
25+
replacement: "utils_$1"
26+
- job_name: "kqp_dynamic"
27+
metrics_path: "/counters/counters=kqp/prometheus"
28+
static_configs:
29+
- targets: ["localhost:${TARGET_PORT}"]
30+
labels:
31+
container: ydb-dynamic
32+
metric_relabel_configs:
33+
- source_labels: ["__name__"]
34+
target_label: "__name__"
35+
replacement: "kqp_$1"
36+
- job_name: "tablets_dynamic"
37+
metrics_path: "/counters/counters=tablets/prometheus"
38+
static_configs:
39+
- targets: ["localhost:${TARGET_PORT}"]
40+
labels:
41+
container: ydb-dynamic
42+
metric_relabel_configs:
43+
- source_labels: ["__name__"]
44+
target_label: "__name__"
45+
replacement: "tablets_$1"
46+
- job_name: "proxy_dynamic"
47+
metrics_path: "/counters/counters=proxy/prometheus"
48+
static_configs:
49+
- targets: ["localhost:${TARGET_PORT}"]
50+
labels:
51+
container: ydb-dynamic
52+
metric_relabel_configs:
53+
- source_labels: ["__name__"]
54+
target_label: "__name__"
55+
replacement: "proxy_$1"
56+
- job_name: "dsproxynode_dynamic"
57+
metrics_path: "/counters/counters=dsproxynode/prometheus"
58+
static_configs:
59+
- targets: ["localhost:${TARGET_PORT}"]
60+
labels:
61+
container: ydb-dynamic
62+
metric_relabel_configs:
63+
- source_labels: ["__name__"]
64+
target_label: "__name__"
65+
replacement: "dsproxynode_$1"
66+
- job_name: "ic_dynamic"
67+
metrics_path: "/counters/counters=interconnect/prometheus"
68+
static_configs:
69+
- targets: ["localhost:${TARGET_PORT}"]
70+
labels:
71+
container: ydb-dynamic
72+
metric_relabel_configs:
73+
- source_labels: ["__name__"]
74+
target_label: "__name__"
75+
replacement: "interconnect_$1"

ydb/tests/tools/kqprun/flame_graph.sh

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
set -eux
4+
5+
if [ $# -gt 3 ]; then
6+
echo "Too many arguments"
7+
exit -1
8+
fi
9+
10+
SUDO=""
11+
12+
if [ ${2:-''} ]; then
13+
SUDO="sudo"
14+
fi
15+
16+
SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
17+
18+
function cleanup {
19+
$SUDO rm $SCRIPT_DIR/profdata
20+
rm $SCRIPT_DIR/profdata.txt
21+
}
22+
trap cleanup EXIT
23+
24+
TARGER_PID=$(pgrep -u $USER ${3:-'kqprun'})
25+
26+
$SUDO perf record -F 50 --call-graph dwarf -g --proc-map-timeout=10000 --pid $TARGER_PID -v -o $SCRIPT_DIR/profdata -- sleep ${1:-'30'}
27+
$SUDO perf script -i $SCRIPT_DIR/profdata > $SCRIPT_DIR/profdata.txt
28+
29+
flame_graph_tool="$SCRIPT_DIR/../../../../../contrib/tools/flame-graph/"
30+
31+
${flame_graph_tool}/stackcollapse-perf.pl $SCRIPT_DIR/profdata.txt | ${flame_graph_tool}/flamegraph.pl > ./profdata.svg
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -eux
4+
5+
if [ $# -le 0 ]; then
6+
echo "Please provide connector port (value of Generic::Connector::Endpoint::Port in config)"
7+
exit -1
8+
fi
9+
10+
if [ $# -gt 2 ]; then
11+
echo "Too many arguments"
12+
exit -1
13+
fi
14+
15+
docker pull ghcr.io/ydb-platform/fq-connector-go:latest
16+
docker run --rm --name=fq-connector-go-$1 --network host ghcr.io/ydb-platform/fq-connector-go:latest --connector-port=$1 --metrics-port=$(($1 + 1)) --pprof-port=$(($1 + 2))
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
set -eux
4+
5+
if [ $# -le 0 ]; then
6+
echo "Please provide monitoring port to listen (value of -M argument)"
7+
exit -1
8+
fi
9+
10+
if [ $# -le 1 ]; then
11+
echo "Please provide prometheus web ui port"
12+
exit -1
13+
fi
14+
15+
if [ $# -gt 3 ]; then
16+
echo "Too many arguments"
17+
exit -1
18+
fi
19+
20+
SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
21+
22+
function cleanup {
23+
rm $SCRIPT_DIR/prometheus_config.yaml
24+
}
25+
trap cleanup EXIT
26+
27+
sed "s/\${TARGET_PORT}/$1/g" "${3:-$SCRIPT_DIR/../configuration/prometheus_config.yaml}" > $SCRIPT_DIR/prometheus_config.yaml
28+
29+
docker run --rm --name=prometheus-$1-$2 --network host -v $SCRIPT_DIR/prometheus_config.yaml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml --web.listen-address=:$2

0 commit comments

Comments
 (0)