当前位置:网站首页>Prometheus 运维工具 Promtool (四)TSDB 功能
Prometheus 运维工具 Promtool (四)TSDB 功能
2022-07-28 09:56:00 【InfoQ】
写性能测试
[[email protected] ~]# ./promtool tsdb bench write --help
usage: promtool tsdb bench write [<flags>] [<file>]
Run a write performance benchmark.
Flags:
-h, --help Show context-sensitive help (also try --help-long and --help-man).
--version Show application version.
--enable-feature= ... Comma separated feature names to enable (only PromQL related). See
https://prometheus.io/docs/prometheus/latest/feature_flags/ for the options and more
details.
--out="benchout" Set the output path.
--metrics=10000 Number of metrics to read.
--scrapes=3000 Number of scrapes to simulate.
Args:
[<file>] Input file with samples data, default is (../../tsdb/testdata/20kseries.json).
wget https://raw.githubusercontent.com/prometheus/prometheus/main/tsdb/testdata/20kseries.json
[[email protected] ~]# ./promtool tsdb bench write --metrics=10000 --scrapes=3000 ./20kseries.json
level=info ts=2022-07-27T13:21:25.546626055Z caller=head.go:493 msg="Replaying on-disk memory mappable chunks if any"
level=info ts=2022-07-27T13:21:25.546734166Z caller=head.go:536 msg="On-disk memory mappable chunks replay completed" duration=11.815µs
level=info ts=2022-07-27T13:21:25.546766084Z caller=head.go:542 msg="Replaying WAL, this may take a while"
level=info ts=2022-07-27T13:21:25.547101874Z caller=head.go:613 msg="WAL segment loaded" segment=0 maxSegment=0
level=info ts=2022-07-27T13:21:25.547131383Z caller=head.go:619 msg="WAL replay completed" checkpoint_replay_duration=38.26µs wal_replay_duration=315.491µs total_replay_duration=409.177µs
level=info ts=2022-07-27T13:21:25.549132675Z caller=db.go:1467 msg="Compactions disabled"
>> start stage=readData
>> completed stage=readData duration=145.973395ms
>> start stage=ingestScrapes
ingestion completed
>> completed stage=ingestScrapes duration=3.628682202s
> total samples: 30000000
> samples/sec: 8.267435217071414e+06
>> start stage=stopStorage
>> completed stage=stopStorage duration=1.522008202s
TSDB 分析
[[email protected] ~]# ./promtool tsdb analyze --help
usage: promtool tsdb analyze [<flags>] [<db path>] [<block id>]
Analyze churn, label pair cardinality and compaction efficiency.
Flags:
-h, --help Show context-sensitive help (also try --help-long and --help-man).
--version Show application version.
--enable-feature= ... Comma separated feature names to enable (only PromQL related). See
https://prometheus.io/docs/prometheus/latest/feature_flags/ for the options and more
details.
--limit=20 How many items to show in each list.
--extended Run extended analysis.
Args:
[<db path>] Database path (default is data/).
[<block id>] Block to analyze (default is the last block).
[[email protected] ~]# ./promtool tsdb analyze ./prometheus/data/
Block ID: 01G8ZXKAHRGF7BV0FTQYZ18FH5
Duration: 59m55.713s
Series: 606677
Label names: 26
Postings (unique label pairs): 13190
Postings entries (total label pairs): 7819776
Label pairs most involved in churning:
329487 workload_user_cattle_io_workloadselector=deployment-appops-pushgateway-flink
329487 pod_template_hash=6d695f75cf
329487 kubernetes_namespace=appops
62797 kubernetes_pod_name=pushgateway-flink-6d695f75cf-2xhfh
58524 kubernetes_pod_name=pushgateway-flink-6d695f75cf-8fq58
52495 kubernetes_pod_name=pushgateway-flink-6d695f75cf-d76n7
51544 kubernetes_pod_name=pushgateway-flink-6d695f75cf-z4bjb
22074 kubernetes_pod_name=pushgateway-flink-6d695f75cf-9jgdk
21516 kubernetes_pod_name=pushgateway-flink-6d695f75cf-96hpq
20426 kubernetes_pod_name=pushgateway-flink-6d695f75cf-9twr2
20047 kubernetes_pod_name=pushgateway-flink-6d695f75cf-ngzwz
11819 kubernetes_pod_name=pushgateway-flink-6d695f75cf-8hv9z
8242 kubernetes_pod_name=pushgateway-flink-6d695f75cf-pddrc
3783 __name__=flink_taskmanager_Status_JVM_Memory_Heap_Used
3783 __name__=flink_taskmanager_job_task_checkpointAlignmentTime
3783 __name__=flink_taskmanager_Status_JVM_ClassLoader_ClassesLoaded
3783 __name__=flink_taskmanager_Status_JVM_Threads_Count
3783 __name__=flink_taskmanager_Status_Shuffle_Netty_UsedMemorySegments
3783 __name__=flink_taskmanager_Status_Flink_Memory_Managed_Used
3783 __name__=flink_taskmanager_job_task_Shuffle_Netty_Output_Buffers_outputQueueLength
Label names most involved in churning:
329487 kubernetes_namespace
329487 kubernetes_pod_name
329487 workload_user_cattle_io_workloadselector
329487 __name__
329487 pod_template_hash
329487 job
314352 instance
314050 host
314050 tm_id
185403 task_attempt_num
185403 task_name
185403 subtask_index
185403 job_name
185403 task_id
185403 task_attempt_id
185403 job_id
15134 operator_name
15134 operator_id
66 method
55 quantile
Most common label pairs:
606565 kubernetes_namespace=appops
606565 workload_user_cattle_io_workloadselector=deployment-pushgateway-flink
606565 pod_template_hash=6d695f75cf
87063 kubernetes_pod_name=pushgateway-flink-6d695f75cf-ngzwz
87063 kubernetes_pod_name=pushgateway-flink-6d695f75cf-9jgdk
87062 kubernetes_pod_name=pushgateway-flink-6d695f75cf-96hpq
87062 kubernetes_pod_name=pushgateway-flink-6d695f75cf-9twr2
67920 kubernetes_pod_name=pushgateway-flink-6d695f75cf-2xhfh
62700 kubernetes_pod_name=pushgateway-flink-6d695f75cf-8fq58
54174 kubernetes_pod_name=pushgateway-flink-6d695f75cf-d76n7
53304 kubernetes_pod_name=pushgateway-flink-6d695f75cf-z4bjb
11892 kubernetes_pod_name=pushgateway-flink-6d695f75cf-8hv9z
8325 kubernetes_pod_name=pushgateway-flink-6d695f75cf-pddrc
6965 __name__=flink_taskmanager_job_task_Shuffle_Netty_Input_Buffers_inputFloatingBuffersUsage
6965 __name__=flink_taskmanager_job_task_numBuffersOut
6965 __name__=flink_taskmanager_job_task_isBackPressured
6965 __name__=flink_taskmanager_Status_JVM_ClassLoader_ClassesLoaded
6965 __name__=flink_taskmanager_job_task_numBuffersOutPerSecond
6965 __name__=push_time_seconds
6965 __name__=flink_taskmanager_job_task_buffers_inPoolUsage
Label names with highest cumulative label value length:
50890 task_name
42890 tm_id
34890 operator_id
34890 task_id
34890 task_attempt_id
34890 job_id
21890 job_name
18928 job
18890 operator_name
13890 host
5972 __name__
3890 task_attempt_num
3890 subtask_index
3100 instance
340 kubernetes_pod_name
40 revision
38 handler
35 workload_user_cattle_io_workloadselector
19 quantile
16 method
Highest cardinality labels:
1012 instance
1002 job
1000 operator_id
1000 task_id
1000 task_attempt_num
1000 host
1000 task_name
1000 tm_id
1000 job_id
1000 job_name
1000 task_attempt_id
1000 subtask_index
1000 operator_name
137 __name__
10 kubernetes_pod_name
7 handler
7 quantile
4 method
3 code
2 version
Highest cardinality metric names:
6965 my_batch_job_duration_seconds
6965 flink_taskmanager_Status_Flink_Memory_Managed_Used
6965 flink_taskmanager_Status_JVM_CPU_Load
6965 flink_taskmanager_Status_JVM_CPU_Time
6965 flink_taskmanager_Status_JVM_ClassLoader_ClassesLoaded
6965 flink_taskmanager_Status_JVM_ClassLoader_ClassesUnloaded
6965 flink_taskmanager_Status_JVM_GarbageCollector_PS_MarkSweep_Count
6965 flink_taskmanager_Status_JVM_GarbageCollector_PS_MarkSweep_Time
6965 flink_taskmanager_Status_JVM_GarbageCollector_PS_Scavenge_Count
6965 flink_taskmanager_Status_JVM_GarbageCollector_PS_Scavenge_Time
6965 flink_taskmanager_Status_JVM_Memory_Direct_Count
6965 flink_taskmanager_Status_JVM_Memory_Direct_MemoryUsed
6965 flink_taskmanager_Status_JVM_Memory_Direct_TotalCapacity
6965 flink_taskmanager_Status_JVM_Memory_Heap_Committed
6965 flink_taskmanager_Status_JVM_Memory_Heap_Max
6965 flink_taskmanager_Status_JVM_Memory_Heap_Used
6965 flink_taskmanager_Status_JVM_Memory_Mapped_Count
6965 flink_taskmanager_Status_JVM_Memory_Mapped_MemoryUsed
6965 flink_taskmanager_Status_JVM_Memory_Mapped_TotalCapacity
6965 flink_taskmanager_Status_JVM_Memory_Metaspace_Committed
列出 TSDB 数据块
[[email protected] ~]# ./promtool tsdb list --help
usage: promtool tsdb list [<flags>] [<db path>]
List tsdb blocks.
Flags:
-h, --help Show context-sensitive help (also try --help-long and --help-man).
--version Show application version.
--enable-feature= ... Comma separated feature names to enable (only PromQL related). See
https://prometheus.io/docs/prometheus/latest/feature_flags/ for the options and more
details.
-r, --human-readable Print human readable values.
Args:
[<db path>] Database path (default is data/).
-r[[email protected] ~]# ./promtool tsdb list -r ./prometheus-pushgateway/data/
BLOCK ULID MIN TIME MAX TIME DURATION NUM SAMPLES NUM CHUNKS NUM SERIES SIZE
01G8XB6J42S6FTDMAPYV30CTR3 2022-07-26 12:00:03 +0000 UTC 2022-07-26 13:00:00 +0000 UTC 59m56.018s 78421200 435860 435412 92MiB217KiB450B
01G8XEMDR374M816NZ2NMNS5AQ 2022-07-26 13:00:03 +0000 UTC 2022-07-26 14:00:00 +0000 UTC 59m56.018s 78421200 435860 435412 92MiB217KiB825B
01G8XJ29C2JVV8PEQFR748C1QR 2022-07-26 14:00:03 +0000 UTC 2022-07-26 15:00:00 +0000 UTC 59m56.018s 78421200 435860 435412 94MiB125KiB158B
01G8XNG502K46CF1960R1FYEAA 2022-07-26 15:00:03 +0000 UTC 2022-07-26 16:00:00 +0000 UTC 59m56.018s 78421200 435860 435412 92MiB388KiB448B
01G8XRY0M2CV8J323VWM393JTZ 2022-07-26 16:00:03 +0000 UTC 2022-07-26 17:00:00 +0000 UTC 59m56.018s 78421200 435860 435412 93MiB978KiB543B
01G8XWBW82NGHBPP6QPZMJ6XAM 2022-07-26 17:00:03 +0000 UTC 2022-07-26 18:00:00 +0000 UTC 59m56.018s 78421200 435860 435412 93MiB979KiB590B
01G8XZSQW2WY7SG70Z40CW2CZV 2022-07-26 18:00:03 +0000 UTC 2022-07-26 19:00:00 +0000 UTC 59m56.018s 78421200 435860 435412 94MiB719KiB630B
Dump
[[email protected] ~]# ./promtool tsdb dump --help
usage: promtool tsdb dump [<flags>] [<db path>]
Dump samples from a TSDB.
Flags:
-h, --help Show context-sensitive help (also try --help-long and --help-man).
--version Show application version.
--enable-feature= ... Comma separated feature names to enable (only PromQL related). See
https://prometheus.io/docs/prometheus/latest/feature_flags/ for the options and more
details.
--min-time=-9223372036854775808
Minimum timestamp to dump.
--max-time=9223372036854775807
Maximum timestamp to dump.
Args:
[<db path>] Database path (default is data/).
[[email protected] ~]# ./promtool tsdb dump --min-time=1658927217000 --max-time=1658930818000 ../prometheus-pushgateway/data/
从 OpenMetric 导入数据块
[[email protected] ~]# ./promtool tsdb create-blocks-from openmetrics --help
usage: promtool tsdb create-blocks-from openmetrics <input file> [<output directory>]
Import samples from OpenMetrics input and produce TSDB blocks. Please refer to the storage docs for more details.
Flags:
-h, --help Show context-sensitive help (also try --help-long and --help-man).
--version Show application version.
--enable-feature= ... Comma separated feature names to enable (only PromQL related). See
https://prometheus.io/docs/prometheus/latest/feature_flags/ for the options and more
details.
-r, --human-readable Print human readable values.
-q, --quiet Do not print created blocks.
Args:
<input file> OpenMetrics file to read samples from.
[<output directory>] Output directory for generated blocks.
为新的记录规则创建数据块
[[email protected] ~]# ./promtool tsdb create-blocks-from rules --help
usage: promtool tsdb create-blocks-from rules --start=START [<flags>] <rule-files>...
Create blocks of data for new recording rules.
Flags:
-h, --help Show context-sensitive help (also try --help-long and --help-man).
--version Show application version.
--enable-feature= ... Comma separated feature names to enable (only PromQL related). See
https://prometheus.io/docs/prometheus/latest/feature_flags/ for the options and
more details.
-r, --human-readable Print human readable values.
-q, --quiet Do not print created blocks.
--url=http://localhost:9090
The URL for the Prometheus API with the data where the rule will be backfilled
from.
--start=START The time to start backfilling the new rule from. Must be a RFC3339 formatted date
or Unix timestamp. Required.
--end=END If an end time is provided, all recording rules in the rule files provided will
be backfilled to the end time. Default will backfill up to 3 hours ago. Must be a
RFC3339 formatted date or Unix timestamp.
--output-dir="data/" Output directory for generated blocks.
--eval-interval=60s How frequently to evaluate rules when backfilling if a value is not set in the
recording rule files.
Args:
<rule-files> A list of one or more files containing recording rules to be backfilled. All recording rules
listed in the files will be backfilled. Alerting rules are not evaluated.
[[email protected] ~]# ./promtool tsdb create-blocks-from rules \
--start 1617079873 \
--end 1617097873 \
--url http://mypromserver.com:9090 \
rules.yaml rules2.yaml
promtool tsdb create-blocks-from rules --storage.tsdb.allow-overlapping-blocks- 如果多次执行生成历史数据 ,且开始时间和结束时间重叠,则每次运行记录规则生成历史数据时都会创建包含相同数据的块。
- 记录规则文件中的所有规则都将被评估。
- 如果在记录规则文件中设置了时间间隔,该时间间隔优先于 tsdb create-blocks-from rules 命令中的
--eval-interval参数。
- 如果告警规则在记录规则文件中,那么告警规则会被忽略。
- 同一组中的规则无法看到之前规则的结果。这意味着不支持引用正在生成历史数据的其他规则的规则。一种解决方法是多次生成历史数据并首先创建依赖数据(并将依赖数据移动到 Prometheus 服务器数据目录,以便从 Prometheus API 访问它)。
总结
边栏推荐
- ASP. Net core 6 framework unveiling example demonstration [29]: building a file server
- 选择供应商服务系统,是大健康产业企业迈向数字化转型的第一步
- Being on duty less than 8 hours a day and being dismissed? Tencent's former employees recovered 13million overtime pay, etc., and the court won a compensation of 90000 in the final judgment
- 工业品MRO采购网站有哪些优势?一文带你读懂
- [OpenHarmony] [RK2206] 构建OpenHarmony编译器 (二)
- 广州地铁14号线新市墟站开建,白云区居民即将开启双线换乘模式!
- 深度学习必懂的 13 种概率分布
- 10分钟快速入门EVS【玩转华为云】
- Arthas tutorial
- Read Plato farm's eplato and the reason for its high premium
猜你喜欢

并查集

TCP Basics

【学习笔记】border与period

B2B2C系统亮点是什么?如何助力珠宝首饰企业打造全渠道多商户商城管理体系

什么样的知识付费系统功能,更有利于平台与讲师发展?

In the era of home health diagnosis, Senzo creates enhanced lateral flow test products

二分、三分、01分数规划 【第I弹】

Seektiger eco pass STI new progress, log in to ZB on April 14

What are the highlights of B2B2C system? How to help jewelry enterprises build an omni channel multi merchant mall management system

2022-uni-app解析token标准的方式-使用jsrsasign-爬坑过了
随机推荐
uni-app进阶之生命周期
leetcode——旋转数组的最小数字
ADVANCE.AI出海指南助力企业出海印尼,掌握东南亚市场半边天
Have you ever seen this kind of dynamic programming -- the stock problem of state machine dynamic programming (Part 2)
二维前缀和
JS promotion: the underlying principle of flat tiling
头文件库文件
博弈论 1.Introduction(组合游戏基本概念、对抗搜索、Bash游戏、Nim游戏)
j s的数组方法,循环
Being on duty less than 8 hours a day and being dismissed? Tencent's former employees recovered 13million overtime pay, etc., and the court won a compensation of 90000 in the final judgment
二分、三分、01分数规划【第III弹】
It can traverse all files and subfolders under a folder
Why should I take the first-class constructor examination? How high is the gold content of the first-class Constructor Certificate?
关于软考高级要不要报班学习
双指针技巧
高温持续,公交企业开展安全专项培训
Software testing and quality learning notes 2 - black box testing
Install lamp under deepin
New features of ES6
Read Plato farm's eplato and the reason for its high premium