Created
May 10, 2023 14:13
-
-
Save strongant/29bca09c70464aa188fb1b87e8cd112a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 指定Prometheus的Remote Write API URL | |
url="http://prometheus-server:9090/api/v1/write" | |
# 指定并发请求数量 | |
concurrent_requests=10 | |
# 指定每个请求发送的指标数量 | |
metrics_per_request=1000 | |
# 构造写入请求的数据 | |
payload="" | |
for i in $(seq 1 $metrics_per_request); do | |
# 生成随机的指标值 | |
metric_name="my_metric_$i" | |
value=$((RANDOM % 100)) | |
# 构造写入请求 | |
payload="$payload$metric_name $value $(date +%s)\n" | |
done | |
# 使用ab工具发起并发请求,并统计响应时间和吞吐量 | |
ab -n $concurrent_requests -c $concurrent_requests -T 'text/plain' -p <(echo -e "$payload") $url | grep -E "(Time taken|Requests per second)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment