PromQL 输入插件
此插件通过 HTTP API 使用 PromQL 查询 从 Prometheus 端点收集指标。
引入于: Telegraf v1.37.0 标签: datastore 操作系统支持: all
全局配置选项
插件支持其他全局和插件配置设置,用于修改指标、标签和字段,创建别名以及配置插件顺序等任务。更多详情请参阅 CONFIGURATION.md。
Secret-store 支持
此插件支持来自 secret-stores 的 username、password 和 token 选项的 secrets。有关如何使用它们的更多详细信息,请参阅 secret-store 文档。
配置
# Query prometheus endpoints using PromQL
[[inputs.promql]]
## URL of the prometheus endpoint
url = "https://:9090"
## Basic authentication properties
# username = ""
# password = ""
## Bearer token based authentication
# token = ""
## Timeout for executing queries with zero meaning no timeout
# timeout = "5s"
## HTTP connection settings
# idle_conn_timeout = "0s"
# max_idle_conn = 0
# max_idle_conn_per_host = 0
# response_timeout = "0s"
## Optional proxy settings
# use_system_proxy = false
# http_proxy_url = ""
## Optional TLS settings
## Set to true/false to enforce TLS being enabled/disabled. If not set,
## enable TLS only if any of the other options are specified.
# tls_enable =
## Trusted root certificates for server
# tls_ca = "/path/to/cafile"
## Used for TLS client certificate authentication
# tls_cert = "/path/to/certfile"
## Used for TLS client certificate authentication
# tls_key = "/path/to/keyfile"
## Password for the key file if it is encrypted
# tls_key_pwd = ""
## Send the specified TLS server name via SNI
# tls_server_name = "kubernetes.example.com"
## Minimal TLS version to accept by the client
# tls_min_version = "TLS12"
## List of ciphers to accept, by default all secure ciphers will be accepted
## See https://pkg.go.dev/crypto/tls#pkg-constants for supported values.
## Use "all", "secure" and "insecure" to add all support ciphers, secure
## suites or insecure suites respectively.
# tls_cipher_suites = ["secure"]
## Renegotiation method, "never", "once" or "freely"
# tls_renegotiation_method = "never"
## Use TLS but skip chain & host verification
# insecure_skip_verify = false
## Instant queries, multiple instances are allowed
# [[inputs.promql.instant]]
# ## Fallback name of the resulting metrics to use as metric name in case
# ## the __name__ property of the query results is empty.
# # name = "promql"
#
# ## Query to execute
# query = 'prometheus_http_requests_total'
#
# ## Limit for the number of results returned by the server with zero
# ## meaning no limit
# # limit = 0
## Range queries, multiple instances are allowed
# [[inputs.promql.range]]
# ## Fallback name of the resulting metrics to use as metric name in case
# ## the __name__ property of the query results is empty.
# # name = "promql"
#
# ## Query to execute
# query = 'prometheus_http_requests_total{job="prometheus"}'
#
# ## Range parameters relative to the gathering time with positive values
# ## refer to BEFORE and negative to AFTER the gathering time
# start = "5m"
# # end = "0s"
# step = "1m"
#
# ## Limit for the number of results returned by the server with zero
# ## meaning no limit
# # limit = 0您可以使用无身份验证或基本身份验证或基于 Bearer token 的身份验证。同时启用基本身份验证和基于 Bearer token 的身份验证将导致失败。
Metrics
此输入插件收集的指标将取决于指定的查询。但是,结果指标将具有以下结构。
标量和字符串结果
标量或字符串结果将生成单个指标,其名称来自 Prometheus __name__ 标签的值。其他标签将保留为 tags。生成的指标使用 Prometheus 时间戳,并将值存储在 value 字段中。
向量和矩阵结果
向量结果将为向量的每个元素生成一个或多个指标,指标名称来自 Prometheus __name__ 标签的值。其他标签将保留为 tags。所有指标都将使用 Prometheus 时间戳。
非直方图结果的值将存储在 value 字段中。直方图结果将包含多个字段,字段名称为 bin 的上限,值为 bin 的计数。此外,指标还将包含 count 和 sum 字段。
示例输出
例如,对 prometheus_http_requests_total{job="prometheus", handler="/api/v1/query"} 进行范围查询,从 5 分钟前开始,步长为 1 分钟,将返回
prometheus_http_requests_total,app=prometheus,code=200,handler=/api/v1/query,instance=localhost:9090,job=prometheus value=28 1758806201000000000
prometheus_http_requests_total,app=prometheus,code=200,handler=/api/v1/query,instance=localhost:9090,job=prometheus value=28 1758806261000000000
prometheus_http_requests_total,app=prometheus,code=200,handler=/api/v1/query,instance=localhost:9090,job=prometheus value=28 1758806321000000000
prometheus_http_requests_total,app=prometheus,code=200,handler=/api/v1/query,instance=localhost:9090,job=prometheus value=28 1758806381000000000
prometheus_http_requests_total,app=prometheus,code=200,handler=/api/v1/query,instance=localhost:9090,job=prometheus value=28 1758806441000000000
prometheus_http_requests_total,app=prometheus,code=200,handler=/api/v1/query,instance=localhost:9090,job=prometheus value=28 1758806501000000000此页面是否有帮助?
感谢您的反馈!
支持和反馈
感谢您成为我们社区的一员!我们欢迎并鼓励您对 Telegraf 和本文档提出反馈和 bug 报告。要获取支持,请使用以下资源
具有年度合同或支持合同的客户可以 联系 InfluxData 支持。