首页 > 其他分享 >Prometheus监控之检查工具Promtool简介

Prometheus监控之检查工具Promtool简介

时间:2022-12-24 14:01:44浏览次数:45  
标签:... help -- 简介 metrics Prometheus debug query Promtool

一、简介

Prometheus提供了一个非常有用的支持命令行工具promtool。
这个小型的Golang二进制文件可用于快速执行包括查询指标、debug 服务、对数据库进行检查等等故障排除操作,并且包含了许多有用的子命令。

prometheus安装包解压,promtool和prometheus同级目录

二、参数

./promtool --help
usage: promtool [<flags>] <command> [<args> ...]
Tooling for the Prometheus monitoring system.
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). Seehttps://prometheus.io
/docs/prometheus/latest/feature_flags/ for the options and more details.
Commands:
help [<command>...]
Show help.
check service-discovery [<flags>] <config-file> <job>
Perform service discovery for the given job name and report the results,
including relabeling.
check config [<flags>] <config-files>...
Check if the config files are valid or not.
check web-config <web-config-files>...
Check if the web config files are valid or not.
check rules [<flags>] <rule-files>...
Check if the rule files are valid or not.
check metrics
Pass Prometheus metrics over stdin to lint them for consistency and correctness.
examples:
$ cat metrics.prom | promtool check metrics
$ curl -s http://localhost:9090/metrics | promtool check metrics

query instant [<flags>] <server> <expr>
Run instant query.
query range [<flags>] <server> <expr>
Run range query.
query series --match=MATCH [<flags>] <server>
Run series query.
query labels [<flags>] <server> <name>
Run labels query.

debug pprof <server>
Fetch profiling debug information.
debug metrics <server>
Fetch metrics debug information.
debug all <server>
Fetch all debug information.
test rules <test-rule-file>...
Unit tests for rules.

tsdb bench write [<flags>] [<file>]
Run a write performance benchmark.
tsdb analyze [<flags>] [<db path>] [<block id>]
Analyze churn, label pair cardinality and compaction efficiency.
tsdb list [<flags>] [<db path>]
List tsdb blocks.
tsdb dump [<flags>] [<db path>]
Dump samples from a TSDB.
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.
tsdb create-blocks-from rules --start=START [<flags>] <rule-files>...
Create blocks of data for new recording rules.

三、基本信息

这个工具有一些基本信息可以使用,一些参数基本是通用的。
首先 使用 --help 可以看到帮助信息,也可以使用 --help-long 参数看加长版的帮助信息
使用 --version 可以看到工具版本信息、构建的分支和 commit ID、构建时间、Go 的版本、运行平台这些信息。
./promtool --version
promtool, version 2.37.0 (branch: HEAD, revision: b41e0750abf5cc18d8233161560731de05199330)
build user: root@0ebb6827e27f
build date: 20220714-15:13:18
go version: go1.18.4
platform: linux/amd64

标签:...,help,--,简介,metrics,Prometheus,debug,query,Promtool
From: https://blog.51cto.com/u_13236892/5967133

相关文章