配置
Prometheus 透過命令列引數和配置檔案進行配置。命令列引數用於配置不可變的系統引數(例如儲存位置、保留在磁碟和記憶體中的資料量等),而配置檔案則定義了與抓取任務及其例項相關的所有內容,以及要載入哪些規則檔案。
要檢視所有可用的命令列引數,請執行 ./prometheus -h。
Prometheus 可以在執行時重新載入其配置。如果新配置格式不正確,則不會應用更改。透過向 Prometheus 程序傳送 SIGHUP 訊號或向 /-/reload 端點發送 HTTP POST 請求(當啟用了 --web.enable-lifecycle 引數時)可以觸發配置過載。這也會重新載入任何已配置的規則檔案。
配置檔案
要指定載入哪個配置檔案,請使用 --config.file 引數。
該檔案使用 YAML 格式 編寫,由下面描述的方案定義。括號表示引數是可選的。對於非列表引數,其值將設定為指定的預設值。
通用佔位符定義如下
<boolean>: 一個布林值,可取true或false<duration>:匹配正則表示式((([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?|0)的持續時間,例如1d、1h30m、5m、10s<filename>: 當前工作目錄中的有效路徑<float>:一個浮點數<host>:由主機名或 IP 後跟可選埠號組成的有效字串<int>:一個整數值<labelname>:匹配正則表示式[a-zA-Z_][a-zA-Z0-9_]*的字串。源標籤中任何其他不支援的字元都應轉換為下劃線。例如,標籤app.kubernetes.io/name應寫為app_kubernetes_io_name。<labelvalue>:一個 Unicode 字元組成的字串<path>:一個有效的 URL 路徑<scheme>:可以取值為http或https的字串<secret>: 一個普通字串,是秘密資訊,如密碼<string>: 一個普通字串<size>:以位元組為單位的大小,例如512MB。單位是必須的。支援的單位有:B、KB、MB、GB、TB、PB、EB。<tmpl_string>:在使用前會進行模板展開的字串
其他佔位符另有說明。
可以在此處 找到一個有效的示例檔案。
全域性配置指定了在所有其他配置上下文中都有效的引數。它們也用作其他配置部分的預設值。
global:
# How frequently to scrape targets by default.
[ scrape_interval: <duration> | default = 1m ]
# How long until a scrape request times out.
# It cannot be greater than the scrape interval.
[ scrape_timeout: <duration> | default = 10s ]
# The protocols to negotiate during a scrape with the client.
# Supported values (case sensitive): PrometheusProto, OpenMetricsText0.0.1,
# OpenMetricsText1.0.0, PrometheusText0.0.4, PrometheusText1.0.0.
# If left unset both here and in an individual scrape config, the
# negotiation order used in that scrape config depends on the effective
# value of scrape_native_histograms for that scrape config.
# If scrape_native_histograms is false, the order is
# [ OpenMetricsText1.0.0, OpenMetricsText0.0.1, PrometheusText1.0.0, PrometheusText0.0.4 ].
# If scrape_native_histograms is true, the order is
# [ PrometheusProto, OpenMetricsText1.0.0, OpenMetricsText0.0.1, PrometheusText1.0.0, PrometheusText0.0.4 ].
[ scrape_protocols: [<string>, ...] ]
# How frequently to evaluate rules.
[ evaluation_interval: <duration> | default = 1m ]
# Offset the rule evaluation timestamp of this particular group by the
# specified duration into the past to ensure the underlying metrics have
# been received. Metric availability delays are more likely to occur when
# Prometheus is running as a remote write target, but can also occur when
# there's anomalies with scraping.
[ rule_query_offset: <duration> | default = 0s ]
# The labels to add to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
# Environment variable references `${var}` or `$var` are replaced according
# to the values of the current environment variables.
# References to undefined variables are replaced by the empty string.
# The `$` character can be escaped by using `$$`.
external_labels:
[ <labelname>: <labelvalue> ... ]
# File to which PromQL queries are logged.
# Reloading the configuration will reopen the file.
[ query_log_file: <string> ]
# File to which scrape failures are logged.
# Reloading the configuration will reopen the file.
[ scrape_failure_log_file: <string> ]
# An uncompressed response body larger than this many bytes will cause the
# scrape to fail. 0 means no limit. Example: 100MB.
# This is an experimental feature, this behaviour could
# change or be removed in the future.
[ body_size_limit: <size> | default = 0 ]
# Per-scrape limit on the number of scraped samples that will be accepted.
# If more than this number of samples are present after metric relabeling
# the entire scrape will be treated as failed. 0 means no limit.
[ sample_limit: <int> | default = 0 ]
# Limit on the number of labels that will be accepted per sample. If more
# than this number of labels are present on any sample post metric-relabeling,
# the entire scrape will be treated as failed. 0 means no limit.
[ label_limit: <int> | default = 0 ]
# Limit on the length (in bytes) of each individual label name. If any label
# name in a scrape is longer than this number post metric-relabeling, the
# entire scrape will be treated as failed. Note that label names are UTF-8
# encoded, and characters can take up to 4 bytes. 0 means no limit.
[ label_name_length_limit: <int> | default = 0 ]
# Limit on the length (in bytes) of each individual label value. If any label
# value in a scrape is longer than this number post metric-relabeling, the
# entire scrape will be treated as failed. Note that label values are UTF-8
# encoded, and characters can take up to 4 bytes. 0 means no limit.
[ label_value_length_limit: <int> | default = 0 ]
# Limit per scrape config on number of unique targets that will be
# accepted. If more than this number of targets are present after target
# relabeling, Prometheus will mark the targets as failed without scraping them.
# 0 means no limit. This is an experimental feature, this behaviour could
# change in the future.
[ target_limit: <int> | default = 0 ]
# Limit per scrape config on the number of targets dropped by relabeling
# that will be kept in memory. 0 means no limit.
[ keep_dropped_targets: <int> | default = 0 ]
# Specifies the validation scheme for metric and label names. Either blank or
# "utf8" for full UTF-8 support, or "legacy" for letters, numbers, colons,
# and underscores.
[ metric_name_validation_scheme: <string> | default "utf8" ]
# If true, native histograms exposed by a target are recognized during
# scraping and ingested as such. If false, any native parts of histograms
# are ignored and only the classic parts are recognized (possibly as
# a classic histogram with only the +Inf buckets if no explicit classic
# buckets are part of the histogram).
[ scrape_native_histograms: <bool> | default = false ]
# Specifies whether to convert scraped classic histograms into native
# histograms with custom buckets.
[ convert_classic_histograms_to_nhcb: <bool> | default = false ]
# Specifies whether to additionally scrape the classic parts of a histogram,
# even if it is also exposed with native parts or it is converted into a
# native histogram with custom buckets.
[ always_scrape_classic_histograms: <boolean> | default = false ]
# When enabled, Prometheus stores additional time series for each scrape:
# scrape_timeout_seconds, scrape_sample_limit, and scrape_body_size_bytes.
# These metrics help monitor how close targets are to their configured limits.
# This option can be overridden per scrape config.
[ extra_scrape_metrics: <boolean> | default = false ]
# The following explains the various combinations of the last three options
# in various exposition cases.
#
# CASE 1: A histogram is solely exposed as a classic histogram. (Note that
# this also applies if the used scrape protocol (also see the
# scrape_protocols setting) does not support native histograms.) In this
# case, the scrape_native_histograms setting has no effect. If
# convert_classic_histograms_to_nhcb is false, the histogram is ingested as
# a classic histograms. If convert_classic_histograms_to_nhcb is true, the
# histograms is converted to an NHCB. In this case,
# always_scrape_classic_histograms determines whether it is also ingested
# as a classic histograms or not.
#
# CASE 2: A histogram is solely exposed as a native histogram, i.e. it has
# no classic buckets except the optional +Inf bucket but it is marked as a
# native histogram (by some "native parts", at the very least by a no-op
# span). If scrape_native_histograms is false, this case is handled like case
# 1, but the resulting classic histogram or NHCB only has a sole bucket, the
# +Inf bucket. If scrape_native_histograms is true, however, the histogram is
# recognized as a pure native histogram and ingested as such. There will be
# no classic histogram ingested, no matter what
# always_scrape_classic_histograms is set to, and there will be no
# conversion to an NHCB, no matter what convert_classic_histograms_to_nhcb
# is set to.
#
# CASE 3: A histogram is exposed as both a native and a classic histogram,
# i.e. it has "native parts" (at the very least a no-op span) and it has at
# least one classic bucket that is not the +Inf bucket. If
# scrape_native_histograms is false, this case is handled like case 1. The
# native parts are ignored, and there will be either a classic histogram, an
# NHCB, or both. If scrape_native_histograms is true, the histogram is
# ingested as a native histogram. There will be no NHCB, no matter what
# convert_classic_histograms_to_nhcb is set to (it would collide with the
# actual native histogram). However, there will be a classic histogram if (and
# only if) always_scrape_classic_histograms is set to true.
runtime:
# Configure the Go garbage collector GOGC parameter
# See: https://tip.golang.org/doc/gc-guide#GOGC
# Lowering this number increases CPU usage.
[ gogc: <int> | default = 75 ]
# Rule files specifies a list of globs. Rules and alerts are read from
# all matching files.
rule_files:
[ - <filepath_glob> ... ]
# Scrape config files specifies a list of globs. Scrape configs are read from
# all matching files and appended to the list of scrape configs.
scrape_config_files:
[ - <filepath_glob> ... ]
# A list of scrape configurations.
scrape_configs:
[ - <scrape_config> ... ]
# Alerting specifies settings related to the Alertmanager.
alerting:
alert_relabel_configs:
[ - <relabel_config> ... ]
alertmanagers:
[ - <alertmanager_config> ... ]
# Settings related to the remote write feature.
remote_write:
[ - <remote_write> ... ]
# Settings related to the OTLP receiver feature.
# See https://prometheus.golang.com.tw/docs/guides/opentelemetry/ for best practices.
otlp:
# Promote specific list of resource attributes to labels.
# It cannot be configured simultaneously with 'promote_all_resource_attributes: true'.
[ promote_resource_attributes: [<string>, ...] | default = [ ] ]
# Promoting all resource attributes to labels, except for the ones configured with 'ignore_resource_attributes'.
# Be aware that changes in attributes received by the OTLP endpoint may result in time series churn and lead to high memory usage by the Prometheus server.
# It cannot be set to 'true' simultaneously with 'promote_resource_attributes'.
[ promote_all_resource_attributes: <boolean> | default = false ]
# Which resource attributes to ignore, can only be set when 'promote_all_resource_attributes' is true.
[ ignore_resource_attributes: [<string>, ...] | default = [] ]
# Configures translation of OTLP metrics when received through the OTLP metrics
# endpoint. Available values:
# - "UnderscoreEscapingWithSuffixes" refers to commonly agreed normalization used
# by OpenTelemetry in https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/translator/prometheus
# - "NoUTF8EscapingWithSuffixes" is a mode that relies on UTF-8 support in Prometheus.
# It preserves all special characters like dots, but still adds required metric name suffixes
# for units and _total, as UnderscoreEscapingWithSuffixes does.
# - "UnderscoreEscapingWithoutSuffixes" translates metric name characters that
# are not alphanumerics/underscores/colons to underscores, and label name
# characters that are not alphanumerics/underscores to underscores, but
# unlike UnderscoreEscapingWithSuffixes it does not append any suffixes to
# the names.
# - (EXPERIMENTAL) "NoTranslation" is a mode that relies on UTF-8 support in Prometheus.
# It preserves all special character like dots and won't append special suffixes for metric
# unit and type.
#
# WARNING: The "NoTranslation" setting has significant known risks and limitations (see https://prometheus.golang.com.tw/docs/practices/naming/
# for details):
# * Impaired UX when using PromQL in plain YAML (e.g. alerts, rules, dashboard, autoscaling configuration).
# * Series collisions which in the best case may result in OOO errors, in the worst case a silently malformed
# time series. For instance, you may end up in situation of ingesting `foo.bar` series with unit
# `seconds` and a separate series `foo.bar` with unit `milliseconds`.
[ translation_strategy: <string> | default = "UnderscoreEscapingWithSuffixes" ]
# Enables adding "service.name", "service.namespace" and "service.instance.id"
# resource attributes to the "target_info" metric, on top of converting
# them into the "instance" and "job" labels.
[ keep_identifying_resource_attributes: <boolean> | default = false ]
# Configures optional translation of OTLP explicit bucket histograms into native histograms with custom buckets.
[ convert_histograms_to_nhcb: <boolean> | default = false ]
# Enables promotion of OTel scope metadata (i.e. name, version, schema URL, and attributes) to metric labels.
# This is disabled by default for backwards compatibility, but according to OTel spec, scope metadata _should_ be identifying, i.e. translated to metric labels.
[ promote_scope_metadata: <boolean> | default = false ]
# Controls whether to enable prepending of 'key_' to labels starting with '_'.
# Reserved labels starting with '__' are not modified.
# This is only relevant when translation_strategy uses underscore escaping
# (e.g., "UnderscoreEscapingWithSuffixes" or "UnderscoreEscapingWithoutSuffixes").
[ label_name_underscore_sanitization: <boolean> | default = true ]
# Enables preserving of multiple consecutive underscores in label names when
# translation_strategy uses underscore escaping. When true (default), multiple
# consecutive underscores are preserved during label name sanitization.
[ label_name_preserve_multiple_underscores: <boolean> | default = true ]
# Settings related to the remote read feature.
remote_read:
[ - <remote_read> ... ]
# Storage related settings that are runtime reloadable.
storage:
[ tsdb: <tsdb> ]
[ exemplars: <exemplars> ]
# Configures exporting traces.
tracing:
[ <tracing_config> ]
<scrape_config>
scrape_config 部分指定了一組目標以及描述如何抓取這些目標的引數。在一般情況下,一個抓取配置指定一個任務。在高階配置中,這可能會有所改變。
目標可以透過 static_configs 引數進行靜態配置,也可以使用支援的服務發現機制之一進行動態發現。
此外, relabel_configs 允許在抓取之前對任何目標及其標籤進行高階修改。
# The job name assigned to scraped metrics by default.
job_name: <job_name>
# How frequently to scrape targets from this job.
[ scrape_interval: <duration> | default = <global_config.scrape_interval> ]
# Per-scrape timeout when scraping this job.
# It cannot be greater than the scrape interval.
[ scrape_timeout: <duration> | default = <global_config.scrape_timeout> ]
# The protocols to negotiate during a scrape with the client.
# Supported values (case sensitive): PrometheusProto, OpenMetricsText0.0.1,
# OpenMetricsText1.0.0, PrometheusText0.0.4, PrometheusText1.0.0.
# If not set in the global config, the default value depends on the
# setting of scrape_native_histograms. If false, it is
# [ OpenMetricsText1.0.0, OpenMetricsText0.0.1, PrometheusText1.0.0, PrometheusText0.0.4 ].
# If true, it is
# [ PrometheusProto, OpenMetricsText1.0.0, OpenMetricsText0.0.1, PrometheusText1.0.0, PrometheusText0.0.4 ].
[ scrape_protocols: [<string>, ...] | default = <dynamic> ]
# Fallback protocol to use if a scrape returns blank, unparsable, or otherwise
# invalid Content-Type.
# Supported values (case sensitive): PrometheusProto, OpenMetricsText0.0.1,
# OpenMetricsText1.0.0, PrometheusText0.0.4, PrometheusText1.0.0.
[ fallback_scrape_protocol: <string> ]
# The HTTP resource path on which to fetch metrics from targets.
[ metrics_path: <path> | default = /metrics ]
# honor_labels controls how Prometheus handles conflicts between labels that are
# already present in scraped data and labels that Prometheus would attach
# server-side ("job" and "instance" labels, manually configured target
# labels, and labels generated by service discovery implementations).
#
# If honor_labels is set to "true", label conflicts are resolved by keeping label
# values from the scraped data and ignoring the conflicting server-side labels.
#
# If honor_labels is set to "false", label conflicts are resolved by renaming
# conflicting labels in the scraped data to "exported_<original-label>" (for
# example "exported_instance", "exported_job") and then attaching server-side
# labels.
#
# Setting honor_labels to "true" is useful for use cases such as federation and
# scraping the Pushgateway, where all labels specified in the target should be
# preserved.
#
# Note that any globally configured "external_labels" are unaffected by this
# setting. In communication with external systems, they are always applied only
# when a time series does not have a given label yet and are ignored otherwise.
[ honor_labels: <boolean> | default = false ]
# honor_timestamps controls whether Prometheus respects the timestamps present
# in scraped data.
#
# If honor_timestamps is set to "true", the timestamps of the metrics exposed
# by the target will be used.
#
# If honor_timestamps is set to "false", the timestamps of the metrics exposed
# by the target will be ignored.
[ honor_timestamps: <boolean> | default = true ]
# track_timestamps_staleness controls whether Prometheus tracks staleness of
# the metrics that have an explicit timestamps present in scraped data.
#
# If track_timestamps_staleness is set to "true", a staleness marker will be
# inserted in the TSDB when a metric is no longer present or the target
# is down.
[ track_timestamps_staleness: <boolean> | default = false ]
# Configures the protocol scheme used for requests.
[ scheme: <scheme> | default = http ]
# Optional HTTP URL parameters.
params:
[ <string>: [<string>, ...] ]
# If enable_compression is set to "false", Prometheus will request uncompressed
# response from the scraped target.
[ enable_compression: <boolean> | default = true ]
# File to which scrape failures are logged.
# Reloading the configuration will reopen the file.
[ scrape_failure_log_file: <string> ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
# List of AWS service discovery configurations.
aws_sd_configs:
[ - <aws_sd_config> ... ]
# List of Azure service discovery configurations.
azure_sd_configs:
[ - <azure_sd_config> ... ]
# List of Consul service discovery configurations.
consul_sd_configs:
[ - <consul_sd_config> ... ]
# List of DigitalOcean service discovery configurations.
digitalocean_sd_configs:
[ - <digitalocean_sd_config> ... ]
# List of Docker service discovery configurations.
docker_sd_configs:
[ - <docker_sd_config> ... ]
# List of Docker Swarm service discovery configurations.
dockerswarm_sd_configs:
[ - <dockerswarm_sd_config> ... ]
# List of DNS service discovery configurations.
dns_sd_configs:
[ - <dns_sd_config> ... ]
# List of EC2 service discovery configurations.
ec2_sd_configs:
[ - <ec2_sd_config> ... ]
# List of Eureka service discovery configurations.
eureka_sd_configs:
[ - <eureka_sd_config> ... ]
# List of file service discovery configurations.
file_sd_configs:
[ - <file_sd_config> ... ]
# List of GCE service discovery configurations.
gce_sd_configs:
[ - <gce_sd_config> ... ]
# List of Hetzner service discovery configurations.
hetzner_sd_configs:
[ - <hetzner_sd_config> ... ]
# List of HTTP service discovery configurations.
http_sd_configs:
[ - <http_sd_config> ... ]
# List of IONOS service discovery configurations.
ionos_sd_configs:
[ - <ionos_sd_config> ... ]
# List of Kubernetes service discovery configurations.
kubernetes_sd_configs:
[ - <kubernetes_sd_config> ... ]
# List of Kuma service discovery configurations.
kuma_sd_configs:
[ - <kuma_sd_config> ... ]
# List of Lightsail service discovery configurations.
lightsail_sd_configs:
[ - <lightsail_sd_config> ... ]
# List of Linode service discovery configurations.
linode_sd_configs:
[ - <linode_sd_config> ... ]
# List of Marathon service discovery configurations.
marathon_sd_configs:
[ - <marathon_sd_config> ... ]
# List of AirBnB's Nerve service discovery configurations.
nerve_sd_configs:
[ - <nerve_sd_config> ... ]
# List of Nomad service discovery configurations.
nomad_sd_configs:
[ - <nomad_sd_config> ... ]
# List of OpenStack service discovery configurations.
openstack_sd_configs:
[ - <openstack_sd_config> ... ]
# List of Outscale service discovery configurations.
outscale_sd_configs:
[ - <outscale_sd_config> ... ]
# List of OVHcloud service discovery configurations.
ovhcloud_sd_configs:
[ - <ovhcloud_sd_config> ... ]
# List of PuppetDB service discovery configurations.
puppetdb_sd_configs:
[ - <puppetdb_sd_config> ... ]
# List of Scaleway service discovery configurations.
scaleway_sd_configs:
[ - <scaleway_sd_config> ... ]
# List of Zookeeper Serverset service discovery configurations.
serverset_sd_configs:
[ - <serverset_sd_config> ... ]
# List of STACKIT service discovery configurations.
stackit_sd_configs:
[ - <stackit_sd_config> ... ]
# List of Triton service discovery configurations.
triton_sd_configs:
[ - <triton_sd_config> ... ]
# List of Uyuni service discovery configurations.
uyuni_sd_configs:
[ - <uyuni_sd_config> ... ]
# List of labeled statically configured targets for this job.
static_configs:
[ - <static_config> ... ]
# List of target relabel configurations.
relabel_configs:
[ - <relabel_config> ... ]
# List of metric relabel configurations.
metric_relabel_configs:
[ - <relabel_config> ... ]
# An uncompressed response body larger than this many bytes will cause the
# scrape to fail. 0 means no limit. Example: 100MB.
# This is an experimental feature, this behaviour could
# change or be removed in the future.
[ body_size_limit: <size> | default = 0 ]
# Per-scrape limit on the number of scraped samples that will be accepted.
# If more than this number of samples are present after metric relabeling
# the entire scrape will be treated as failed. 0 means no limit.
[ sample_limit: <int> | default = 0 ]
# Limit on the number of labels that will be accepted per sample. If more
# than this number of labels are present on any sample post metric-relabeling,
# the entire scrape will be treated as failed. 0 means no limit.
[ label_limit: <int> | default = 0 ]
# Limit on the length (in bytes) of each individual label name. If any label
# name in a scrape is longer than this number post metric-relabeling, the
# entire scrape will be treated as failed. Note that label names are UTF-8
# encoded, and characters can take up to 4 bytes. 0 means no limit.
[ label_name_length_limit: <int> | default = 0 ]
# Limit on the length (in bytes) of each individual label value. If any label
# value in a scrape is longer than this number post metric-relabeling, the
# entire scrape will be treated as failed. Note that label values are UTF-8
# encoded, and characters can take up to 4 bytes. 0 means no limit.
[ label_value_length_limit: <int> | default = 0 ]
# Limit per scrape config on number of unique targets that will be
# accepted. If more than this number of targets are present after target
# relabeling, Prometheus will mark the targets as failed without scraping them.
# 0 means no limit. This is an experimental feature, this behaviour could
# change in the future.
[ target_limit: <int> | default = 0 ]
# Limit per scrape config on the number of targets dropped by relabeling
# that will be kept in memory. 0 means no limit.
[ keep_dropped_targets: <int> | default = 0 ]
# Specifies the validation scheme for metric and label names. Either blank or
# "utf8" for full UTF-8 support, or "legacy" for letters, numbers, colons, and
# underscores.
[ metric_name_validation_scheme: <string> | default "utf8" ]
# Specifies the character escaping scheme that will be requested when scraping
# for metric and label names that do not conform to the legacy Prometheus
# character set. Available options are:
# * `allow-utf-8`: Full UTF-8 support, no escaping needed.
# * `underscores`: Escape all legacy-invalid characters to underscores.
# * `dots`: Escapes dots to `_dot_`, underscores to `__`, and all other
# legacy-invalid characters to underscores.
# * `values`: Prepend the name with `U__` and replace all invalid
# characters with their unicode value, surrounded by underscores. Single
# underscores are replaced with double underscores.
# e.g. "U__my_2e_dotted_2e_name".
# If this value is left blank, Prometheus will default to `allow-utf-8` if the
# validation scheme for the current scrape config is set to utf8, or
# `underscores` if the validation scheme is set to `legacy`.
[ metric_name_escaping_scheme: <string> | default "allow-utf-8" ]
# Limit on total number of positive and negative buckets allowed in a single
# native histogram. The resolution of a histogram with more buckets will be
# reduced until the number of buckets is within the limit. If the limit cannot
# be reached, the scrape will fail.
# 0 means no limit.
[ native_histogram_bucket_limit: <int> | default = 0 ]
# Lower limit for the growth factor of one bucket to the next in each native
# histogram. The resolution of a histogram with a lower growth factor will be
# reduced as much as possible until it is within the limit.
# To set an upper limit for the schema (equivalent to "scale" in OTel's
# exponential histograms), use the following factor limits:
#
# +----------------------------+----------------------------+
# | growth factor | resulting schema AKA scale |
# +----------------------------+----------------------------+
# | 65536 | -4 |
# +----------------------------+----------------------------+
# | 256 | -3 |
# +----------------------------+----------------------------+
# | 16 | -2 |
# +----------------------------+----------------------------+
# | 4 | -1 |
# +----------------------------+----------------------------+
# | 2 | 0 |
# +----------------------------+----------------------------+
# | 1.4 | 1 |
# +----------------------------+----------------------------+
# | 1.1 | 2 |
# +----------------------------+----------------------------+
# | 1.09 | 3 |
# +----------------------------+----------------------------+
# | 1.04 | 4 |
# +----------------------------+----------------------------+
# | 1.02 | 5 |
# +----------------------------+----------------------------+
# | 1.01 | 6 |
# +----------------------------+----------------------------+
# | 1.005 | 7 |
# +----------------------------+----------------------------+
# | 1.002 | 8 |
# +----------------------------+----------------------------+
#
# 0 results in the smallest supported factor (which is currently ~1.0027 or
# schema 8, but might change in the future).
[ native_histogram_min_bucket_factor: <float> | default = 0 ]
# If true, native histograms exposed by a target are recognized during
# scraping and ingested as such. If false, any native parts of histograms
# are ignored and only the classic parts are recognized (possibly as
# a classic histogram with only the +Inf buckets if no explicit classic
# buckets are part of the histogram).
[ scrape_native_histograms: <bool> | default = <global.scrape_native_histograms> ]
# Specifies whether to convert classic histograms into native histograms with
# custom buckets.
[ convert_classic_histograms_to_nhcb: <bool> | default = <global.convert_classic_histograms_to_nhcb>]
# Specifies whether to additionally scrape the classic parts of a histogram,
# even if it is also exposed with native parts or it is converted into a
# native histogram with custom buckets.
[ always_scrape_classic_histograms: <boolean> | default = <global.always_scrape_classic_histograms> ]
# When enabled, Prometheus stores additional time series for this scrape job:
# scrape_timeout_seconds, scrape_sample_limit, and scrape_body_size_bytes.
# These metrics help monitor how close targets are to their configured limits.
# If not set, inherits the value from the global configuration.
[ extra_scrape_metrics: <boolean> | default = <global.extra_scrape_metrics> ]
# See global configuration above for further explanations of how the last three
# options combine their effects.
其中 <job_name> 在所有抓取配置中必須是唯一的。
<http_config>
http_config 允許配置 HTTP 請求。
# Sets the `Authorization` header on every request with the
# configured username and password.
# username and username_file are mutually exclusive.
# password and password_file are mutually exclusive.
basic_auth:
[ username: <string> ]
[ username_file: <string> ]
[ password: <secret> ]
[ password_file: <string> ]
# Sets the `Authorization` header on every request with
# the configured credentials.
authorization:
# Sets the authentication type of the request.
[ type: <string> | default: Bearer ]
# Sets the credentials of the request. It is mutually exclusive with
# `credentials_file`.
[ credentials: <secret> ]
# Sets the credentials of the request with the credentials read from the
# configured file. It is mutually exclusive with `credentials`.
[ credentials_file: <filename> ]
# Optional OAuth 2.0 configuration.
# Cannot be used at the same time as basic_auth or authorization.
oauth2:
[ <oauth2> ]
# Configure whether requests follow HTTP 3xx redirects.
[ follow_redirects: <boolean> | default = true ]
# Whether to enable HTTP2.
[ enable_http2: <boolean> | default: true ]
# Configures the request's TLS settings.
tls_config:
[ <tls_config> ]
# Optional proxy URL.
[ proxy_url: <string> ]
# Comma-separated string that can contain IPs, CIDR notation, domain names
# that should be excluded from proxying. IP and domain names can
# contain port numbers.
[ no_proxy: <string> ]
# Use proxy URL indicated by environment variables (HTTP_PROXY, https_proxy, HTTPs_PROXY, https_proxy, and no_proxy)
[ proxy_from_environment: <boolean> | default: false ]
# Specifies headers to send to proxies during CONNECT requests.
[ proxy_connect_header:
[ <string>: [<secret>, ...] ] ]
# Custom HTTP headers to be sent along with each request.
# Headers that are set by Prometheus itself can't be overwritten.
http_headers:
# Header name.
[ <string>:
# Header values.
[ values: [<string>, ...] ]
# Headers values. Hidden in configuration page.
[ secrets: [<secret>, ...] ]
# Files to read header values from.
[ files: [<string>, ...] ] ]
<tls_config>
tls_config 允許配置 TLS 連線。
# CA certificate to validate API server certificate with. At most one of ca and ca_file is allowed.
[ ca: <string> ]
[ ca_file: <filename> ]
# Certificate and key for client cert authentication to the server.
# At most one of cert and cert_file is allowed.
# At most one of key and key_file is allowed.
[ cert: <string> ]
[ cert_file: <filename> ]
[ key: <secret> ]
[ key_file: <filename> ]
# ServerName extension to indicate the name of the server.
# https://tools.ietf.org/html/rfc4366#section-3.1
[ server_name: <string> ]
# Disable validation of the server certificate.
[ insecure_skip_verify: <boolean> ]
# Minimum acceptable TLS version. Accepted values: TLS10 (TLS 1.0), TLS11 (TLS
# 1.1), TLS12 (TLS 1.2), TLS13 (TLS 1.3).
# If unset, Prometheus will use Go default minimum version, which is TLS 1.2.
# See MinVersion in https://pkg.go.dev/crypto/tls#Config.
[ min_version: <string> ]
# Maximum acceptable TLS version. Accepted values: TLS10 (TLS 1.0), TLS11 (TLS
# 1.1), TLS12 (TLS 1.2), TLS13 (TLS 1.3).
# If unset, Prometheus will use Go default maximum version, which is TLS 1.3.
# See MaxVersion in https://pkg.go.dev/crypto/tls#Config.
[ max_version: <string> ]
<oauth2>
使用客戶端憑據(client credentials)或密碼授權型別(password grant type)的 OAuth 2.0 認證。Prometheus 使用給定的客戶端訪問許可權和憑據從指定的端點獲取訪問令牌。
client_id: <string>
# OAuth2 grant type to use. It can be one of
# "client_credentials" or "urn:ietf:params:oauth:grant-type:jwt-bearer" (RFC 7523).
# Default value is "client_credentials"
[ grant_type: <string> ]
# Client secret to provide to authorization server. Only used if
# GrantType is set empty or set to "client_credentials".
[ client_secret: <secret> ]
# Read the client secret from a file.
# It is mutually exclusive with `client_secret`.
[ client_secret_file: <filename> ]
# Secret key to sign JWT with. Only used if
# GrantType is set to "urn:ietf:params:oauth:grant-type:jwt-bearer".
[ client_certificate_key: <secret> ]
# Read the secret key from a file.
# It is mutually exclusive with `client_certificate_key`.
[ client_certificate_key_file: <filename> ]
# JWT kid value to include in the JWT header. Only used if
# GrantType is set to "urn:ietf:params:oauth:grant-type:jwt-bearer".
[ client_certificate_key_id: <string> ]
# Signature algorithm used to sign JWT token. Only used if
# GrantType is set to "urn:ietf:params:oauth:grant-type:jwt-bearer".
# Default value is RS256 and valid values RS256, RS384, RS512
[ signature_algorithm: <string> ]
# OAuth client identifier used when communicating with
# the configured OAuth provider. Default value is client_id. Only used if
# GrantType is set to "urn:ietf:params:oauth:grant-type:jwt-bearer".
[ iss: <string> ]
# Intended audience of the request. If empty, the value
# of TokenURL is used as the intended audience. Only used if
# GrantType is set to "urn:ietf:params:oauth:grant-type:jwt-bearer".
[ audience: <string> ]
# Map of claims to be added to the JWT token. Only used if
# GrantType is set to "urn:ietf:params:oauth:grant-type:jwt-bearer".
claims:
[ <string>: <string> ... ]
# Scopes for the token request.
scopes:
[ - <string> ... ]
# The URL to fetch the token from.
token_url: <string>
# Optional parameters to append to the token URL.
# To set 'password' grant type, add it to params:
# endpoint_params:
# grant_type: 'password'
# username: '[email protected]'
# password: 'strongpassword'
endpoint_params:
[ <string>: <string> ... ]
# Configures the token request's TLS settings.
tls_config:
[ <tls_config> ]
# Optional proxy URL.
[ proxy_url: <string> ]
# Comma-separated string that can contain IPs, CIDR notation, domain names
# that should be excluded from proxying. IP and domain names can
# contain port numbers.
[ no_proxy: <string> ]
# Use proxy URL indicated by environment variables (HTTP_PROXY, https_proxy, HTTPs_PROXY, https_proxy, and no_proxy)
[ proxy_from_environment: <boolean> | default: false ]
# Specifies headers to send to proxies during CONNECT requests.
[ proxy_connect_header:
[ <string>: [<secret>, ...] ] ]
# Custom HTTP headers to be sent along with each request.
# Headers that are set by Prometheus itself can't be overwritten.
http_headers:
# Header name.
[ <string>:
# Header values.
[ values: [<string>, ...] ]
# Headers values. Hidden in configuration page.
[ secrets: [<secret>, ...] ]
# Files to read header values from.
[ files: [<string>, ...] ] ]
<aws_sd_config>
AWS SD 配置允許從 AWS 服務中檢索抓取目標。這是一種統一的服務發現方式,透過 role 引數支援多種 AWS 服務型別。
可以配置以下 role 型別之一來發現目標
ec2
ec2 角色從 AWS EC2 例項中發現目標。預設使用私有 IP 地址,但可以透過重新標記更改為公有 IP 地址。
所使用的 IAM 憑證必須擁有 ec2:DescribeInstances 許可權以發現抓取目標;如果您希望可用區 ID 作為標籤可用,還可以選擇性地擁有 ec2:DescribeAvailabilityZones 許可權(見下文)。
在重新標記期間,目標上可以使用以下元標籤
__meta_ec2_ami:EC2 亞馬遜系統映像(Amazon Machine Image)__meta_ec2_architecture:例項的架構__meta_ec2_availability_zone:例項執行所在的可用區__meta_ec2_availability_zone_id:例項執行所在的可用區 ID (需要ec2:DescribeAvailabilityZones)__meta_ec2_instance_id:EC2 例項 ID__meta_ec2_instance_lifecycle:EC2 例項的生命週期,僅針對 'spot'(競價例項)或 'scheduled'(計劃例項)設定,否則不存在__meta_ec2_instance_state:EC2 例項的狀態__meta_ec2_instance_type:EC2 例項的型別__meta_ec2_ipv6_addresses:分配給例項網路介面的 IPv6 地址的逗號分隔列表(如果存在)__meta_ec2_owner_id:擁有該 EC2 例項的 AWS 賬號 ID__meta_ec2_platform:作業系統平臺,在 Windows 伺服器上設定為 'windows',否則不存在__meta_ec2_default_ipv6_address:找到的第一個主 IPv6 地址(如果存在),否則為第一個非主 IPv6 地址(如果存在)__meta_ec2_primary_ipv6_addresses:例項的主 IPv6 地址的逗號分隔列表(如果存在)。該列表根據每個對應網路介面在掛載順序中的位置進行排序。__meta_ec2_primary_subnet_id:主網路介面的子網 ID(如果可用)__meta_ec2_private_dns_name:例項的私有 DNS 名稱(如果可用)__meta_ec2_private_ip:例項的私有 IP 地址(如果存在)__meta_ec2_public_dns_name:例項的公有 DNS 名稱(如果可用)__meta_ec2_public_ip:例項的公有 IP 地址(如果可用)__meta_ec2_region:例項所在的區域__meta_ec2_subnet_id:例項執行所在的子網 ID 的逗號分隔列表(如果可用)__meta_ec2_tag_<tagkey>:例項的每個標籤值__meta_ec2_vpc_id:例項執行所在的 VPC ID(如果可用)
lightsail
lightsail 角色從 AWS Lightsail 例項中發現目標。預設使用私有 IP 地址,但可以透過重新標記更改為公有 IP 地址。
在重新標記期間,目標上可以使用以下元標籤
__meta_lightsail_availability_zone:例項執行所在的可用區__meta_lightsail_blueprint_id:Lightsail 藍圖 ID__meta_lightsail_bundle_id:Lightsail 套餐 ID__meta_lightsail_instance_name:Lightsail 例項的名稱__meta_lightsail_instance_state:Lightsail 例項的狀態__meta_lightsail_instance_support_code:Lightsail 例項的支援程式碼__meta_lightsail_ipv6_addresses:分配給例項網路介面的 IPv6 地址的逗號分隔列表(如果存在)__meta_lightsail_private_ip:例項的私有 IP 地址__meta_lightsail_public_ip:例項的公有 IP 地址(如果可用)__meta_lightsail_region:例項所在的區域__meta_lightsail_tag_<tagkey>:例項的每個標籤值
ecs
ecs 角色從 AWS ECS 容器中發現目標。
ECS 服務發現支援所有 ECS 網路模式
- awsvpc 模式(帶有 ENI 的 Fargate 和 EC2):使用來自其彈性網路介面的任務私有 IP 地址
- bridge 模式(EC2):使用 EC2 宿主機例項的私有 IP 地址
- host 模式(EC2):使用 EC2 宿主機例項的私有 IP 地址
預設使用私有 IP 地址,但可以透過重新標記更改為公有 IP 地址。
所使用的 IAM 憑證必須具有以下許可權才能發現抓取目標
ecs:ListClustersecs:DescribeClustersecs:ListServicesecs:DescribeServicesecs:ListTasksecs:DescribeTasksecs:DescribeContainerInstances(EC2 啟動型別任務所需)ec2:DescribeInstances(EC2 啟動型別任務所需)ec2:DescribeNetworkInterfaces(獲取 awsvpc 模式任務的公有 IP 所需)
在重新標記期間,目標上可以使用以下元標籤
__meta_ecs_cluster:ECS 叢集的名稱__meta_ecs_cluster_arn:ECS 叢集的 ARN__meta_ecs_service:ECS 服務的名稱__meta_ecs_service_arn:ECS 服務的 ARN__meta_ecs_service_status:ECS 服務的狀態__meta_ecs_task_group:ECS 任務組(通常是 service:service-name)__meta_ecs_task_arn:ECS 任務的 ARN__meta_ecs_task_definition:ECS 任務定義的 ARN__meta_ecs_ip_address:任務的私有 IP 地址__meta_ecs_launch_type:任務的啟動型別(EC2 或 Fargate)__meta_ecs_desired_status:任務的期望狀態__meta_ecs_last_status:任務的最新已知狀態__meta_ecs_health_status:任務的健康狀態__meta_ecs_platform_family:平臺家族(例如 Linux、Windows)__meta_ecs_platform_version:平臺版本__meta_ecs_subnet_id:任務執行所在的子網 ID__meta_ecs_availability_zone:任務執行所在的可用區__meta_ecs_region:AWS 區域__meta_ecs_public_ip:公有 IP 地址(在 awsvpc 模式下來自 ENI,在 bridge/host 模式下來自 EC2 例項)(如果可用)__meta_ecs_network_mode:任務的網路模式(awsvpc 或 bridge)__meta_ecs_container_instance_arn:容器例項的 ARN(僅限 EC2 啟動型別)__meta_ecs_ec2_instance_id:EC2 例項 ID(僅限 EC2 啟動型別)__meta_ecs_ec2_instance_type:EC2 例項型別(僅限 EC2 啟動型別)__meta_ecs_ec2_instance_private_ip:EC2 例項的私有 IP 地址(僅限 EC2 啟動型別)__meta_ecs_ec2_instance_public_ip:EC2 例項的公有 IP 地址(如果可用)(僅限 EC2 啟動型別)__meta_ecs_tag_cluster_<tagkey>:每個叢集標籤值,以標籤名稱為鍵__meta_ecs_tag_service_<tagkey>:每個服務標籤值,以標籤名稱為鍵__meta_ecs_tag_task_<tagkey>:每個任務標籤值,以標籤名稱為鍵__meta_ecs_tag_ec2_<tagkey>:每個 EC2 例項標籤值,以標籤名稱為鍵(僅限 EC2 啟動型別)
msk
msk 角色從 AWS MSK(Apache Kafka 託管流式處理)已預配的叢集中發現目標。
重要提示:此服務發現僅適用於已預配的叢集(provisioned clusters)。不支援無伺服器(Serverless)叢集,因為它們不公開單個 broker 節點。
發現的內容包括
- Broker 節點:Kafka broker 例項(支援基於 ZooKeeper 和基於 KRaft 的叢集)
- KRaft 控制器節點:控制器例項(僅限基於 KRaft 的叢集)
注意:無法透過 MSK API 發現 ZooKeeper 節點。為了進行監控,MSK 提供了
- JMX Exporter:在 broker 和 KRaft 控制器節點上都可用(啟用時)
- Node Exporter:僅在 broker 節點上可用(啟用時)
所使用的 IAM 憑證必須具有以下許可權才能發現抓取目標
kafka:DescribeClusterV2kafka:ListClustersV2kafka:ListNodes
在重新標記期間,目標上可以使用以下元標籤
__meta_msk_cluster_name:MSK 叢集的名稱__meta_msk_cluster_arn:MSK 叢集的 ARN__meta_msk_cluster_state:MSK 叢集的狀態(例如 ACTIVE、CREATING、DELETING)__meta_msk_cluster_type:MSK 叢集的型別(例如 PROVISIONED、SERVERLESS)__meta_msk_cluster_version:MSK 叢集的當前版本__meta_msk_cluster_kafka_version:叢集上執行的 Kafka 版本__meta_msk_cluster_jmx_exporter_enabled:叢集上是否啟用了 JMX Exporter__meta_msk_cluster_configuration_arn:MSK 配置的 ARN__meta_msk_cluster_configuration_revision:MSK 配置的版本號(revision)__meta_msk_cluster_tag_<tagkey>:每個叢集標籤值,以標籤名稱為鍵__meta_msk_node_type:節點型別(BROKER 或 CONTROLLER)__meta_msk_node_arn:節點的 ARN__meta_msk_node_added_time:節點新增到叢集的時間__meta_msk_node_instance_type:節點的例項型別__meta_msk_node_attached_eni:掛載的 ENI 的 ID__meta_msk_broker_id:broker ID(僅限 broker 節點)__meta_msk_broker_endpoint_index:broker 端點的索引(僅限 broker 節點)__meta_msk_broker_client_subnet:broker 的客戶端子網(僅限 broker 節點)__meta_msk_broker_client_vpc_ip:broker 的 VPC IP 地址(僅限 broker 節點)__meta_msk_broker_node_exporter_enabled:在 broker 上是否啟用了 Node Exporter(僅限 broker 節點)__meta_msk_controller_endpoint_index:控制器端點的索引(僅限控制器節點)
elasticache
elasticache 角色從 AWS ElastiCache 中發現無伺服器(serverless)快取和快取叢集的目標。
重要提示:對於快取叢集,每個快取節點都會建立一個目標。每個目標包括叢集級別的標籤(ARN、狀態、標籤等)和節點特定的標籤(節點 ID、端點、可用區等)。__address__ 標籤設定為單個節點的端點地址和埠。
對於無伺服器快取,每個無伺服器快取都會建立一個目標,且其 __address__ 標籤設定為無伺服器快取的端點。
所使用的 IAM 憑證必須具有以下許可權才能發現抓取目標
elasticache:DescribeServerlessCacheselasticache:DescribeCacheClusterselasticache:ListTagsForResource
在重新標記期間,目標上可以使用以下元標籤
通用標籤(在所有目標上都可用)
__meta_elasticache_deployment_option:部署選項 - 無伺服器快取為serverless,快取叢集節點為node
無伺服器快取標籤
__meta_elasticache_serverless_cache_arn:無伺服器快取的 ARN__meta_elasticache_serverless_cache_name:無伺服器快取的名稱__meta_elasticache_serverless_cache_status:無伺服器快取的狀態__meta_elasticache_serverless_cache_engine:快取引擎(redis 或 valkey)__meta_elasticache_serverless_cache_full_engine_version:完整的引擎版本__meta_elasticache_serverless_cache_major_engine_version:主引擎版本__meta_elasticache_serverless_cache_description:無伺服器快取的描述__meta_elasticache_serverless_cache_create_time:RFC3339 格式的建立時間__meta_elasticache_serverless_cache_snapshot_retention_limit:快照保留天數限制__meta_elasticache_serverless_cache_daily_snapshot_time:每日快照時間__meta_elasticache_serverless_cache_user_group_id:使用者組 ID__meta_elasticache_serverless_cache_kms_key_id:用於靜態加密的 KMS 金鑰 ID__meta_elasticache_serverless_cache_endpoint_address:端點地址__meta_elasticache_serverless_cache_endpoint_port:端點埠__meta_elasticache_serverless_cache_reader_endpoint_address:只讀端點地址__meta_elasticache_serverless_cache_reader_endpoint_port:只讀端點埠__meta_elasticache_serverless_cache_security_group_id_<index>:安全組 ID(帶索引)__meta_elasticache_serverless_cache_subnet_id_<index>:子網 ID(帶索引)__meta_elasticache_serverless_cache_cache_usage_limit_data_storage_maximum:指定單位的最大資料儲存量__meta_elasticache_serverless_cache_cache_usage_limit_data_storage_minimum: 指定單位的最小資料儲存量__meta_elasticache_serverless_cache_cache_usage_limit_data_storage_unit:資料儲存單位(例如 GB)__meta_elasticache_serverless_cache_cache_usage_limit_ecpu_per_second_maximum:每秒最大 ECPU__meta_elasticache_serverless_cache_cache_usage_limit_ecpu_per_second_minimum:每秒最小 ECPU__meta_elasticache_serverless_cache_tag_<tagkey>:每個無伺服器快取標籤值,以標籤名稱為鍵
快取叢集標籤
__meta_elasticache_cache_cluster_arn:快取叢集的 ARN__meta_elasticache_cache_cluster_cache_cluster_id:快取叢集 ID__meta_elasticache_cache_cluster_cache_cluster_status:快取叢集的狀態__meta_elasticache_cache_cluster_engine:快取引擎(redis 或 memcached)__meta_elasticache_cache_cluster_engine_version:引擎版本__meta_elasticache_cache_cluster_cache_node_type:快取節點型別(例如 cache.t3.micro)__meta_elasticache_cache_cluster_num_cache_nodes:快取節點的數量__meta_elasticache_cache_cluster_cache_cluster_create_time:RFC3339 格式的建立時間__meta_elasticache_cache_cluster_at_rest_encryption_enabled:是否啟用了靜態加密__meta_elasticache_cache_cluster_transit_encryption_enabled:是否啟用了傳輸中加密__meta_elasticache_cache_cluster_transit_encryption_mode:傳輸中加密模式__meta_elasticache_cache_cluster_auth_token_enabled:是否啟用了認證令牌(auth token)__meta_elasticache_cache_cluster_auth_token_last_modified:認證令牌的最後修改時間__meta_elasticache_cache_cluster_auto_minor_version_upgrade:是否啟用了自動小版本升級__meta_elasticache_cache_cluster_cache_parameter_group:快取引數組名稱__meta_elasticache_cache_cluster_cache_subnet_group_name:快取子網組名稱__meta_elasticache_cache_cluster_client_download_landing_page:客戶端下載登入頁 URL__meta_elasticache_cache_cluster_ip_discovery:IP 發現模式(ipv4 或 ipv6)__meta_elasticache_cache_cluster_network_type:網路型別(ipv4、ipv6 或 dual_stack)__meta_elasticache_cache_cluster_preferred_availability_zone:首選可用區__meta_elasticache_cache_cluster_preferred_maintenance_window:首選維護視窗__meta_elasticache_cache_cluster_preferred_outpost_arn:首選 Outpost ARN__meta_elasticache_cache_cluster_replication_group_id:複製組 ID(適用於屬於複製組一部分的 Redis 叢集)__meta_elasticache_cache_cluster_replication_group_log_delivery_enabled:複製組是否啟用了日誌投遞__meta_elasticache_cache_cluster_snapshot_retention_limit:快照保留限制(天數)__meta_elasticache_cache_cluster_snapshot_window:每日快照視窗__meta_elasticache_cache_cluster_configuration_endpoint_address:配置端點地址(僅在啟用叢集模式時有效)__meta_elasticache_cache_cluster_configuration_endpoint_port:配置端點埠(僅在啟用叢集模式時有效)__meta_elasticache_cache_cluster_notification_topic_arn:用於通知的 SNS 主題 ARN__meta_elasticache_cache_cluster_notification_topic_status:SNS 主題狀態__meta_elasticache_cache_cluster_log_delivery_configuration_destination_type_<index>:日誌投遞目標型別(cloudwatch-logs 或 kinesis-firehose)__meta_elasticache_cache_cluster_log_delivery_configuration_log_format_<index>:日誌格式(text 或 json)__meta_elasticache_cache_cluster_log_delivery_configuration_log_type_<index>:日誌型別(slow-log 或 engine-log)__meta_elasticache_cache_cluster_log_delivery_configuration_status_<index>:日誌投遞狀態__meta_elasticache_cache_cluster_log_delivery_configuration_message_<index>:日誌投遞訊息__meta_elasticache_cache_cluster_log_delivery_configuration_log_group_<index>:CloudWatch 日誌組名稱(僅限 cloudwatch-logs 目標)__meta_elasticache_cache_cluster_log_delivery_configuration_delivery_stream_<index>:Kinesis Firehose 投遞流名稱(僅限 kinesis-firehose 目標)__meta_elasticache_cache_cluster_pending_modified_values_auth_token_status:待處理的身份驗證令牌狀態__meta_elasticache_cache_cluster_pending_modified_values_cache_node_type:待處理的快取節點型別變更__meta_elasticache_cache_cluster_pending_modified_values_engine_version:待處理的引擎版本升級__meta_elasticache_cache_cluster_pending_modified_values_num_cache_nodes:待處理的快取節點數量__meta_elasticache_cache_cluster_pending_modified_values_transit_encryption_enabled:待處理的傳輸中加密狀態__meta_elasticache_cache_cluster_pending_modified_values_transit_encryption_mode:待處理的傳輸中加密模式__meta_elasticache_cache_cluster_pending_modified_values_cache_node_ids_to_remove:要移除的快取節點 ID 列表(以逗號分隔)__meta_elasticache_cache_cluster_security_group_membership_id_<index>:安全組 ID(已索引)__meta_elasticache_cache_cluster_security_group_membership_status_<index>:安全組狀態(已索引)__meta_elasticache_cache_cluster_node_id:快取節點 ID__meta_elasticache_cache_cluster_node_status:快取節點狀態__meta_elasticache_cache_cluster_node_create_time:RFC3339 格式的快取節點建立時間__meta_elasticache_cache_cluster_node_availability_zone:快取節點可用區__meta_elasticache_cache_cluster_node_customer_outpost_arn:快取節點 Outpost ARN__meta_elasticache_cache_cluster_node_source_cache_node_id:用於複製的源快取節點 ID__meta_elasticache_cache_cluster_node_parameter_group_status:引數組狀態__meta_elasticache_cache_cluster_node_endpoint_address:快取節點端點地址__meta_elasticache_cache_cluster_node_endpoint_port:快取節點端點埠__meta_elasticache_cache_cluster_tag_<tagkey>:每個快取叢集的標籤值,以標籤名稱為鍵
rds
rds 角色從叢集內的 AWS RDS 資料庫例項中發現目標。為指定叢集內的每個資料庫例項建立一個目標。預設使用每個例項的端點地址和埠。
所使用的 IAM 憑證必須具有 rds:DescribeDBClusters 和 rds:DescribeDBInstances 許可權才能發現抓取目標。
在重新標記期間,目標上可以使用以下元標籤
叢集標籤
__meta_rds_cluster_activity_stream_kinesis_stream_name:用於資料庫活動流的 Amazon Kinesis 資料流名稱__meta_rds_cluster_activity_stream_kms_key_id:用於加密資料庫 activity stream 的 AWS KMS 金鑰識別符號__meta_rds_cluster_activity_stream_mode:資料庫活動流的模式(sync 或 async)__meta_rds_cluster_activity_stream_status:資料庫活動流的狀態__meta_rds_cluster_allocated_storage:已分配的儲存大小,以吉位元組(GiB)為單位__meta_rds_cluster_arn:資料庫叢集的 Amazon 資源名稱(ARN)__meta_rds_cluster_auto_minor_version_upgrade:是否啟用了自動次要版本升級__meta_rds_cluster_automatic_restart_time:已停止叢集將自動重新啟動的時間__meta_rds_cluster_aws_backup_recovery_point_arn:AWS Backup 中恢復點的 ARN__meta_rds_cluster_backtrack_consumed_change_records:為回溯(backtrack)儲存的變更記錄數量__meta_rds_cluster_backtrack_window:目標回溯視窗(以小時為單位)__meta_rds_cluster_backup_retention_period:自動備份的保留天數__meta_rds_cluster_capacity:Aurora Serverless 資料庫叢集的當前容量__meta_rds_cluster_character_set_name:字元集名稱__meta_rds_cluster_clone_group_id:克隆組 ID__meta_rds_cluster_cluster_create_time:資料庫叢集的建立時間__meta_rds_cluster_cluster_scalability_type:叢集的伸縮性型別__meta_rds_cluster_copy_tags_to_snapshot:是否將標籤從叢集複製到快照__meta_rds_cluster_cross_account_clone:資料庫叢集是否為跨賬戶克隆__meta_rds_cluster_database_insights_mode:Database Insights 的模式__meta_rds_cluster_database_name:資料庫名稱__meta_rds_cluster_db_system_id:Oracle 系統 ID(Oracle SID)__meta_rds_cluster_deletion_protection:是否啟用了刪除保護__meta_rds_cluster_earliest_backtrack_time:使用回溯可以恢復資料庫的最早時間__meta_rds_cluster_earliest_restorable_time:可以恢復資料庫的最早時間__meta_rds_cluster_endpoint:資料庫叢集的端點__meta_rds_cluster_engine_lifecycle_support:引擎生命週期支援值__meta_rds_cluster_engine_mode:叢集的引擎模式(provisioned、serverless 等)__meta_rds_cluster_engine_version:資料庫引擎的版本__meta_rds_cluster_engine:資料庫叢集的資料庫引擎__meta_rds_cluster_global_cluster_identifier:全域性叢集的識別符號__meta_rds_cluster_global_write_forwarding_requested:是否請求了全域性寫入轉發__meta_rds_cluster_global_write_forwarding_status:全域性寫入轉發的狀態__meta_rds_cluster_hosted_zone_id:Route 53 託管區域 ID__meta_rds_cluster_http_endpoint_enabled:是否啟用了 HTTP 端點__meta_rds_cluster_iam_database_authentication_enabled:資料庫叢集是否啟用了 IAM 資料庫身份驗證__meta_rds_cluster_identifier:資料庫叢集的識別符號__meta_rds_cluster_instance_class:資料庫叢集的計算和記憶體容量類__meta_rds_cluster_io_optimized_next_allowed_modification_time:允許下一次進行 IO 最佳化配置變更的時間__meta_rds_cluster_iops:預置 IOPS(每秒 I/O 操作次數)值__meta_rds_cluster_kms_key_id:加密叢集的 AWS KMS 金鑰識別符號__meta_rds_cluster_latest_restorable_time:可以恢復資料庫的最晚時間__meta_rds_cluster_local_write_forwarding_status:本地寫入轉發的狀態__meta_rds_cluster_master_username:主使用者名稱__meta_rds_cluster_monitoring_interval:增強監控指標收集之間的間隔時間(秒)__meta_rds_cluster_monitoring_role_arn:允許 RDS 向 CloudWatch 傳送增強監控指標的 IAM 角色 ARN__meta_rds_cluster_multi_az:資料庫叢集是否為多可用區(Multi-AZ)__meta_rds_cluster_network_type:網路型別(IPV4 或 DUAL)__meta_rds_cluster_parameter_group:資料庫叢集引數組的名稱__meta_rds_cluster_percent_progress:資料庫叢集操作的進度百分比__meta_rds_cluster_performance_insights_enabled:是否啟用了 Performance Insights__meta_rds_cluster_performance_insights_kms_key_id:用於加密 Performance Insights 資料的 AWS KMS 金鑰識別符號__meta_rds_cluster_performance_insights_retention_period:Performance Insights 資料的保留期限__meta_rds_cluster_port:資料庫叢集監聽的埠__meta_rds_cluster_preferred_backup_window:建立自動備份的每日時間範圍__meta_rds_cluster_preferred_maintenance_window:可以進行系統維護的每週時間範圍__meta_rds_cluster_publicly_accessible:資料庫叢集是否公開可訪問__meta_rds_cluster_reader_endpoint:資料庫叢集的讀取器(reader)端點__meta_rds_cluster_replication_source_identifier:如果該叢集是隻讀副本,則為其源資料庫叢集的識別符號__meta_rds_cluster_resource_id:資料庫叢集的 AWS 區域內唯一的不可變識別符號__meta_rds_cluster_serverless_v2_platform_version:Aurora Serverless v2 資料庫叢集的平臺版本__meta_rds_cluster_status:資料庫叢集的狀態__meta_rds_cluster_storage_encrypted:資料庫叢集是否對儲存進行了加密__meta_rds_cluster_storage_encryption_type:儲存加密型別__meta_rds_cluster_storage_throughput:儲存吞吐量,以 MiBps 為單位__meta_rds_cluster_storage_type:儲存型別__meta_rds_cluster_subnet_group:與資料庫叢集關聯的子網組名稱__meta_rds_cluster_tag_<tagkey>:資料庫叢集的每個標籤值__meta_rds_cluster_upgrade_rollout_order:升級釋出順序
例項標籤
__meta_rds_instance_activity_stream_engine_native_audit_fields_included:資料庫活動流中是否包含引擎原生審計欄位__meta_rds_instance_activity_stream_kinesis_stream_name:用於資料庫活動流的 Amazon Kinesis 資料流名稱__meta_rds_instance_activity_stream_kms_key_id:用於加密資料庫活動流的 AWS KMS 金鑰識別符號__meta_rds_instance_activity_stream_mode:資料庫活動流的模式(sync 或 async)__meta_rds_instance_activity_stream_policy_status:資料庫活動流的策略狀態__meta_rds_instance_activity_stream_status:資料庫活動流的狀態__meta_rds_instance_allocated_storage:已分配的儲存大小,以吉位元組(GiB)為單位__meta_rds_instance_arn:資料庫例項的 Amazon 資源名稱(ARN)__meta_rds_instance_auto_minor_version_upgrade:是否啟用了自動次要版本升級__meta_rds_instance_automatic_restart_time:已停止例項將自動重新啟動的時間__meta_rds_instance_automation_mode:例項的自動化模式__meta_rds_instance_availability_zone:資料庫例項的可用區__meta_rds_instance_aws_backup_recovery_point_arn:AWS Backup 中恢復點的 ARN__meta_rds_instance_backup_retention_period:自動備份的保留天數__meta_rds_instance_backup_target:備份目標(region 或 outposts)__meta_rds_instance_ca_certificate_identifier:資料庫例項的 CA 證書識別符號__meta_rds_instance_character_set_name:字元集名稱__meta_rds_instance_class:資料庫例項的計算和記憶體容量類__meta_rds_instance_copy_tags_to_snapshot:是否將標籤從例項複製到快照__meta_rds_instance_custom_iam_instance_profile:與底層 Amazon EC2 例項關聯的例項配置檔案__meta_rds_instance_customer_owned_ip_enabled:是否啟用了客戶擁有的 IP 地址 (CoIP)__meta_rds_instance_database_insights_mode:Database Insights 的模式__meta_rds_instance_db_cluster_identifier:該例項所屬的資料庫叢集的識別符號__meta_rds_instance_db_name:資料庫名稱__meta_rds_instance_db_system_id:Oracle 系統 ID(Oracle SID)__meta_rds_instance_dedicated_log_volume:資料庫例項是否具有專用日誌卷__meta_rds_instance_deletion_protection:是否啟用了刪除保護__meta_rds_instance_endpoint_address:資料庫例項的 DNS 地址__meta_rds_instance_endpoint_hosted_zone_id:端點的 Route 53 託管區域 ID__meta_rds_instance_endpoint_port:資料庫例項監聽的埠__meta_rds_instance_engine_lifecycle_support:引擎生命週期支援值__meta_rds_instance_engine_version:資料庫引擎的版本__meta_rds_instance_engine:資料庫例項使用的資料庫引擎__meta_rds_instance_enhanced_monitoring_resource_arn:用於增強監控的 Amazon CloudWatch Logs 日誌流 ARN__meta_rds_instance_iam_database_authentication_enabled:是否啟用了 IAM 資料庫身份驗證__meta_rds_instance_identifier:資料庫例項的識別符號__meta_rds_instance_instance_create_time:資料庫例項的建立時間__meta_rds_instance_iops:預置 IOPS(每秒 I/O 操作次數)值__meta_rds_instance_is_cluster_writer:該例項是否為叢集寫入器(true/false)__meta_rds_instance_is_storage_config_upgrade_available:儲存配置升級是否可用__meta_rds_instance_kms_key_id:加密例項的 AWS KMS 金鑰識別符號__meta_rds_instance_latest_restorable_time:可以恢復資料庫的最晚時間__meta_rds_instance_license_model:許可模型資訊__meta_rds_instance_listener_endpoint_address:監聽器端點的 DNS 地址__meta_rds_instance_listener_endpoint_hosted_zone_id:監聽器端點的 Route 53 託管區域 ID__meta_rds_instance_listener_endpoint_port:監聽器端點監聽的埠__meta_rds_instance_master_username:主使用者名稱__meta_rds_instance_max_allocated_storage:儲存可自動擴充套件的上限(吉位元組)__meta_rds_instance_monitoring_interval:增強監控指標收集之間的間隔時間(秒)__meta_rds_instance_monitoring_role_arn:允許 RDS 向 CloudWatch 傳送增強監控指標的 IAM 角色 ARN__meta_rds_instance_multi_az:資料庫例項是否為多可用區(Multi-AZ)部署__meta_rds_instance_multi_tenant:例項是否處於多租戶配置中__meta_rds_instance_nchar_character_set_name:國家字元集名稱__meta_rds_instance_network_type:網路型別(IPV4 或 DUAL)__meta_rds_instance_percent_progress:資料庫例項操作的進度百分比__meta_rds_instance_performance_insights_enabled:是否啟用了 Performance Insights__meta_rds_instance_performance_insights_kms_key_id:用於加密 Performance Insights 資料的 AWS KMS 金鑰識別符號__meta_rds_instance_performance_insights_retention_period:Performance Insights 資料的保留期限__meta_rds_instance_port:資料庫例項監聽的埠__meta_rds_instance_preferred_backup_window:建立自動備份的每日時間範圍__meta_rds_instance_preferred_maintenance_window:可以進行系統維護的每週時間範圍__meta_rds_instance_promotion_tier:故障後 Aurora 副本提升為主例項的順序__meta_rds_instance_publicly_accessible:資料庫例項是否公開可訪問__meta_rds_instance_read_replica_source_db_cluster_identifier:如果該例項是隻讀副本,則為其源資料庫叢集的識別符號__meta_rds_instance_read_replica_source_db_instance_identifier:如果該例項是隻讀副本,則為其源資料庫例項的識別符號__meta_rds_instance_replica_mode:副本模式(open-read-only 或 mounted)__meta_rds_instance_resource_id:資料庫例項的 AWS 區域內唯一的不可變識別符號__meta_rds_instance_resume_full_automation_mode_time:資料庫例項恢復完全自動化模式的時間__meta_rds_instance_secondary_availability_zone:多可用區例項的備用可用區__meta_rds_instance_status:資料庫例項的狀態__meta_rds_instance_storage_encrypted:資料庫例項是否對儲存進行了加密__meta_rds_instance_storage_encryption_type:儲存加密型別__meta_rds_instance_storage_throughput:儲存吞吐量,以 MiBps 為單位__meta_rds_instance_storage_type:儲存型別__meta_rds_instance_storage_volume_status:儲存卷的狀態__meta_rds_instance_subnet_group:與資料庫例項關聯的子網組名稱__meta_rds_instance_tag_<tagkey>:資料庫例項的每個標籤值__meta_rds_instance_tde_credential_arn:TDE 加密金鑰的 ARN__meta_rds_instance_timezone:資料庫例項的時區__meta_rds_instance_upgrade_rollout_order:升級釋出順序
有關 AWS 發現的配置選項,請參見下文
# The AWS role to use for service discovery.
# Must be one of: ec2, lightsail, ecs, msk, elasticache, or rds.
role: <string>
# The AWS region. If blank, the region from the instance metadata is used.
[ region: <string> ]
# Custom endpoint to be used.
[ endpoint: <string> ]
# AWS access key ID. If blank, the environment variable AWS_ACCESS_KEY_ID is used.
[ access_key: <string> ]
# AWS secret access key. If blank, the environment variable AWS_SECRET_ACCESS_KEY is used.
[ secret_key: <secret> ]
# Named AWS profile used to authenticate.
[ profile: <string> ]
# AWS Role ARN, an alternative to using AWS API keys.
[ role_arn: <string> ]
# Optional External ID that can go along with role_arn.
[ external_id: <string> ]
# Refresh interval to re-read the targets list.
[ refresh_interval: <duration> | default = 60s ]
# The port to scrape metrics from. If using the public IP address, this must
# instead be specified in the relabeling rule.
[ port: <int> | default = 80 ]
# Filters can be used optionally to filter the instance list by other criteria (ec2 & rds role only).
# Available filter criteria can be found here:
# EC2:
# - https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html
# - Filter API documentation: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_Filter.html
# RDS:
# - https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeDBInstances.html
# - Filter API documentation: https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_Filter.html
filters:
[ - name: <string>
values: <string>, [...] ]
# List of ECS, ElastiCache, MSK, or RDS cluster identifiers (ecs, elasticache, msk, and rds roles only) to discover.
# A List of ARNs of clusters to discover. If empty, all clusters in the region are discovered.
# This can significantly improve performance when you only need to monitor specific clusters/caches.
[ clusters: [<string>, ...] ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
<azure_sd_config>
Azure 服務發現(SD)配置允許從 Azure 虛擬機器(VM)檢索抓取目標。
此發現至少需要以下許可權
Microsoft.Compute/virtualMachines/read:VM 發現所需Microsoft.Network/networkInterfaces/read:VM 發現所需Microsoft.Compute/virtualMachineScaleSets/virtualMachines/read:規模集(VMSS)發現所需Microsoft.Compute/virtualMachineScaleSets/virtualMachines/networkInterfaces/read:規模集(VMSS)發現所需
在重新標記期間,目標上可以使用以下元標籤
__meta_azure_machine_id:機器 ID__meta_azure_machine_location:機器執行的位置__meta_azure_machine_name:機器名稱__meta_azure_machine_computer_name:機器的計算機名稱__meta_azure_machine_os_type:機器作業系統__meta_azure_machine_private_ip:機器的私有 IP__meta_azure_machine_public_ip:機器的公共 IP(如果存在)__meta_azure_machine_resource_group:機器的資源組__meta_azure_machine_tag_<tagname>:機器的每個標籤值__meta_azure_machine_scale_set:虛擬機器所屬的規模集(scale set)名稱(僅在使用 規模集 時設定此值)__meta_azure_machine_size:機器大小__meta_azure_subscription_id:訂閱 ID__meta_azure_tenant_id:租戶 ID
有關 Azure 發現的配置選項,請參見下文
# The information to access the Azure API.
# The Azure environment.
[ environment: <string> | default = AzurePublicCloud ]
# The authentication method, either OAuth, ManagedIdentity or SDK.
# See https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview
# SDK authentication method uses environment variables by default.
# See https://learn.microsoft.com/en-us/azure/developer/go/azure-sdk-authentication
[ authentication_method: <string> | default = OAuth]
# The subscription ID. Always required.
subscription_id: <string>
# Optional tenant ID. Only required with authentication_method OAuth.
[ tenant_id: <string> ]
# Optional client ID. Only required with authentication_method OAuth.
[ client_id: <string> ]
# Optional client secret. Only required with authentication_method OAuth.
[ client_secret: <secret> ]
# Optional resource group name. Limits discovery to this resource group.
[ resource_group: <string> ]
# Refresh interval to re-read the instance list.
[ refresh_interval: <duration> | default = 300s ]
# The port to scrape metrics from. If using the public IP address, this must
# instead be specified in the relabeling rule.
[ port: <int> | default = 80 ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
<consul_sd_config>
Consul 服務發現(SD)配置允許從 Consul 的 服務目錄中檢索抓取目標。發現過程使用兩個 Consul API 端點
- Catalog API 用於列出服務(在
services為空、或者設定了tags或filter時使用)。 - Health API 用於檢索服務例項及其健康狀態。
由於這兩個 API 具有不同的過濾欄位模式(schema),Prometheus 為每個 API 暴露了獨立的過濾選項:filter 適用於 Catalog API,而 health_filter 適用於 Health API。例如,標籤在 Catalog API 中暴露為 ServiceTags,但在 Health API 中暴露為 Service.Tags。
在重新標記期間,目標上可以使用以下元標籤
__meta_consul_address:目標的地址__meta_consul_dc:目標的控制中心(datacenter)名稱__meta_consul_health:服務的健康狀態__meta_consul_partition:服務註冊的管理分割槽(admin partition)名稱__meta_consul_metadata_<key>:目標的每個節點元資料鍵值對__meta_consul_node:為目標定義的節點名稱__meta_consul_service_address:服務的目標服務地址__meta_consul_service_id:服務的目標服務 ID__meta_consul_service_metadata_<key>:目標的每個服務元資料鍵值對__meta_consul_service_port:服務的目標服務埠__meta_consul_service:目標所屬的服務名稱__meta_consul_tagged_address_<key>:目標的每個節點標記地址(tagged address)鍵值對__meta_consul_tags:以標籤分隔符連線的目標標籤列表
# The information to access the Consul API. It is to be defined
# as the Consul documentation requires.
[ server: <host> | default = "localhost:8500" ]
# Prefix for URIs for when consul is behind an API gateway (reverse proxy).
[ path_prefix: <string> ]
[ token: <secret> ]
[ datacenter: <string> ]
# Namespaces are only supported in Consul Enterprise.
[ namespace: <string> ]
# Admin Partitions are only supported in Consul Enterprise.
[ partition: <string> ]
[ scheme: <string> | default = "http" ]
# The username and password fields are deprecated in favor of the basic_auth configuration.
[ username: <string> ]
[ password: <secret> ]
# A list of services for which targets are retrieved. If omitted, all services
# are scraped.
services:
[ - <string> ]
# Filter expression for the Catalog API. See https://developer.hashicorp.com/consul/api-docs/catalog#filtering for syntax.
[ filter: <string> ]
# Filter expression for the Health API. See https://developer.hashicorp.com/consul/api-docs/health#filtering for syntax.
[ health_filter: <string> ]
# The `tags` and `node_meta` fields are deprecated in favor of `filter` and `health_filter`.
# An optional list of tags used to filter nodes for a given service. Services must contain all tags in the list.
tags:
[ - <string> ]
# Node metadata key/value pairs to filter nodes for a given service. As of Consul 1.14, consider `filter` or `health_filter` instead.
[ node_meta:
[ <string>: <string> ... ] ]
# The string by which Consul tags are joined into the tag label.
[ tag_separator: <string> | default = , ]
# Allow stale Consul results (see https://www.consul.io/api/features/consistency.html). Will reduce load on Consul.
[ allow_stale: <boolean> | default = true ]
# The time after which the provided names are refreshed.
# On large setup it might be a good idea to increase this value because the catalog will change all the time.
[ refresh_interval: <duration> | default = 30s ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
請注意,用於抓取目標的 IP 地址和埠會組裝為 <__meta_consul_address>:<__meta_consul_service_port>。但是,在某些 Consul 設定中,相關地址位於 __meta_consul_service_address 中。在這些情況下,您可以使用 重新標記(relabel) 功能來替換特殊的 __address__ 標籤。
重新標記階段 是基於任意標籤過濾服務或服務節點的首選且更強大的方式。對於擁有成千上萬服務的使用者,直接使用 Consul API 可能會更高效,該 API 提供了對節點過濾的基礎支援(目前可透過節點元資料和單個標籤進行過濾)。
<digitalocean_sd_config>
DigitalOcean 服務發現(SD)配置允許從 DigitalOcean 的 API 檢索抓取目標。該服務發現透過 role 引數支援多種角色。
可以配置以下 role 型別之一來發現目標
droplets
droplets 角色從 DigitalOcean Droplets 中發現目標。預設使用公網 IPv4 地址,但可以透過重新標記進行更改。
在重新標記期間,目標上可以使用以下元標籤
__meta_digitalocean_droplet_id:droplet 的 ID__meta_digitalocean_droplet_name:droplet 的名稱__meta_digitalocean_image:droplet 映象的縮略名(slug)__meta_digitalocean_image_name:droplet 映象的顯示名稱__meta_digitalocean_private_ipv4:droplet 的私有 IPv4 地址__meta_digitalocean_public_ipv4:droplet 的公共 IPv4 地址__meta_digitalocean_public_ipv6:droplet 的公共 IPv6 地址__meta_digitalocean_region:droplet 的地域(region)__meta_digitalocean_size:droplet 的規格(size)__meta_digitalocean_status:droplet 的狀態__meta_digitalocean_features:droplet 的特性列表(以逗號分隔)__meta_digitalocean_tags:droplet 的標籤列表(以逗號分隔)__meta_digitalocean_vpc:droplet 所屬 VPC 的 ID
databases
databases 角色從 DigitalOcean 託管資料庫中發現目標。
在重新標記期間,目標上可以使用以下元標籤
__meta_digitalocean_db_id:資料庫叢集的 ID__meta_digitalocean_db_name:資料庫叢集的名稱__meta_digitalocean_db_engine:資料庫叢集的引擎(例如pg、mysql、redis、mongodb)__meta_digitalocean_db_version:引擎版本__meta_digitalocean_db_status:資料庫叢集的狀態__meta_digitalocean_db_region:資料庫叢集的地域__meta_digitalocean_db_size:資料庫叢集的規格__meta_digitalocean_db_num_nodes:資料庫叢集中的節點數量__meta_digitalocean_db_host:資料庫叢集的公共主機地址__meta_digitalocean_db_private_host:資料庫叢集的私有主機地址__meta_digitalocean_db_tag_<tagname>:資料庫叢集的每個標籤,其值被設定為true
# The DigitalOcean role to use for service discovery.
# Must be one of: droplets or databases.
[ role: <string> | default = droplets ]
# The port to scrape metrics from.
[ port: <int> | default = 80 ]
# The time after which the targets are refreshed.
[ refresh_interval: <duration> | default = 60s ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
<docker_sd_config>
Docker 服務發現(SD)配置允許從 Docker Engine 主機中檢索抓取目標。
該服務發現可以發現“容器”,併為容器配置暴露的每個網路 IP 和埠建立一個目標。
可用的元資料標籤
__meta_docker_container_id:容器 ID__meta_docker_container_name:容器名稱__meta_docker_container_network_mode:容器的網路模式__meta_docker_container_label_<labelname>:容器的每個標籤,任何不支援的字元都會轉換為下劃線__meta_docker_network_id:網路 ID__meta_docker_network_name:網路名稱__meta_docker_network_ingress:網路是否為 ingress__meta_docker_network_internal:網路是否為內部網路__meta_docker_network_label_<labelname>:網路的每個標籤,任何不支援的字元都會轉換為下劃線__meta_docker_network_scope:網路的作用域__meta_docker_network_ip:容器在此網路中的 IP__meta_docker_port_private:容器上的埠__meta_docker_port_public:如果存在埠對映,則是外部埠__meta_docker_port_public_ip:如果存在埠對映,則是公共 IP
有關 Docker 發現的配置選項,請參見下文
# Address of the Docker daemon.
host: <string>
# The port to scrape metrics from, when `role` is nodes, and for discovered
# tasks and services that don't have published ports.
[ port: <int> | default = 80 ]
# The host to use if the container is in host networking mode.
[ host_networking_host: <string> | default = "localhost" ]
# Sort all non-nil networks in ascending order based on network name and
# get the first network if the container has multiple networks defined,
# thus avoiding collecting duplicate targets.
[ match_first_network: <boolean> | default = true ]
# Optional filters to limit the discovery process to a subset of available
# resources.
# The available filters are listed in the upstream documentation:
# https://docs.docker.com.tw/engine/api/v1.40/#operation/ContainerList
[ filters:
[ - name: <string>
values: <string>, [...] ]
# The time after which the containers are refreshed.
[ refresh_interval: <duration> | default = 60s ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
重新標記階段 是過濾容器的首選且更強大的方式。對於擁有成千上萬容器的使用者,直接使用具有過濾容器基礎支援(使用 filters)的 Docker API 可能會更高效。
關於如何為 Docker Engine 配置 Prometheus 的詳細示例,請參見 此 Prometheus 配置檔案示例 。
<dockerswarm_sd_config>
Docker Swarm 服務發現(SD)配置允許從 Docker Swarm 引擎中檢索抓取目標。
可以配置以下角色之一來發現目標
services
services 角色會發現所有 Swarm 服務 並將它們的埠暴露為目標。對於服務的每個已釋出埠,都會生成一個目標。如果服務沒有釋出任何埠,則會使用服務發現配置中定義的 port 引數為每個服務建立一個目標。
可用的元資料標籤
__meta_dockerswarm_service_id:服務 ID__meta_dockerswarm_service_name:服務名稱__meta_dockerswarm_service_mode:服務的模式__meta_dockerswarm_service_endpoint_port_name:端點埠的名稱(如果可用)__meta_dockerswarm_service_endpoint_port_publish_mode:端點埠的釋出模式__meta_dockerswarm_service_label_<labelname>:服務的每個標籤,任何不支援的字元都會轉換為下劃線__meta_dockerswarm_service_task_container_hostname:目標的容器主機名(如果可用)__meta_dockerswarm_service_task_container_image:目標的容器映象__meta_dockerswarm_service_updating_status:服務的更新狀態(如果可用)__meta_dockerswarm_network_id:網路 ID__meta_dockerswarm_network_name:網路名稱__meta_dockerswarm_network_ingress:網路是否為 ingress__meta_dockerswarm_network_internal:網路是否為內部網路__meta_dockerswarm_network_label_<labelname>:網路的每個標籤,任何不支援的字元都會轉換為下劃線__meta_dockerswarm_network_scope:網路的作用域
tasks
tasks 角色會發現所有 Swarm 任務 並將它們的埠暴露為目標。對於任務的每個已釋出埠,都會生成一個目標。如果任務沒有釋出 any 埠,則會使用服務發現配置中定義的 port 引數為每個任務建立一個目標。
可用的元資料標籤
__meta_dockerswarm_container_label_<labelname>:容器的每個標籤,任何不支援的字元都會轉換為下劃線__meta_dockerswarm_task_id:任務 ID__meta_dockerswarm_task_container_id:任務的容器 ID__meta_dockerswarm_task_desired_state:任務的期望狀態__meta_dockerswarm_task_slot:任務的槽位(slot)__meta_dockerswarm_task_state:任務的狀態__meta_dockerswarm_task_port_publish_mode:任務埠的釋出模式__meta_dockerswarm_service_id:服務 ID__meta_dockerswarm_service_name:服務名稱__meta_dockerswarm_service_mode:服務的模式__meta_dockerswarm_service_label_<labelname>:服務的每個標籤,任何不支援的字元都會轉換為下劃線__meta_dockerswarm_network_id:網路 ID__meta_dockerswarm_network_name:網路名稱__meta_dockerswarm_network_ingress:網路是否為 ingress__meta_dockerswarm_network_internal:網路是否為內部網路__meta_dockerswarm_network_label_<labelname>:網路的每個標籤,任何不支援的字元都會轉換為下劃線__meta_dockerswarm_network_label:網路的每個標籤,任何不支援的字元都會轉換為下劃線__meta_dockerswarm_network_scope:網路的作用域__meta_dockerswarm_node_id:節點 ID__meta_dockerswarm_node_hostname:節點的主機名__meta_dockerswarm_node_address:節點的地址__meta_dockerswarm_node_availability:節點的可用性__meta_dockerswarm_node_label_<labelname>:節點的每個標籤,任何不支援的字元都會轉換為下劃線__meta_dockerswarm_node_platform_architecture:節點的架構__meta_dockerswarm_node_platform_os:節點的作業系統__meta_dockerswarm_node_role:節點的角色__meta_dockerswarm_node_status:節點的狀態
對於使用 mode=host 釋出的埠,不會填充 __meta_dockerswarm_network_* 元資料標籤。
nodes
nodes 角色用於發現 Swarm 節點 。
可用的元資料標籤
__meta_dockerswarm_node_address:節點的地址__meta_dockerswarm_node_availability:節點的可用性__meta_dockerswarm_node_engine_version:節點引擎的版本__meta_dockerswarm_node_hostname:節點的主機名__meta_dockerswarm_node_id:節點 ID__meta_dockerswarm_node_label_<labelname>:節點的每個標籤,任何不支援的字元都會轉換為下劃線__meta_dockerswarm_node_manager_address:節點管理元件(manager)的地址__meta_dockerswarm_node_manager_leader:節點管理元件(manager)的領導者狀態(true 或 false)__meta_dockerswarm_node_manager_reachability:節點管理元件(manager)的可達性__meta_dockerswarm_node_platform_architecture:節點的架構__meta_dockerswarm_node_platform_os:節點的作業系統__meta_dockerswarm_node_role:節點的角色__meta_dockerswarm_node_status:節點的狀態
有關 Docker Swarm 發現的配置選項,請參見下文
# Address of the Docker daemon.
host: <string>
# Role of the targets to retrieve. Must be `services`, `tasks`, or `nodes`.
role: <string>
# The port to scrape metrics from, when `role` is nodes, and for discovered
# tasks and services that don't have published ports.
[ port: <int> | default = 80 ]
# Optional filters to limit the discovery process to a subset of available
# resources.
# The available filters are listed in the upstream documentation:
# Services: https://docs.docker.com.tw/engine/api/v1.40/#operation/ServiceList
# Tasks: https://docs.docker.com.tw/engine/api/v1.40/#operation/TaskList
# Nodes: https://docs.docker.com.tw/engine/api/v1.40/#operation/NodeList
[ filters:
[ - name: <string>
values: <string>, [...] ]
# The time after which the service discovery data is refreshed.
[ refresh_interval: <duration> | default = 60s ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
重新標記階段 是過濾任務、服務或節點的推薦且更強大的方式。對於擁有成千上萬任務的使用者,直接使用具有過濾節點基礎支援(使用 filters)的 Swarm API 可能會更高效。
關於如何為 Docker Swarm 配置 Prometheus 的詳細示例,請參見 此 Prometheus 配置檔案示例 。
<dns_sd_config>
基於 DNS 的服務發現配置允許指定一組 DNS 域名,這些域名會被定期查詢以發現目標列表。要聯絡的 DNS 伺服器是從 /etc/resolv.conf 中讀取的。
此服務發現方法僅支援基礎的 DNS A、AAAA、MX、NS 和 SRV 記錄查詢,不支援 RFC6763 中指定的先進 DNS-SD 方法。
在重新標記期間,目標上可以使用以下元標籤
__meta_dns_name:生成所發現目標的記錄名稱。__meta_dns_srv_record_target:SRV 記錄的目標(target)欄位__meta_dns_srv_record_port:SRV 記錄的埠(port)欄位__meta_dns_mx_record_target:MX 記錄的目標(target)欄位__meta_dns_ns_record_target:NS 記錄的目標(target)欄位
# A list of DNS domain names to be queried.
names:
[ - <string> ]
# The type of DNS query to perform. One of SRV, A, AAAA, MX or NS.
[ type: <string> | default = 'SRV' ]
# The port number used if the query type is not SRV.
[ port: <int>]
# The time after which the provided names are refreshed.
[ refresh_interval: <duration> | default = 30s ]
<ec2_sd_config>
EC2 服務發現(SD)配置允許從 AWS EC2 例項中檢索抓取目標。預設使用私網 IP 地址,但可以透過重新標記將其修改為公網 IP 地址。
所使用的 IAM 憑證必須擁有 ec2:DescribeInstances 許可權以發現抓取目標;如果您希望可用區 ID 作為標籤可用,還可以選擇性地擁有 ec2:DescribeAvailabilityZones 許可權(見下文)。
在重新標記期間,目標上可以使用以下元標籤
__meta_ec2_ami:EC2 亞馬遜系統映像(Amazon Machine Image)__meta_ec2_architecture:例項的架構__meta_ec2_availability_zone:例項執行所在的可用區__meta_ec2_availability_zone_id:例項執行所在的可用區 ID (需要ec2:DescribeAvailabilityZones)__meta_ec2_instance_id:EC2 例項 ID__meta_ec2_instance_lifecycle:EC2 例項的生命週期,僅針對 'spot'(競價例項)或 'scheduled'(計劃例項)設定,否則不存在__meta_ec2_instance_state:EC2 例項的狀態__meta_ec2_instance_type:EC2 例項的型別__meta_ec2_ipv6_addresses:分配給例項網路介面的 IPv6 地址的逗號分隔列表(如果存在)__meta_ec2_owner_id:擁有該 EC2 例項的 AWS 賬號 ID__meta_ec2_platform:作業系統平臺,在 Windows 伺服器上設定為 'windows',否則不存在__meta_ec2_default_ipv6_address:找到的第一個主 IPv6 地址(如果存在),否則為第一個非主 IPv6 地址(如果存在)__meta_ec2_primary_ipv6_addresses:例項的主 IPv6 地址的逗號分隔列表(如果存在)。該列表根據每個對應網路介面在掛載順序中的位置進行排序。__meta_ec2_primary_subnet_id:主網路介面的子網 ID(如果可用)__meta_ec2_private_dns_name:例項的私有 DNS 名稱(如果可用)__meta_ec2_private_ip:例項的私有 IP 地址(如果存在)__meta_ec2_public_dns_name:例項的公有 DNS 名稱(如果可用)__meta_ec2_public_ip:例項的公有 IP 地址(如果可用)__meta_ec2_region:例項所在的區域__meta_ec2_subnet_id:例項執行所在的子網 ID 的逗號分隔列表(如果可用)__meta_ec2_tag_<tagkey>:例項的每個標籤值__meta_ec2_vpc_id:例項執行所在的 VPC ID(如果可用)
有關 EC2 發現的配置選項,請參見下文
# The information to access the EC2 API.
# The AWS region. If blank, the region from the instance metadata is used.
[ region: <string> ]
# Custom endpoint to be used.
[ endpoint: <string> ]
# The AWS API keys. If blank, the environment variables `AWS_ACCESS_KEY_ID`
# and `AWS_SECRET_ACCESS_KEY` are used.
[ access_key: <string> ]
[ secret_key: <secret> ]
# Named AWS profile used to connect to the API.
[ profile: <string> ]
# AWS Role ARN, an alternative to using AWS API keys.
[ role_arn: <string> ]
# Optional External ID that can go along with role_arn.
[ external_id: <string> ]
# Refresh interval to re-read the instance list.
[ refresh_interval: <duration> | default = 60s ]
# The port to scrape metrics from. If using the public IP address, this must
# instead be specified in the relabeling rule.
[ port: <int> | default = 80 ]
# Filters can be used optionally to filter the instance list by other criteria.
# Available filter criteria can be found here:
# https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html
# Filter API documentation: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_Filter.html
filters:
[ - name: <string>
values: <string>, [...] ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
重新標記階段 是基於任意標籤過濾目標的推薦且更強大的方式。對於擁有成千上萬例項的使用者,直接使用支援過濾例項的 EC2 API 可能會更高效。
<openstack_sd_config>
OpenStack 服務發現(SD)配置允許從 OpenStack Nova 例項中檢索抓取目標。
可以配置以下 <openstack_role> 型別之一來發現目標
hypervisor
hypervisor 角色為每個 Nova 管理程式(hypervisor)節點發現一個目標。目標地址預設為管理程式的 host_ip 屬性。
在重新標記期間,目標上可以使用以下元標籤
__meta_openstack_hypervisor_host_ip:hypervisor 節點的 IP 地址。__meta_openstack_hypervisor_hostname:hypervisor 節點的名稱。__meta_openstack_hypervisor_id:hypervisor 節點的 ID。__meta_openstack_hypervisor_state:hypervisor 節點的狀態(state)。__meta_openstack_hypervisor_status:hypervisor 節點的狀態(status)。__meta_openstack_hypervisor_type:hypervisor 節點的型別。
instance
instance 角色為 Nova 例項的每個 network 介面發現一個目標。目標地址預設為網路介面的私有 IP 地址。
在重新標記期間,目標上可以使用以下元標籤
__meta_openstack_address_pool:私有 IP 地址的地址池。__meta_openstack_instance_flavor:OpenStack 例項的配置規格(flavor)名稱,如果名稱不可用,則為配置規格 ID。__meta_openstack_instance_id:OpenStack 例項 ID。__meta_openstack_instance_image:OpenStack 例項正在使用的映象 ID。__meta_openstack_instance_name:OpenStack 例項名稱。__meta_openstack_instance_status:OpenStack 例項的狀態。__meta_openstack_private_ip:OpenStack 例項的私有 IP。__meta_openstack_project_id:擁有此例項的專案(租戶)。__meta_openstack_public_ip:OpenStack 例項的公共 IP。__meta_openstack_tag_<key>:例項的每個元資料項,任何不支援的字元都會轉換為下劃線。__meta_openstack_user_id:擁有該租戶的使用者賬戶。
loadbalancer
loadbalancer 角色為每個帶有 PROMETHEUS 監聽器的 Octavia 負載均衡器發現一個目標。目標地址預設為負載均衡器的 VIP 地址。
在重新標記期間,目標上可以使用以下元標籤
__meta_openstack_loadbalancer_availability_zone:OpenStack 負載均衡器的可用區。__meta_openstack_loadbalancer_floating_ip:OpenStack 負載均衡器的浮動 IP。__meta_openstack_loadbalancer_id:OpenStack 負載均衡器 ID。__meta_openstack_loadbalancer_name:OpenStack 負載均衡器名稱。__meta_openstack_loadbalancer_provider:OpenStack 負載均衡器的 Octavia 提供者。__meta_openstack_loadbalancer_operating_status:OpenStack 負載均衡器的執行狀態。__meta_openstack_loadbalancer_provisioning_status:OpenStack 負載均衡器的配置狀態(provisioning status)。__meta_openstack_loadbalancer_tags:以逗號分隔的 OpenStack 負載均衡器的標籤。__meta_openstack_loadbalancer_vip:OpenStack 負載均衡器的 VIP。__meta_openstack_project_id:擁有此負載均衡器的專案(租戶)。
有關 OpenStack 發現的配置選項,請參見下文
# The information to access the OpenStack API.
# The OpenStack role of entities that should be discovered.
role: <openstack_role>
# The OpenStack Region.
region: <string>
# identity_endpoint specifies the HTTP endpoint that is required to work with
# the Identity API of the appropriate version. While it's ultimately needed by
# all of the identity services, it will often be populated by a provider-level
# function.
[ identity_endpoint: <string> ]
# username is required if using Identity V2 API. Consult with your provider's
# control panel to discover your account's username. In Identity V3, either
# userid or a combination of username and domain_id or domain_name are needed.
[ username: <string> ]
[ userid: <string> ]
# password for the Identity V2 and V3 APIs. Consult with your provider's
# control panel to discover your account's preferred method of authentication.
[ password: <secret> ]
# At most one of domain_id and domain_name must be provided if using username
# with Identity V3. Otherwise, either are optional.
[ domain_name: <string> ]
[ domain_id: <string> ]
# The project_id and project_name fields are optional for the Identity V2 API.
# Some providers allow you to specify a project_name instead of the project_id.
# Some require both. Your provider's authentication policies will determine
# how these fields influence authentication.
[ project_name: <string> ]
[ project_id: <string> ]
# The application_credential_id or application_credential_name fields are
# required if using an application credential to authenticate. Some providers
# allow you to create an application credential to authenticate rather than a
# password.
[ application_credential_name: <string> ]
[ application_credential_id: <string> ]
# The application_credential_secret field is required if using an application
# credential to authenticate.
[ application_credential_secret: <secret> ]
# Whether the service discovery should list all instances for all projects.
# It is only relevant for the 'instance' role and usually requires admin permissions.
[ all_tenants: <boolean> | default: false ]
# Refresh interval to re-read the instance list.
[ refresh_interval: <duration> | default = 60s ]
# The port to scrape metrics from. If using the public IP address, this must
# instead be specified in the relabeling rule.
[ port: <int> | default = 80 ]
# The availability of the endpoint to connect to. Must be one of public, admin or internal.
[ availability: <string> | default = "public" ]
# TLS configuration.
tls_config:
[ <tls_config> ]
<ovhcloud_sd_config>
OVHcloud 服務發現(SD)配置允許使用其 API 從 OVHcloud 的 專用伺服器 和 VPS 中檢索抓取目標。Prometheus 會定期檢查 REST 端點併為發現的每個伺服器建立一個目標。該角色會嘗試使用公網 IPv4 地址作為預設地址,如果沒有,則嘗試使用 IPv6 地址。這可以透過重新標記來更改。對於 OVHcloud 的 公共雲實例 ,您可以使用 openstack_sd_config。
VPS
__meta_ovhcloud_vps_cluster:伺服器所屬的叢集__meta_ovhcloud_vps_datacenter:伺服器所屬的資料中心__meta_ovhcloud_vps_disk:伺服器的磁碟__meta_ovhcloud_vps_display_name:伺服器的顯示名稱__meta_ovhcloud_vps_ipv4:伺服器的 IPv4 地址__meta_ovhcloud_vps_ipv6:伺服器的 IPv6 地址__meta_ovhcloud_vps_keymap:伺服器的 KVM 鍵盤佈局__meta_ovhcloud_vps_maximum_additional_ip:伺服器的最大附加 IP 數量__meta_ovhcloud_vps_memory_limit:伺服器的記憶體限制__meta_ovhcloud_vps_memory:伺服器的記憶體__meta_ovhcloud_vps_monitoring_ip_blocks:伺服器的監控 IP 塊__meta_ovhcloud_vps_name:伺服器的名稱__meta_ovhcloud_vps_netboot_mode:伺服器的網路引導(netboot)模式__meta_ovhcloud_vps_offer_type:伺服器的套餐型別__meta_ovhcloud_vps_offer:伺服器的套餐名稱__meta_ovhcloud_vps_state:伺服器的狀態__meta_ovhcloud_vps_vcore:伺服器的虛擬核心(vcore)數量__meta_ovhcloud_vps_version:伺服器的版本__meta_ovhcloud_vps_zone:伺服器的可用區(zone)
專用伺服器
__meta_ovhcloud_dedicated_server_commercial_range:伺服器的商用範圍型別__meta_ovhcloud_dedicated_server_datacenter:伺服器的資料中心__meta_ovhcloud_dedicated_server_ipv4:伺服器的 IPv4 地址__meta_ovhcloud_dedicated_server_ipv6:伺服器的 IPv6 地址__meta_ovhcloud_dedicated_server_link_speed:伺服器的鏈路速度__meta_ovhcloud_dedicated_server_name:伺服器的名稱__meta_ovhcloud_dedicated_server_no_intervention:伺服器是否停用了資料中心人工干預__meta_ovhcloud_dedicated_server_os:伺服器的作業系統__meta_ovhcloud_dedicated_server_rack:伺服器的機架__meta_ovhcloud_dedicated_server_reverse:伺服器的反向 DNS 名稱__meta_ovhcloud_dedicated_server_server_id:伺服器的 ID__meta_ovhcloud_dedicated_server_state:伺服器的狀態__meta_ovhcloud_dedicated_server_support_level:伺服器的支援級別
有關 OVHcloud 發現的配置選項,請參見下文
# Access key to use. https://api.ovh.com
application_key: <string>
application_secret: <secret>
consumer_key: <secret>
# Service of the targets to retrieve. Must be `vps` or `dedicated_server`.
service: <string>
# API endpoint. https://github.com/ovh/go-ovh#supported-apis
[ endpoint: <string> | default = "ovh-eu" ]
# Refresh interval to re-read the resources list.
[ refresh_interval: <duration> | default = 60s ]
<puppetdb_sd_config>
PuppetDB 服務發現(SD)配置允許從 PuppetDB 資源中檢索抓取目標。
此服務發現可以發現資源,併為 API 返回的每個資源建立一個目標。
資源地址是該資源的 certname,可以在 重新標記階段 中進行更改。
在重新標記期間,目標上可以使用以下元標籤
__meta_puppetdb_query:Puppet 查詢語言(PQL)查詢__meta_puppetdb_certname:與資源關聯的節點名稱__meta_puppetdb_resource:用於標識的資源型別、標題和引數的 SHA-1 雜湊值__meta_puppetdb_type:資源型別__meta_puppetdb_title:資源標題__meta_puppetdb_exported:資源是否已被匯出("true"或"false")__meta_puppetdb_tags:以逗號分隔的資源標籤列表__meta_puppetdb_file:宣告該資源的清單(manifest)檔案__meta_puppetdb_environment:與資源關聯的節點的環境__meta_puppetdb_parameter_<parametername>:資源的引數
有關 PuppetDB 發現的配置選項,請參見下文
# The URL of the PuppetDB root query endpoint.
url: <string>
# Puppet Query Language (PQL) query. Only resources are supported.
# https://puppet.com/docs/puppetdb/latest/api/query/v4/pql.html
query: <string>
# Whether to include the parameters as meta labels.
# Due to the differences between parameter types and Prometheus labels,
# some parameters might not be rendered. The format of the parameters might
# also change in future releases.
#
# Note: Enabling this exposes parameters in the Prometheus UI and API. Make sure
# that you don't have secrets exposed as parameters if you enable this.
[ include_parameters: <boolean> | default = false ]
# Refresh interval to re-read the resources list.
[ refresh_interval: <duration> | default = 60s ]
# The port to scrape metrics from.
[ port: <int> | default = 80 ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
關於如何使用 PuppetDB 配置 Prometheus 的詳細示例,請參見 此 Prometheus 配置檔案示例 。
<file_sd_config>
基於檔案的服務發現提供了一種更通用的方式來配置靜態目標,並可作為接入自定義服務發現機制的介面。
它讀取一組檔案,其中包含零個或多個 <static_config> 的列表。對所有已定義檔案的更改都會透過磁碟監聽(disk watches)進行檢測並立即應用。
在監聽這些單獨檔案的更改時,父目錄也會被隱式監聽。這是為了高效處理 原子重新命名 ,並檢測匹配配置的 glob 模式的新檔案。如果父目錄中包含大量其他檔案,這可能會引發問題,因為每一個其他檔案也會被監聽,即使與它們相關的事件並不相關。
檔案可以以 YAML 或 JSON 格式提供。只有那些能生成格式正確的(well-formed)目標組的更改才會生效。
檔案必須包含靜態配置列表,並使用以下格式
JSON
[
{
"targets": [ "<host>", ... ],
"labels": {
"<labelname>": "<labelvalue>", ...
}
},
...
]
YAML
- targets:
[ - '<host>' ]
labels:
[ <labelname>: <labelvalue> ... ]
作為備用方案,檔案內容也會在指定的重新整理間隔內定期重新讀取。
在重新標記階段,每個目標都有一個元標籤 __meta_filepath。其值設定為提取該目標的檔案路徑。
有一個與此發現機制相整合的整合列表。
# Patterns for files from which target groups are extracted.
files:
[ - <filename_pattern> ... ]
# Refresh interval to re-read the files.
[ refresh_interval: <duration> | default = 5m ]
其中 <檔名模式> 可以是以 .json、.yml 或 .yaml 結尾的路徑。路徑的最後一個片段可以包含單個 *,用於匹配任意字元序列,例如 my/path/tg_*.json。
<gce_sd_config>
GCE SD 配置允許從 GCP GCE 例項中獲取抓取目標。預設使用私有 IP 地址,但可以透過重新標記更改為公有 IP 地址。
在重新標記期間,目標上可以使用以下元標籤
__meta_gce_instance_id:例項的數字 ID__meta_gce_instance_name:例項的名稱__meta_gce_label_<標籤名>:例項的每個 GCE 標籤,任何不支援的字元都會被轉換為下劃線__meta_gce_machine_type:例項機器型別的完整或部分 URL__meta_gce_metadata_<名稱>:例項的每個元資料項__meta_gce_network:例項的網路 URL__meta_gce_private_ip:例項的私有 IP 地址__meta_gce_interface_ipv4_<名稱>:每個命名介面的 IPv4 地址__meta_gce_project:例項執行所在的 GCP 專案__meta_gce_public_ip:例項的公有 IP 地址(如果存在)__meta_gce_subnetwork:例項的子網 URL__meta_gce_tags:以逗號分隔的例項標籤列表__meta_gce_zone:例項執行所在的 GCE 區域 URL
有關 GCE 發現的配置選項,請參見下文
# The information to access the GCE API.
# The GCP Project
project: <string>
# The zone of the scrape targets. If you need multiple zones use multiple
# gce_sd_configs.
zone: <string>
# Filter can be used optionally to filter the instance list by other criteria
# Syntax of this filter string is described here in the filter query parameter section:
# https://cloud.google.com/compute/docs/reference/latest/instances/list
[ filter: <string> ]
# Refresh interval to re-read the instance list
[ refresh_interval: <duration> | default = 60s ]
# The port to scrape metrics from. If using the public IP address, this must
# instead be specified in the relabeling rule.
[ port: <int> | default = 80 ]
# The tag separator is used to separate the tags on concatenation
[ tag_separator: <string> | default = , ]
Google Cloud SDK 預設客戶端會透過在以下位置查詢來發現憑據,並優先使用找到的第一個位置
- 由
GOOGLE_APPLICATION_CREDENTIALS環境變數指定的 JSON 檔案 - 已知路徑
$HOME/.config/gcloud/application_default_credentials.json中的 JSON 檔案 - 從 GCE 元資料伺服器中獲取
如果 Prometheus 執行在 GCE 內部,則其執行例項關聯的服務賬戶應至少對計算資源擁有隻讀許可權。如果執行在 GCE 外部,請確保建立了適當的服務賬戶,並將憑證檔案放置在預期位置之一。
<hetzner_sd_config>
Hetzner SD 配置允許從 Hetzner Cloud API 和 Robot API 中獲取抓取目標。此服務發現預設使用公有 IPv4 地址,但可以透過重新標記進行更改,如 Prometheus hetzner-sd 配置檔案 中所示。
在重新標記期間,所有目標上都可以使用以下元標籤
__meta_hetzner_server_id:伺服器的 ID__meta_hetzner_server_name:伺服器的名稱__meta_hetzner_server_status:伺服器的狀態__meta_hetzner_public_ipv4:伺服器的公有 IPv4 地址__meta_hetzner_public_ipv6_network:伺服器的公有 IPv6 網路 (/64)
請注意,對於 robot 和 hcloud 角色,__meta_hetzner_datacenter 標籤已被廢棄
- 對於
robot角色,替代標籤為__meta_hetzner_robot_datacenter。 - 對於
hcloud角色,該標籤將在 2026 年 7 月 1 日後被移除。有關更多詳細資訊,請參閱變更日誌 。
以下標籤僅適用於 role 設定為 hcloud 的目標
__meta_hetzner_hcloud_image_name:伺服器的映象名稱__meta_hetzner_hcloud_image_description:伺服器映象的描述__meta_hetzner_hcloud_image_os_flavor:伺服器映象的作業系統類別__meta_hetzner_hcloud_image_os_version:伺服器映象的作業系統版本__meta_hetzner_hcloud_location:伺服器的位置__meta_hetzner_hcloud_location_network_zone: 伺服器的網路區域__meta_hetzner_hcloud_datacenter_location:伺服器的位置(已廢棄,建議使用__meta_hetzner_hcloud_location)__meta_hetzner_hcloud_datacenter_location_network_zone:伺服器的網路區域(已廢棄,建議使用__meta_hetzner_hcloud_location_network_zone)__meta_hetzner_hcloud_server_type:伺服器的型別__meta_hetzner_hcloud_cpu_cores:伺服器的 CPU 核心數__meta_hetzner_hcloud_cpu_type:伺服器的 CPU 型別(共享或獨佔)__meta_hetzner_hcloud_memory_size_gb:伺服器的記憶體大小(單位為 GB)__meta_hetzner_hcloud_disk_size_gb:伺服器的磁碟大小(單位為 GB)__meta_hetzner_hcloud_private_ipv4_<網路名稱>:伺服器在給定網路中的私有 IPv4 地址__meta_hetzner_hcloud_label_<標籤名>:伺服器的每個標籤,任何不支援的字元都會被轉換為下劃線__meta_hetzner_hcloud_labelpresent_<標籤名>:如果伺服器存在該標籤則為true,任何不支援的字元都會被轉換為下劃線
以下標籤僅適用於 role 設定為 robot 的目標
__meta_hetzner_robot_datacenter:伺服器的資料中心__meta_hetzner_robot_product:伺服器的產品型別__meta_hetzner_robot_cancelled:伺服器登出狀態
# The Hetzner role of entities that should be discovered.
# One of robot or hcloud.
role: <string>
# The port to scrape metrics from.
[ port: <int> | default = 80 ]
# The time after which the servers are refreshed.
[ refresh_interval: <duration> | default = 60s ]
# Label selector used to filter the servers when fetching them from the API. See https://docs.hetzner.cloud/#label-selector for more details.
# Only used when role is hcloud.
[ label_selector: <string> ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
<http_sd_config>
基於 HTTP 的服務發現提供了一種更通用的方式來配置靜態目標,並可作為接入自定義服務發現機制的介面。
它從包含零個或多個 <static_config> 列表的 HTTP 端點獲取目標。目標端點必須返回 HTTP 200 響應。HTTP 標頭 Content-Type 必須為 application/json,且主體必須是有效的 JSON。
響應主體示例
[
{
"targets": [ "<host>", ... ],
"labels": {
"<labelname>": "<labelvalue>", ...
}
},
...
]
端點會在指定的重新整理間隔內定期查詢。prometheus_sd_http_failures_total 計數器指標用於跟蹤重新整理失敗的次數。
在重新標記階段,每個目標都有一個元標籤 __meta_url。其值設定為提取該目標的 URL。
有一個與此發現機制相整合的整合列表。
# URL from which the targets are fetched.
url: <string>
# Refresh interval to re-query the endpoint.
[ refresh_interval: <duration> | default = 60s ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
<ionos_sd_config>
IONOS SD 配置允許從 IONOS Cloud API 中獲取抓取目標。此服務發現預設使用第一個網絡卡(NIC)的 IP 地址,但可以透過重新標記進行更改。在重新標記期間,所有目標上都可以使用以下元標籤
__meta_ionos_server_availability_zone:伺服器的可用區__meta_ionos_server_boot_cdrom_id:伺服器引導時所使用 CD-ROM 的 ID__meta_ionos_server_boot_image_id:伺服器引導時所使用引導映象或快照的 ID__meta_ionos_server_boot_volume_id:引導卷的 ID__meta_ionos_server_cpu_family:伺服器的 CPU 系列__meta_ionos_server_id:伺服器的 ID__meta_ionos_server_ip:分配給伺服器的所有 IP 的逗號分隔列表__meta_ionos_server_lifecycle:伺服器資源的生命週期狀態__meta_ionos_server_name:伺服器的名稱__meta_ionos_server_nic_ip_<網絡卡名稱>:按連線到伺服器的每個網絡卡(NIC)名稱分組的 IP 逗號分隔列表__meta_ionos_server_servers_id:伺服器所屬伺服器組的 ID__meta_ionos_server_state:伺服器的執行狀態__meta_ionos_server_type:伺服器的型別
# The unique ID of the data center.
datacenter_id: <string>
# The port to scrape metrics from.
[ port: <int> | default = 80 ]
# The time after which the servers are refreshed.
[ refresh_interval: <duration> | default = 60s ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
<kubernetes_sd_config>
Kubernetes SD 配置允許從 Kubernetes REST API 中獲取抓取目標,並始終與叢集狀態保持同步。
可以配置以下 role 型別之一來發現目標
node
node 角色發現叢集中每個節點的一個目標,其地址預設為 Kubelet 的 HTTP 埠。目標地址預設為 Kubernetes 節點物件中第一個存在的地址,地址型別順序為:NodeInternalIP、NodeExternalIP、NodeLegacyHostIP、NodeHostName。
可用的元資料標籤
__meta_kubernetes_node_name:節點物件的名稱。__meta_kubernetes_node_provider_id:雲服務商為節點物件定義的名稱。__meta_kubernetes_node_condition_<狀況型別>:對於 node.Status.Conditions 中的每個條目,生成一個狀況型別為小寫的標籤。可能的值為true、false或unknown。例如:__meta_kubernetes_node_condition_ready、__meta_kubernetes_node_condition_memorypressure、__meta_kubernetes_node_condition_diskpressure。__meta_kubernetes_node_label_<標籤名>:來自節點物件的每個標籤,任何不支援的字元都會被轉換為下劃線。__meta_kubernetes_node_labelpresent_<標籤名>:如果節點物件存在該標籤則為true,任何不支援的字元都會被轉換為下劃線。__meta_kubernetes_node_annotation_<註解名>:來自節點物件的每個註解。__meta_kubernetes_node_annotationpresent_<註解名>:如果節點物件存在該註解則為true。__meta_kubernetes_node_address_<地址型別>:每個節點地址型別中的第一個地址(如果存在)。
此外,節點的 instance 標籤將被設定為從 API 伺服器獲取的節點名稱。
service
service 角色為每個服務的每個服務埠發現一個目標。這對於服務的黑盒監控通常非常有用。地址將被設定為服務的 Kubernetes DNS 名稱及對應的服務埠。
可用的元資料標籤
__meta_kubernetes_namespace:服務物件的名稱空間。__meta_kubernetes_service_annotation_<註解名>:來自服務物件的每個註解。__meta_kubernetes_service_annotationpresent_<註解名>:如果服務物件存在該註解則為 "true"。__meta_kubernetes_service_cluster_ip:服務的叢集 IP 地址(不適用於 ExternalName 型別的服務)。__meta_kubernetes_service_loadbalancer_ip:負載均衡器的 IP 地址(適用於 LoadBalancer 型別的服務)。__meta_kubernetes_service_external_name:服務的 DNS 名稱(適用於 ExternalName 型別的服務)。__meta_kubernetes_service_label_<標籤名>:來自服務物件的每個標籤,任何不支援的字元都會被轉換為下劃線。__meta_kubernetes_service_labelpresent_<標籤名>:如果服務物件存在該標籤則為true,任何不支援的字元都會被轉換為下劃線。__meta_kubernetes_service_name:服務物件的名稱。__meta_kubernetes_service_port_name:目標服務埠的名稱。__meta_kubernetes_service_port_number:目標服務埠的埠號。__meta_kubernetes_service_port_protocol:目標服務埠的協議。__meta_kubernetes_service_type:服務的型別。
pod
pod 角色發現所有 Pod 並將其容器公開為目標。對於容器宣告的每個埠,都會生成一個目標。如果容器沒有指定埠,則會為每個容器建立一個無埠的目標,以便透過重新標記手動新增埠。
可用的元資料標籤
__meta_kubernetes_namespace:Pod 物件的名稱空間。__meta_kubernetes_pod_name:Pod 物件的名稱。__meta_kubernetes_pod_ip:Pod 物件的 Pod IP。__meta_kubernetes_pod_label_<標籤名>:來自 Pod 物件的每個標籤,任何不支援的字元都會被轉換為下劃線。__meta_kubernetes_pod_labelpresent_<標籤名>:如果 Pod 物件存在該標籤則為true,任何不支援的字元都會被轉換為下劃線。__meta_kubernetes_pod_annotation_<註解名>:來自 Pod 物件的每個註解。__meta_kubernetes_pod_annotationpresent_<註解名>:如果 Pod 物件存在該註解則為true。__meta_kubernetes_pod_container_init:如果容器是 InitContainer(初始化容器) 則為true__meta_kubernetes_pod_container_name:目標地址指向的容器名稱。__meta_kubernetes_pod_container_id:目標地址指向的容器 ID。ID 格式為<型別>://<容器ID>。__meta_kubernetes_pod_container_image:容器正在使用的映象。__meta_kubernetes_pod_container_port_name:容器埠的名稱。__meta_kubernetes_pod_container_port_number:容器埠的埠號。__meta_kubernetes_pod_container_port_protocol:容器埠的協議。__meta_kubernetes_pod_ready:Pod 的就緒狀態,設定為true或false。__meta_kubernetes_pod_phase:在生命週期 中設定為Pending、Running、Succeeded、Failed或Unknown。__meta_kubernetes_pod_node_name:排程該 Pod 的節點名稱。__meta_kubernetes_pod_host_ip:Pod 物件的當前主機 IP。__meta_kubernetes_pod_uid:Pod 物件的 UID。__meta_kubernetes_pod_controller_kind:Pod 控制器的物件型別。__meta_kubernetes_pod_controller_name:Pod 控制器的名稱。__meta_kubernetes_pod_deployment_name:Pod 所屬的 Deployment 名稱。需要設定attach_metadata: {deployment: true}。__meta_kubernetes_pod_cronjob_name:Pod 所屬的 CronJob 名稱。需要設定attach_metadata: {cronjob: true}。__meta_kubernetes_pod_job_name:Pod 所屬的 Job 名稱。需要設定attach_metadata: {job: true}。
endpoints
endpoints 角色從服務列出的端點(Endpoint)中發現目標。對於每個端點地址,每個埠都會發現一個目標。如果端點背後有 Pod 支援,則該 Pod 中未繫結到端點埠的所有其他容器埠也會被發現為目標。
請注意,Endpoints API 在 Kubernetes v1.33+ 中已被廢棄 ,建議改用 EndpointSlice 並切換到下文的 endpointslice 角色。
可用的元資料標籤
__meta_kubernetes_namespace:Endpoints 物件的名稱空間。__meta_kubernetes_endpoints_name:Endpoints 物件的名稱。__meta_kubernetes_endpoints_label_<標籤名>:來自 Endpoints 物件的每個標籤,任何不支援的字元都會被轉換為下劃線。__meta_kubernetes_endpoints_labelpresent_<標籤名>:如果 Endpoints 物件存在該標籤則為true,任何不支援的字元都會被轉換為下劃線。__meta_kubernetes_endpoints_annotation_<註解名>:來自 Endpoints 物件的每個註解。__meta_kubernetes_endpoints_annotationpresent_<註解名>:如果 Endpoints 物件存在該註解則為true。- 對於直接從端點列表中發現的所有目標(不包括從底層 Pod 額外推斷出的目標),將附加以下標籤:
__meta_kubernetes_endpoint_hostname:端點的主機名。__meta_kubernetes_endpoint_node_name:託管該端點的節點名稱。__meta_kubernetes_endpoint_ready:端點的就緒狀態,設定為true或false。__meta_kubernetes_endpoint_port_name:端點埠的名稱。__meta_kubernetes_endpoint_port_protocol:端點埠的協議。__meta_kubernetes_endpoint_address_target_kind:端點地址目標的型別。__meta_kubernetes_endpoint_address_target_name:端點地址目標的名稱。
- 如果端點屬於某個服務,則會附加
role: service發現的所有標籤。 - 對於由 Pod 支援的所有目標,將附加
role: pod發現的所有標籤。
endpointslice
endpointslice 角色從現有的 EndpointSlice 中發現目標。對於 EndpointSlice 物件中引用的每個端點地址,都會發現一個目標。如果端點由 Pod 支援,則該 Pod 中未繫結到端點埠的所有其他容器埠也會被發現為目標。
該角色需要 discovery.k8s.io/v1 API 版本(自 Kubernetes v1.21 起可用)。
可用的元資料標籤
__meta_kubernetes_namespace:EndpointSlice 物件的名稱空間。__meta_kubernetes_endpointslice_name:EndpointSlice 物件的名稱。__meta_kubernetes_endpointslice_label_<標籤名>:來自 EndpointSlice 物件的每個標籤,任何不支援的字元都會被轉換為下劃線。__meta_kubernetes_endpointslice_labelpresent_<標籤名>:如果 EndpointSlice 物件存在該標籤則為true,任何不支援的字元都會被轉換為下劃線。__meta_kubernetes_endpointslice_annotation_<註解名>:來自 EndpointSlice 物件的每個註解。__meta_kubernetes_endpointslice_annotationpresent_<註解名>:如果 EndpointSlice 物件存在該註解則為true。- 對於直接從 EndpointSlice 列表中發現的所有目標(不包括從底層 Pod 額外推斷出的目標),將附加以下標籤:
__meta_kubernetes_endpointslice_address_target_kind:所引用物件的型別。__meta_kubernetes_endpointslice_address_target_name:所引用物件的名稱。__meta_kubernetes_endpointslice_address_type:目標地址的 IP 協議系列。__meta_kubernetes_endpointslice_endpoint_conditions_ready:所引用端點的就緒狀態,設定為true或false。__meta_kubernetes_endpointslice_endpoint_conditions_serving:所引用端點的提供服務狀態,設定為true或false。__meta_kubernetes_endpointslice_endpoint_conditions_terminating:所引用端點的終止狀態,設定為true或false。__meta_kubernetes_endpointslice_endpoint_topology_kubernetes_io_hostname:託管所引用端點的節點名稱。__meta_kubernetes_endpointslice_endpoint_topology_present_kubernetes_io_hostname:該標誌指示所引用物件是否具有 kubernetes.io/hostname 註解。__meta_kubernetes_endpointslice_endpoint_hostname:所引用端點的主機名。__meta_kubernetes_endpointslice_endpoint_node_name:託管所引用端點的節點名稱。__meta_kubernetes_endpointslice_endpoint_zone:所引用端點所在的可用區。__meta_kubernetes_endpointslice_port:所引用端點的埠。__meta_kubernetes_endpointslice_port_name:所引用端點的命名埠。__meta_kubernetes_endpointslice_port_protocol:所引用端點的協議。
- 如果端點屬於某個服務,則會附加
role: service發現的所有標籤。 - 對於由 Pod 支援的所有目標,將附加
role: pod發現的所有標籤。
ingress
ingress 角色為每個 Ingress 的每個路徑發現一個目標。這對於 Ingress 的黑盒監控通常非常有用。地址將被設定為 Ingress 規範中指定的主機。
該角色需要 networking.k8s.io/v1 API版本(自 Kubernetes v1.19 起可用)。
可用的元資料標籤
__meta_kubernetes_namespace:Ingress 物件的名稱空間。__meta_kubernetes_ingress_name:Ingress 物件的名稱。__meta_kubernetes_ingress_label_<標籤名>:來自 Ingress 物件的每個標籤,任何不支援的字元都會被轉換為下劃線。__meta_kubernetes_ingress_labelpresent_<標籤名>:如果 Ingress 物件存在該標籤則為true,任何不支援的字元都會被轉換為下劃線。__meta_kubernetes_ingress_annotation_<註解名>:來自 Ingress 物件的每個註解。__meta_kubernetes_ingress_annotationpresent_<註解名>:如果 Ingress 物件存在該註解則為true。__meta_kubernetes_ingress_class_name:Ingress 規範中的類名(如果存在)。__meta_kubernetes_ingress_scheme:Ingress 的協議方案,如果設定了 TLS 配置,則為https。預設為http。__meta_kubernetes_ingress_path:Ingress 規範中的路徑。預設為/。
有關 Kubernetes 發現的配置選項,請參見下文
# The information to access the Kubernetes API.
# The API server addresses. If left empty, Prometheus is assumed to run inside
# of the cluster and will discover API servers automatically and use the pod's
# CA certificate and bearer token file at /var/run/secrets/kubernetes.io/serviceaccount/.
[ api_server: <host> ]
# The Kubernetes role of entities that should be discovered.
# One of endpoints, endpointslice, service, pod, node, or ingress.
role: <string>
# Optional path to a kubeconfig file.
# Note that api_server and kube_config are mutually exclusive.
[ kubeconfig_file: <filename> ]
# Optional namespace discovery. If omitted, all namespaces are used.
namespaces:
own_namespace: <boolean>
names:
[ - <string> ]
# Optional label and field selectors to limit the discovery process to a subset of available resources.
# See https://kubernetes.club.tw/docs/concepts/overview/working-with-objects/field-selectors/
# and https://kubernetes.club.tw/docs/concepts/overview/working-with-objects/labels/ to learn more about the possible
# filters that can be used. The endpoints role supports pod, service and endpoints selectors.
# The pod role supports node selectors when configured with `attach_metadata: {node: true}`.
# Other roles only support selectors matching the role itself (e.g. node role can only contain node selectors).
# Note: When making decision about using field/label selector make sure that this
# is the best approach - it will prevent Prometheus from reusing single list/watch
# for all scrape configs. This might result in a bigger load on the Kubernetes API,
# because per each selector combination there will be additional LIST/WATCH. On the other hand,
# if you just want to monitor small subset of pods in large cluster it's recommended to use selectors.
# Decision, if selectors should be used or not depends on the particular situation.
[ selectors:
[ - role: <string>
[ label: <string> ]
[ field: <string> ] ]]
# Optional metadata to attach to discovered targets. If omitted, no additional metadata is attached.
attach_metadata:
# Attaches node metadata to discovered targets. Valid for roles: pod, endpoints, endpointslice.
# When set to true, Prometheus must have permissions to list/watch Nodes.
[ node: <boolean> | default = false ]
# Attaches namespace metadata to discovered targets. Valid for roles: pod, endpoints, endpointslice, service, ingress.
# When set to true, Prometheus must have permissions to list/watch Namespaces.
[ namespace: <boolean> | default = false ]
# Attaches deployment metadata to discovered pod targets. Valid for role: pod.
# When set to true, Prometheus must have permissions to list/watch ReplicaSets.
# Enables the __meta_kubernetes_pod_deployment_name label.
[ deployment: <boolean> | default = false ]
# Attaches job metadata to discovered pod targets. Valid for role: pod.
# When set to true, Prometheus must have permissions to list/watch Jobs.
# Enables the __meta_kubernetes_pod_job_name label.
[ job: <boolean> | default = false ]
# Attaches cronjob metadata to discovered pod targets. Valid for role: pod.
# When set to true, Prometheus must have permissions to list/watch Jobs.
# Enables the __meta_kubernetes_pod_cronjob_name label.
[ cronjob: <boolean> | default = false ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
有關配置 Prometheus 以適應 Kubernetes 的詳細示例,請參見此 Prometheus 配置檔案示例 。
您可能還希望瞭解第三方專案 Prometheus Operator ,它可以在 Kubernetes 之上自動執行 Prometheus 設定。
<kuma_sd_config>
Kuma SD 配置允許從 Kuma 控制平面獲取抓取目標。
此 SD 透過 MADS v1 (監控分配發現服務) xDS API 發現基於 Kuma 資料平面代理(Dataplane Proxy) 的“監控分配”,並將為啟用了 Prometheus 的網格內的每個代理建立一個目標。
每個目標都可以使用以下元標籤
__meta_kuma_mesh:代理網格(Mesh)的名稱__meta_kuma_dataplane:代理的名稱__meta_kuma_service:代理關聯服務的名稱__meta_kuma_label_<標籤名>:代理的每個標籤
有關 Kuma MonitoringAssignment 發現的配置選項,請參見下文
# Address of the Kuma Control Plane's MADS xDS server.
server: <string>
# Client id is used by Kuma Control Plane to compute Monitoring Assignment for specific Prometheus backend.
# This is useful when migrating between multiple Prometheus backends, or having separate backend for each Mesh.
# When not specified, system hostname/fqdn will be used if available, if not `prometheus` will be used.
[ client_id: <string> ]
# The time to wait between polling update requests.
[ refresh_interval: <duration> | default = 30s ]
# The time after which the monitoring assignments are refreshed.
[ fetch_timeout: <duration> | default = 2m ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
重新標記階段是過濾代理和使用者自定義標籤的首選且更強大的方式。
<lightsail_sd_config>
Lightsail SD 配置允許從 AWS Lightsail 例項獲取抓取目標。預設使用私有 IP 地址,但可以透過重新標記更改為公有 IP 地址。
在重新標記期間,目標上可以使用以下元標籤
__meta_lightsail_availability_zone:例項執行所在的可用區__meta_lightsail_blueprint_id:Lightsail 藍圖 ID__meta_lightsail_bundle_id:Lightsail 套餐 ID__meta_lightsail_instance_name:Lightsail 例項的名稱__meta_lightsail_instance_state:Lightsail 例項的狀態__meta_lightsail_instance_support_code:Lightsail 例項的支援程式碼__meta_lightsail_ipv6_addresses:分配給例項網路介面的 IPv6 地址的逗號分隔列表(如果存在)__meta_lightsail_private_ip:例項的私有 IP 地址__meta_lightsail_public_ip:例項的公有 IP 地址(如果可用)__meta_lightsail_region:例項所在的區域__meta_lightsail_tag_<tagkey>:例項的每個標籤值
有關 Lightsail 發現的配置選項,請參見下文
# The information to access the Lightsail API.
# The AWS region. If blank, the region from the instance metadata is used.
[ region: <string> ]
# Custom endpoint to be used.
[ endpoint: <string> ]
# The AWS API keys. If blank, the environment variables `AWS_ACCESS_KEY_ID`
# and `AWS_SECRET_ACCESS_KEY` are used.
[ access_key: <string> ]
[ secret_key: <secret> ]
# Named AWS profile used to connect to the API.
[ profile: <string> ]
# AWS Role ARN, an alternative to using AWS API keys.
[ role_arn: <string> ]
# Optional External ID that can go along with role_arn.
[ external_id: <string> ]
# Refresh interval to re-read the instance list.
[ refresh_interval: <duration> | default = 60s ]
# The port to scrape metrics from. If using the public IP address, this must
# instead be specified in the relabeling rule.
[ port: <int> | default = 80 ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
<linode_sd_config>
Linode SD 配置允許從 Linode 的 Linode APIv4 獲取抓取目標。此服務發現預設使用公有 IPv4 地址,但可以透過重新標記進行更改,如 Prometheus linode-sd 配置檔案 中所示。
建立 Linode APIv4 令牌(Token)時必須包含以下範圍(Scope):linodes:read_only、ips:read_only 以及 events:read_only。
在重新標記期間,目標上可以使用以下元標籤
__meta_linode_instance_id:Linode 例項的 ID__meta_linode_instance_label:Linode 例項的標籤__meta_linode_image:Linode 例項映象的別名 (slug)__meta_linode_private_ipv4:Linode 例項的私有 IPv4 地址__meta_linode_public_ipv4:Linode 例項的公有 IPv4 地址__meta_linode_public_ipv6:Linode 例項的公有 IPv6 地址__meta_linode_private_ipv4_rdns:Linode 例項第一個私有 IPv4 地址的反向 DNS__meta_linode_public_ipv4_rdns:Linode 例項第一個公有 IPv4 地址的反向 DNS__meta_linode_public_ipv6_rdns:Linode 例項第一個公有 IPv6 地址的反向 DNS__meta_linode_region:Linode 例項的地域 (region)__meta_linode_type:Linode 例項的型別__meta_linode_status:Linode 例項的狀態__meta_linode_tags:Linode 例項的標籤列表,由標籤分隔符連線__meta_linode_group:Linode 例項所屬的顯示組__meta_linode_gpus:Linode 例項的 GPU 數量__meta_linode_hypervisor:驅動 Linode 例項的虛擬化軟體__meta_linode_backups:Linode 例項的備份服務狀態__meta_linode_specs_disk_bytes:Linode 例項可訪問的儲存空間大小(位元組)__meta_linode_specs_memory_bytes:Linode 例項可訪問的記憶體大小(位元組)__meta_linode_specs_vcpus:此 Linode 例項可訪問的 VCPU 數量__meta_linode_specs_transfer_bytes:Linode 例項每月分配的網路流量(位元組)__meta_linode_extra_ips:分配給 Linode 例項的所有額外 IPv4 地址的列表,由標籤分隔符連線__meta_linode_ipv6_ranges:分配給 Linode 例項並帶掩碼的 IPv6 範圍列表,由標籤分隔符連線
# Optional region to filter on.
[ region: <string> ]
# The port to scrape metrics from.
[ port: <int> | default = 80 ]
# The string by which Linode Instance tags are joined into the tag label.
[ tag_separator: <string> | default = , ]
# The time after which the linode instances are refreshed.
[ refresh_interval: <duration> | default = 60s ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
<marathon_sd_config>
Marathon SD 配置允許使用 Marathon REST API 獲取抓取目標。Prometheus 會定期檢查 REST 端點中當前正在執行的任務,併為至少包含一個健康任務的每個應用(App)建立一個目標組。
在重新標記期間,目標上可以使用以下元標籤
__meta_marathon_app:應用的名稱(斜槓會被替換為連字元)__meta_marathon_image:所使用的 Docker 映象名稱(如果可用)__meta_marathon_task:Mesos 任務的 ID__meta_marathon_app_label_<標籤名>:附加到應用的任何 Marathon 標籤,任何不支援的字元都會被轉換為下劃線__meta_marathon_port_definition_label_<標籤名>:埠定義標籤,任何不支援的字元都會被轉換為下劃線__meta_marathon_port_mapping_label_<標籤名>:埠對映標籤,任何不支援的字元都會被轉換為下劃線__meta_marathon_port_index:埠索引號(例如PORT1對應1)
有關 Marathon 發現的配置選項,請參見下文
# List of URLs to be used to contact Marathon servers.
# You need to provide at least one server URL.
servers:
- <string>
# Polling interval
[ refresh_interval: <duration> | default = 30s ]
# Optional authentication information for token-based authentication
# https://docs.mesosphere.com/1.11/security/ent/iam-api/#passing-an-authentication-token
# It is mutually exclusive with `auth_token_file` and other authentication mechanisms.
[ auth_token: <secret> ]
# Optional authentication information for token-based authentication
# https://docs.mesosphere.com/1.11/security/ent/iam-api/#passing-an-authentication-token
# It is mutually exclusive with `auth_token` and other authentication mechanisms.
[ auth_token_file: <filename> ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
預設情況下,Marathon 中列出的每個應用都會被 Prometheus 抓取。如果並非所有服務都提供 Prometheus 指標,您可以使用 Marathon 標籤和 Prometheus 重新標記來控制實際抓取哪些例項。有關如何設定 Marathon 應用和 Prometheus 配置的實際示例,請參見 Prometheus marathon-sd 配置檔案 。
預設情況下,所有應用在 Prometheus 中都會顯示為單個作業(Job)(即配置檔案中指定的作業),這也可以透過重新標記進行修改。
<nerve_sd_config>
Nerve SD 配置允許從儲存在 AirBnB Nerve 中的 Zookeeper 獲取抓取目標。
在重新標記期間,目標上可以使用以下元標籤
__meta_nerve_path:Zookeeper 中端點節點的完整路徑__meta_nerve_endpoint_host:端點的主機__meta_nerve_endpoint_port:端點的埠__meta_nerve_endpoint_name:端點的名稱
# The Zookeeper servers.
servers:
- <host>
# Paths can point to a single service, or the root of a tree of services.
paths:
- <string>
[ timeout: <duration> | default = 10s ]
<nomad_sd_config>
Nomad SD 配置允許從 Nomad Service API 獲取抓取目標。
在重新標記期間,目標上可以使用以下元標籤
__meta_nomad_address:目標的服務地址__meta_nomad_dc:目標的資料中心名稱__meta_nomad_namespace:目標的名稱空間__meta_nomad_node_id:為目標定義的節點名稱__meta_nomad_service:目標所屬服務的名稱__meta_nomad_service_address:目標的服務地址__meta_nomad_service_id:目標的服務 ID__meta_nomad_service_port:目標的服務埠__meta_nomad_tags:目標的標籤列表,由標籤分隔符連線
# The information to access the Nomad API. It is to be defined
# as the Nomad documentation requires.
[ allow_stale: <boolean> | default = true ]
[ namespace: <string> | default = default ]
[ refresh_interval: <duration> | default = 60s ]
[ region: <string> | default = global ]
# The URL to connect to the API.
[ server: <string> ]
[ tag_separator: <string> | default = ,]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
<serverset_sd_config>
Serverset SD 配置允許從儲存在 Serverset 中獲取抓取目標,該端點儲存於 Zookeeper 中。Serverset 通常由 Finagle 和 Aurora 使用。
在重新標記期間,目標上可以使用以下元標籤
__meta_serverset_path:Zookeeper 中 Serverset 成員節點的完整路徑__meta_serverset_endpoint_host:預設端點的主機__meta_serverset_endpoint_port:預設端點的埠__meta_serverset_endpoint_host_<端點>:給定端點的主機__meta_serverset_endpoint_port_<端點>:給定端點的埠__meta_serverset_shard:成員的分片號 (shard number)__meta_serverset_status:成員的狀態
# The Zookeeper servers.
servers:
- <host>
# Paths can point to a single serverset, or the root of a tree of serversets.
paths:
- <string>
[ timeout: <duration> | default = 10s ]
Serverset 資料必須採用 JSON 格式,目前不支援 Thrift 格式。
<stackit_sd_config>
STACKIT SD 配置允許從各種 API 獲取抓取目標。
在重新標記期間,目標上可以使用以下元標籤
__meta_stackit_availability_zone:伺服器的可用區。__meta_stackit_label_<標籤名>:每個伺服器標籤,不支援的字元會被替換為下劃線。__meta_stackit_labelpresent_<標籤名>:如果伺服器存在該標籤則為 "true",不支援的字元會被替換為下劃線。__meta_stackit_private_ipv4_<網路名稱>:伺服器在給定網路中的私有 IPv4 地址__meta_stackit_public_ipv4:伺服器的公有 IPv4 地址__meta_stackit_id:目標的 ID。__meta_stackit_type:目標的型別或品牌。__meta_stackit_name:伺服器名稱。__meta_stackit_status:伺服器當前的狀態。__meta_stackit_power_status:伺服器的電源狀態。
有關 STACKIT 發現的配置選項,請參見下文
# The STACKIT project
project: <string>
# STACKIT region to use. No automatic discovery of the region is done.
[ region : <string> | default = "eu01" ]
# Custom API endpoint to be used. Format scheme://host:port
[ endpoint : <string> ]
# The port to scrape metrics from.
[ port: <int> | default = 80 ]
# Raw private key string used for authenticating a service account
[ private_key: <string> ]
# Path to a file containing the raw private key string
[ private_key_path: <string> ]
# Full JSON-formatted service account key used for authentication
[ service_account_key: <string> ]
# Path to a file containing the JSON-formatted service account key
[ service_account_key_path: <string> ]
# Path to a file containing STACKIT credentials.
[ credentials_file_path: <string> ]
# The time after which the servers are refreshed.
[ refresh_interval: <duration> | default = 60s ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
可以透過 http_config 設定 服務賬戶金鑰(Service Account Key) 。這可以透過將 STACKIT 服務賬戶 JSON 中的值對映到 OAuth2 配置中來實現。
從給定的服務賬戶 JSON 中
{
//....
"credentials": {
"kid": "6a7c3b36-xxxxxxxx",
"iss": "[email protected]",
"sub": "af2c2336-xxxxxxxx",
"aud": "https://stackit-service-account-prod.apps.01.cf.eu01.stackit.cloud",
"privateKey": "-----BEGIN PRIVATE KEY-----xxxx"
}
}
屬性可以對映為
stackit_sd_config:
- oauth2:
client_id: <credentials.sub>
client_certificate_key: <credentials.privateKey>
client_certificate_key_id: <credentials.kid>
iss: <credentials.iss>
audience: <credentials.aud>
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer"
token_url: "https://service-account.api.stackit.cloud/token"
signature_algorithm: RS512
<triton_sd_config>
Triton SD 配置允許從 Container Monitor 發現端點獲取抓取目標。
可以配置以下 <triton_role> 型別之一來發現目標
container
container 角色為 account 擁有的每個“虛擬機器”發現一個目標。這些是 SmartOS 區域或 lx/KVM/bhyve 型別的區域。
在重新標記期間,目標上可以使用以下元標籤
__meta_triton_groups:屬於目標的組列表,以逗號分隔符連線__meta_triton_machine_alias:目標容器的別名__meta_triton_machine_brand:目標容器的品牌 (brand)__meta_triton_machine_id:目標容器的 UUID__meta_triton_machine_image:目標容器的映象型別__meta_triton_server_id:目標容器執行所在的伺服器 UUID
cn
cn 角色為構成 Triton 基礎設施的每個計算節點(也稱為“伺服器”或“全域性區域”)發現一個目標。account 必須是 Triton 運營商,並且目前要求至少擁有一個 container。
在重新標記期間,目標上可以使用以下元標籤
__meta_triton_machine_alias:目標的主機名(需要 triton-cmon 1.7.0 或更高版本)__meta_triton_machine_id:目標的 UUID
有關 Triton 發現的配置選項,請參見下文
# The information to access the Triton discovery API.
# The account to use for discovering new targets.
account: <string>
# The type of targets to discover, can be set to:
# * "container" to discover virtual machines (SmartOS zones, lx/KVM/bhyve branded zones) running on Triton
# * "cn" to discover compute nodes (servers/global zones) making up the Triton infrastructure
[ role : <string> | default = "container" ]
# The DNS suffix which should be applied to target.
dns_suffix: <string>
# The Triton discovery endpoint (e.g. 'cmon.us-east-3b.triton.zone'). This is
# often the same value as dns_suffix.
endpoint: <string>
# A list of groups for which targets are retrieved, only supported when `role` == `container`.
# If omitted all containers owned by the requesting account are scraped.
groups:
[ - <string> ... ]
# The port to use for discovery and metric scraping.
[ port: <int> | default = 9163 ]
# The interval which should be used for refreshing targets.
[ refresh_interval: <duration> | default = 60s ]
# The Triton discovery API version.
[ version: <int> | default = 1 ]
# TLS configuration.
tls_config:
[ <tls_config> ]
<eureka_sd_config>
Eureka SD 配置允許使用 Eureka REST API 獲取抓取目標。Prometheus 會定期檢查 REST 端點併為每個應用例項建立一個目標。
在重新標記期間,目標上可以使用以下元標籤
__meta_eureka_app_name:應用的名稱__meta_eureka_app_instance_id:應用例項的 ID__meta_eureka_app_instance_hostname:應用例項的主機名__meta_eureka_app_instance_homepage_url:應用例項的主頁 URL__meta_eureka_app_instance_statuspage_url:應用例項的狀態頁 URL__meta_eureka_app_instance_healthcheck_url:應用例項的健康檢查 URL__meta_eureka_app_instance_ip_addr:應用例項的 IP 地址__meta_eureka_app_instance_vip_address:應用例項的 VIP 地址__meta_eureka_app_instance_secure_vip_address:應用例項的安全 VIP 地址__meta_eureka_app_instance_status:應用例項的狀態__meta_eureka_app_instance_port:應用例項的埠__meta_eureka_app_instance_port_enabled:應用例項的埠是否啟用__meta_eureka_app_instance_secure_port:應用例項的安全埠地址__meta_eureka_app_instance_secure_port_enabled:應用例項的安全埠是否啟用__meta_eureka_app_instance_country_id:應用例項的國家 ID__meta_eureka_app_instance_metadata_<元資料名>:應用例項元資料__meta_eureka_app_instance_datacenterinfo_name:應用例項的資料中心名稱__meta_eureka_app_instance_datacenterinfo_<元資料名>:資料中心元資料
有關 Eureka 發現的配置選項,請參見下文
# The URL to connect to the Eureka server.
server: <string>
# Refresh interval to re-read the app instance list.
[ refresh_interval: <duration> | default = 30s ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
有關如何設定 Eureka 應用和 Prometheus 配置的實際示例,請參見 Prometheus eureka-sd 配置檔案 。
<scaleway_sd_config>
Scaleway SD 配置允許從 Scaleway 例項 和 裸金屬(baremetal)服務 獲取抓取目標。
在重新標記期間,目標上可以使用以下元標籤
例項角色
__meta_scaleway_instance_boot_type:伺服器的引導型別__meta_scaleway_instance_hostname:伺服器的主機名__meta_scaleway_instance_id:伺服器的 ID__meta_scaleway_instance_image_arch:伺服器映象的架構__meta_scaleway_instance_image_id:伺服器映象的 ID__meta_scaleway_instance_image_name:伺服器映象的名稱__meta_scaleway_instance_location_cluster_id:伺服器位置的叢集 ID__meta_scaleway_instance_location_hypervisor_id:伺服器位置的管理程式 (hypervisor) ID__meta_scaleway_instance_location_node_id:伺服器位置的節點 ID__meta_scaleway_instance_name:伺服器的名稱__meta_scaleway_instance_organization_id:伺服器的組織__meta_scaleway_instance_private_ipv4:伺服器的私有 IPv4 地址__meta_scaleway_instance_project_id:伺服器的專案 ID__meta_scaleway_instance_public_ipv4:伺服器的公有 IPv4 地址__meta_scaleway_instance_public_ipv6:伺服器的公有 IPv6 地址__meta_scaleway_instance_public_ipv4_addresses:伺服器的公有 IPv4 地址列表__meta_scaleway_instance_public_ipv6_addresses:伺服器的公有 IPv6 地址列表__meta_scaleway_instance_region:伺服器的地域__meta_scaleway_instance_security_group_id:伺服器安全組的 ID__meta_scaleway_instance_security_group_name:伺服器安全組的名稱__meta_scaleway_instance_status:伺服器的狀態__meta_scaleway_instance_tags:伺服器的標籤列表,由標籤分隔符連線__meta_scaleway_instance_type:伺服器的商用型別__meta_scaleway_instance_zone:伺服器的可用區(例如:fr-par-1,完整列表參見此處 )
該角色按以下順序使用它找到的第一個地址:私有 IPv4、公有 IPv4、公有 IPv6。這可以透過重新標記進行更改,如 Prometheus scaleway-sd 配置檔案 中所示。如果例項在重新標記之前沒有地址,它將不會被新增到目標列表中,並且您將無法對其進行重新標記。
裸金屬角色
__meta_scaleway_baremetal_id:伺服器的 ID__meta_scaleway_baremetal_public_ipv4:伺服器的公有 IPv4 地址__meta_scaleway_baremetal_public_ipv6:伺服器的公有 IPv6 地址__meta_scaleway_baremetal_name:伺服器的名稱__meta_scaleway_baremetal_os_name:伺服器作業系統的名稱__meta_scaleway_baremetal_os_version:伺服器作業系統的版本__meta_scaleway_baremetal_project_id:伺服器的專案 ID__meta_scaleway_baremetal_status:伺服器的狀態__meta_scaleway_baremetal_tags:伺服器的標籤列表,由標籤分隔符連線__meta_scaleway_baremetal_type:伺服器的商用型別__meta_scaleway_baremetal_zone:伺服器的可用區(例如:fr-par-1,完整列表參見此處 )
此角色預設使用公有 IPv4 地址。這可以透過重新標記進行更改,如 Prometheus scaleway-sd 配置檔案 中所示。
有關 Scaleway 發現的配置選項,請參見下文
# Access key to use. https://console.scaleway.com/project/credentials
access_key: <string>
# Secret key to use when listing targets. https://console.scaleway.com/project/credentials
# It is mutually exclusive with `secret_key_file`.
[ secret_key: <secret> ]
# Sets the secret key with the credentials read from the configured file.
# It is mutually exclusive with `secret_key`.
[ secret_key_file: <filename> ]
# Project ID of the targets.
project_id: <string>
# Role of the targets to retrieve. Must be `instance` or `baremetal`.
role: <string>
# The port to scrape metrics from.
[ port: <int> | default = 80 ]
# API URL to use when doing the server listing requests.
[ api_url: <string> | default = "https://api.scaleway.com" ]
# Zone is the availability zone of your targets (e.g. fr-par-1).
[ zone: <string> | default = fr-par-1 ]
# NameFilter specify a name filter (works as a LIKE) to apply on the server listing request.
[ name_filter: <string> ]
# TagsFilter specify a tag filter (a server needs to have all defined tags to be listed) to apply on the server listing request.
tags_filter:
[ - <string> ]
# Refresh interval to re-read the targets list.
[ refresh_interval: <duration> | default = 60s ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
<uyuni_sd_config>
Uyuni SD 配置允許透過 Uyuni API 從託管系統中獲取抓取目標。
在重新標記期間,目標上可以使用以下元標籤
__meta_uyuni_endpoint_name:應用端點的名稱__meta_uyuni_exporter:為目標公開指標的匯出器 (exporter)__meta_uyuni_groups:目標的系統組__meta_uyuni_metrics_path:目標的指標(metrics)路徑__meta_uyuni_minion_hostname:Uyuni 客戶端的主機名__meta_uyuni_primary_fqdn:Uyuni 客戶端的主 FQDN__meta_uyuni_proxy_module:如果為目標配置了 Exporter Exporter 代理,則為此模組名稱__meta_uyuni_scheme:請求所使用的協議方案__meta_uyuni_system_id:客戶端的系統 ID
請參見下方關於 Uyuni 發現的配置選項
# The URL to connect to the Uyuni server.
server: <string>
# Credentials are used to authenticate the requests to Uyuni API.
username: <string>
password: <secret>
# The entitlement string to filter eligible systems.
[ entitlement: <string> | default = monitoring_entitled ]
# The string by which Uyuni group names are joined into the groups label.
[ separator: <string> | default = , ]
# Refresh interval to re-read the managed targets list.
[ refresh_interval: <duration> | default = 60s ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
請參見 Prometheus uyuni-sd 配置檔案 ,瞭解有關如何設定 Uyuni Prometheus 配置的實際示例。
<vultr_sd_config>
Vultr SD 配置允許從 Vultr 檢索抓取目標。
此服務發現預設使用主 IPv4 地址,可以透過重新標記進行更改,正如 Prometheus vultr-sd 配置檔案 中所演示的那樣。
在重新標記期間,目標上可以使用以下元標籤
__meta_vultr_instance_id:Vultr 例項的唯一 ID。__meta_vultr_instance_label:使用者為此例項提供的標籤。__meta_vultr_instance_os:作業系統名稱。__meta_vultr_instance_os_id:此例項所使用的作業系統 ID。__meta_vultr_instance_region:例項所在的區域 ID。__meta_vultr_instance_plan:計劃(Plan)的唯一 ID。__meta_vultr_instance_main_ip:主 IPv4 地址。__meta_vultr_instance_internal_ip:私有 IP 地址。__meta_vultr_instance_main_ipv6:主 IPv6 地址。__meta_vultr_instance_features:此例項可用的功能列表。__meta_vultr_instance_tags:與例項關聯的標籤列表。__meta_vultr_instance_hostname:此例項的主機名。__meta_vultr_instance_server_status:伺服器健康狀態。__meta_vultr_instance_vcpu_count:vCPU 數量。__meta_vultr_instance_ram_mb:以 MB 為單位的 RAM 大小。__meta_vultr_instance_disk_gb:以 GB 為單位的磁碟大小。__meta_vultr_instance_allowed_bandwidth_gb:以 GB 為單位的每月頻寬配額。
# The port to scrape metrics from.
[ port: <int> | default = 80 ]
# The time after which the instances are refreshed.
[ refresh_interval: <duration> | default = 60s ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
<outscale_sd_config>
Outscale SD 配置允許透過 Outscale API (OAPI) 從 Outscale Cloud 虛擬機器檢索抓取目標。
在重新標記期間,目標上可以使用以下元標籤
__meta_outscale_vm_instance_id:虛擬機器的 ID__meta_outscale_vm_region:虛擬機器所在的區域__meta_outscale_vm_subregion:虛擬機器所在的子區域__meta_outscale_vm_state:虛擬機器的狀態__meta_outscale_vm_private_ip:虛擬機器的私有 IP 地址__meta_outscale_vm_public_ip:虛擬機器的公有 IP 地址__meta_outscale_vm_tag_<key>:每個標籤的值;標籤鍵會被清理並追加(例如,標籤鍵Name→__meta_outscale_vm_tag_Name)
目標會使用找到的第一個地址:先是私有 IP,然後是公有 IP。這可以透過重新標記進行更改,正如 Prometheus outscale-sd 配置檔案 中所演示的那樣。
請參見下方關於 Outscale 發現的配置選項
# Region to use.
[ region: <string> | default = "eu-west-2" ]
# Access key (20 alphanumeric characters). See https://docs.outscale.com/en/userguide/Creating-an-Access-Key.html
access_key: <string>
# Secret key (40 characters). Use one of `secret_key` or `secret_key_file`.
[ secret_key: <secret> ]
# Secret key file.
[ secret_key_file: <filename> ]
# API endpoint URL. Defaults to https://api.<region>.outscale.com/api/v1 if empty.
[ endpoint: <string> ]
# The port to scrape metrics from.
[ port: <int> | default = 80 ]
# Refresh interval to re-read the targets list.
[ refresh_interval: <duration> | default = 60s ]
# HTTP client settings.
[ <http_config> ]
<static_config>
static_config 允許指定目標列表以及它們的公共標籤集。這是在抓取配置中指定靜態目標的標準方式。
# The targets specified by the static config.
targets:
[ - '<host>' ]
# Labels assigned to all metrics scraped from the targets.
labels:
[ <labelname>: <labelvalue> ... ]
在重新標記(relabeling)部分中提到的特殊標籤也可以在此處使用,以覆蓋抓取配置中的相應設定。這在與任何不直接支援這些設定的服務發現機制結合使用時特別有用。
<relabel_config>
重新標記是一個強大的工具,可在抓取目標之前動態重寫其標籤集。每個抓取配置均可以配置多個重新標記步驟。它們會按照在配置檔案中出現的順序,依次應用於每個目標的標籤集。
初始時,除了為每個目標配置的標籤之外,目標的 job 標籤會被設定為相應抓取配置的 job_name 值。
您還可以使用特殊的標籤,例如 __address__、__scheme__、__metrics_path__、__scrape_interval__、__scrape_timeout__、__convert_classic_histograms_to_nhcb__、__always_scrape_classic_histograms__、__scrape_native_histograms__ 等,來自定義定義的目標。這些標籤將覆蓋抓取配置中的相應設定。
__address__ 標籤會被設定為目標的 <host>:<port> 地址。重新標記之後,如果在重新標記期間未設定 instance 標籤,則預設會將其設定為 __address__ 的值。
__scheme__ 和 __metrics_path__ 標籤會分別被設定為目標的協議方案和指標路徑,如 scrape_config 中所指定。
__param_<name> 標籤會被設定為 scrape_config 中定義的名叫 <name> 的第一個 URL 引數的值。
__scrape_interval__ 和 __scrape_timeout__ 標籤會被設定為目標的抓取間隔和超時時間,如 scrape_config 中所指定。
__convert_classic_histograms_to_nhcb__ 標籤會被設定為目標的 convert_classic_histograms_to_nhcb 值,如 scrape_config 中所指定(預設使用配置的全域性值)。在重新標記期間設定此標籤,可以針對每個目標覆蓋“是否將經典直方圖轉換為具有自定義桶的原生直方圖”。其值必須能夠解析為布林值;如果值無效,該目標將被丟棄。
__always_scrape_classic_histograms__ 標籤會被設定為目標的 always_scrape_classic_histograms 值,如 scrape_config 中所指定(預設使用配置的全域性值)。在重新標記期間設定此標籤,可以針對每個目標覆蓋“當經典直方圖作為原生直方圖暴露時,是否也攝取該經典直方圖”。其值必須能夠解析為布林值;如果值無效,該目標將被丟棄。
__scrape_native_histograms__ 標籤會被設定為目標的 scrape_native_histograms 值,如 scrape_config 中所指定(預設使用配置的全域性值)。在重新標記期間設定此標籤,可以針對每個目標覆蓋“是否抓取原生直方圖”。其值必須能夠解析為布林值;如果值無效,該目標將被丟棄。
在重新標記階段,帶有 __meta_ 字首的其他標籤可能是可用的。這些標籤由提供該目標的服務發現機制設定,並且因機制而異。
以 __ 開頭的標籤將在目標重新標記完成後從標籤集中移除。
如果重新標記步驟只需要臨時儲存標籤值(作為後續重新標記步驟的輸入),請使用 __tmp 標籤名稱字首。此字首可確保永遠不會被 Prometheus 本身使用。
# The source_labels tells the rule what labels to fetch from the series. Any
# labels which do not exist get a blank value (""). Their content is concatenated
# using the configured separator and matched against the configured regular expression
# for the replace, keep, and drop actions.
[ source_labels: '[' <labelname> [, ...] ']' ]
# Separator placed between concatenated source label values.
[ separator: <string> | default = ; ]
# Label to which the resulting value is written in a replace action.
# It is mandatory for replace actions. Regex capture groups are available.
[ target_label: <labelname> ]
# Regular expression against which the extracted value is matched.
[ regex: <regex> | default = (.*) ]
# Modulus to take of the hash of the source label values.
[ modulus: <int> ]
# Replacement value against which a regex replace is performed if the
# regular expression matches. Regex capture groups are available.
[ replacement: <string> | default = $1 ]
# Action to perform based on regex matching.
[ action: <relabel_action> | default = replace ]
<regex> 可以是任何有效的 RE2 正則表示式 。它是執行 replace、keep、drop、labelmap、labeldrop 和 labelkeep 操作所必需的。正則表示式預設在兩端錨定。要取消錨定,請使用 .*<regex>.*。
<relabel_action> 決定了要執行的重新標記操作
replace:將regex與拼接後的source_labels進行匹配。然後,將target_label設定為replacement,並將replacement中的匹配組引用(${1}、${2}等)替換為其對應的值。如果regex不匹配,則不進行替換。lowercase:將拼接後的source_labels對映為其小寫形式。uppercase:將拼接後的source_labels對映為其大寫形式。keep:丟棄regex與拼接後的source_labels不匹配的目標。drop:丟棄regex與拼接後的source_labels匹配的目標。keepequal:丟棄拼接後的source_labels與target_label不匹配的目標。dropequal:丟棄拼接後的source_labels與target_label匹配的目標。hashmod:將target_label設定為拼接後的source_labels的雜湊值模數(modulus)。labelmap:將regex與所有源標籤名稱進行匹配,而不僅限於source_labels中指定的那些名稱。然後將匹配標籤的值複製到replacement給出的標籤名稱中,並將replacement中的匹配組引用(${1}、${2}等)替換為其對應的值。labeldrop:將regex與所有標籤名稱進行匹配。任何匹配的標籤都會從標籤集中移除。labelkeep:將regex與所有標籤名稱進行匹配。任何不匹配的標籤都會從標籤集中移除。
使用 labeldrop 和 labelkeep 時需要特別小心,以確保移除標籤後,指標仍然可以被唯一標識。
<metric_relabel_configs>
指標重新標記是在樣本被攝取前的最後一步應用於這些樣本的。它具有與目標重新標記相同的配置格式和操作。指標重新標記不適用於自動生成的時序,例如 up。
此功能的一個用途是排除因開銷過大而不宜攝取的時序。
<alert_relabel_configs>
告警重新標記是在告警被髮送到 Alertmanager 之前應用於這些告警的。它具有與目標重新標記相同的配置格式和操作。告警重新標記是在外部標籤之後應用的。
此功能的一個用途是確保具有不同外部標籤的高可用(HA)對 Prometheus 伺服器傳送完全相同的告警。
<alertmanager_config>
alertmanager_config 部分指定了 Prometheus 伺服器將告警傳送到哪些 Alertmanager 例項。它還提供了配置與這些 Alertmanager 進行通訊方式的引數。
Alertmanager 可以透過 static_configs 引數進行靜態配置,也可以使用支援的服務發現機制之一進行動態發現。
此外,relabel_configs 允許從發現的實體中篩選 Alertmanager,並對所使用的 API 路徑提供高階修改,該路徑透過 __alerts_path__ 標籤暴露。
# Per-target Alertmanager timeout when pushing alerts.
[ timeout: <duration> | default = 10s ]
# The api version of Alertmanager.
[ api_version: <string> | default = v2 ]
# Prefix for the HTTP path alerts are pushed to.
[ path_prefix: <path> | default = / ]
# Configures the protocol scheme used for requests.
[ scheme: <scheme> | default = http ]
# Optionally configures AWS's Signature Verification 4 signing process to sign requests.
# Cannot be set at the same time as basic_auth, authorization, oauth2, azuread or google_iam.
# To use the default credentials from the AWS SDK, use `sigv4: {}`.
sigv4:
# The AWS region. If blank, the region from the default credentials chain
# is used.
[ region: <string> ]
# The AWS API keys. If blank, the environment variables `AWS_ACCESS_KEY_ID`
# and `AWS_SECRET_ACCESS_KEY` are used.
[ access_key: <string> ]
[ secret_key: <secret> ]
# Named AWS profile used to authenticate.
[ profile: <string> ]
# AWS Role ARN, an alternative to using AWS API keys.
[ role_arn: <string> ]
# AWS External ID used when assuming a role.
# Can only be used with role_arn.
[ external_id: <string> ]
# Defines the FIPS mode for the AWS STS endpoint.
# Requires Prometheus >= 2.54.0
# Note: FIPS STS selection should be configured via use_fips_sts_endpoint rather than environment variables. (The problem report that motivated this: AWS_USE_FIPS_ENDPOINT no longer works.)
[ use_fips_sts_endpoint: <boolean> | default = false ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
# List of AWS service discovery configurations.
aws_sd_configs:
[ - <aws_sd_config> ... ]
# List of Azure service discovery configurations.
azure_sd_configs:
[ - <azure_sd_config> ... ]
# List of Consul service discovery configurations.
consul_sd_configs:
[ - <consul_sd_config> ... ]
# List of DNS service discovery configurations.
dns_sd_configs:
[ - <dns_sd_config> ... ]
# List of EC2 service discovery configurations.
ec2_sd_configs:
[ - <ec2_sd_config> ... ]
# List of Eureka service discovery configurations.
eureka_sd_configs:
[ - <eureka_sd_config> ... ]
# List of file service discovery configurations.
file_sd_configs:
[ - <file_sd_config> ... ]
# List of DigitalOcean service discovery configurations.
digitalocean_sd_configs:
[ - <digitalocean_sd_config> ... ]
# List of Docker service discovery configurations.
docker_sd_configs:
[ - <docker_sd_config> ... ]
# List of Docker Swarm service discovery configurations.
dockerswarm_sd_configs:
[ - <dockerswarm_sd_config> ... ]
# List of GCE service discovery configurations.
gce_sd_configs:
[ - <gce_sd_config> ... ]
# List of Hetzner service discovery configurations.
hetzner_sd_configs:
[ - <hetzner_sd_config> ... ]
# List of HTTP service discovery configurations.
http_sd_configs:
[ - <http_sd_config> ... ]
# List of IONOS service discovery configurations.
ionos_sd_configs:
[ - <ionos_sd_config> ... ]
# List of Kubernetes service discovery configurations.
kubernetes_sd_configs:
[ - <kubernetes_sd_config> ... ]
# List of Lightsail service discovery configurations.
lightsail_sd_configs:
[ - <lightsail_sd_config> ... ]
# List of Linode service discovery configurations.
linode_sd_configs:
[ - <linode_sd_config> ... ]
# List of Marathon service discovery configurations.
marathon_sd_configs:
[ - <marathon_sd_config> ... ]
# List of AirBnB's Nerve service discovery configurations.
nerve_sd_configs:
[ - <nerve_sd_config> ... ]
# List of Nomad service discovery configurations.
nomad_sd_configs:
[ - <nomad_sd_config> ... ]
# List of OpenStack service discovery configurations.
openstack_sd_configs:
[ - <openstack_sd_config> ... ]
# List of Outscale service discovery configurations.
outscale_sd_configs:
[ - <outscale_sd_config> ... ]
# List of OVHcloud service discovery configurations.
ovhcloud_sd_configs:
[ - <ovhcloud_sd_config> ... ]
# List of PuppetDB service discovery configurations.
puppetdb_sd_configs:
[ - <puppetdb_sd_config> ... ]
# List of Scaleway service discovery configurations.
scaleway_sd_configs:
[ - <scaleway_sd_config> ... ]
# List of Zookeeper Serverset service discovery configurations.
serverset_sd_configs:
[ - <serverset_sd_config> ... ]
# List of STACKIT service discovery configurations.
stackit_sd_configs:
[ - <stackit_sd_config> ... ]
# List of Triton service discovery configurations.
triton_sd_configs:
[ - <triton_sd_config> ... ]
# List of Uyuni service discovery configurations.
uyuni_sd_configs:
[ - <uyuni_sd_config> ... ]
# List of Vultr service discovery configurations.
vultr_sd_configs:
[ - <vultr_sd_config> ... ]
# List of labeled statically configured Alertmanagers.
static_configs:
[ - <static_config> ... ]
# List of Alertmanager relabel configurations.
relabel_configs:
[ - <relabel_config> ... ]
# List of alert relabel configurations.
alert_relabel_configs:
[ - <relabel_config> ... ]
<remote_write>
write_relabel_configs 是在將樣本傳送到遠端端點之前應用於這些樣本的重新標記。寫入重新標記在外部標籤之後應用。這可用於限制傳送哪些樣本。
這裡有一個關於如何使用此功能的小型演示 。
# The URL of the endpoint to send samples to.
url: <string>
# protobuf message to use when writing to the remote write endpoint.
#
# * The `prometheus.WriteRequest` represents the message introduced in Remote Write 1.0, which
# will be deprecated eventually.
# * The `io.prometheus.write.v2.Request` was introduced in Remote Write 2.0 and replaces the former,
# by improving efficiency and sending metadata, start timestamp and native histograms by default.
#
# Before changing this value, consult with your remote storage provider (or test) what message it supports.
# Read more on https://prometheus.golang.com.tw/docs/specs/remote_write_spec_2_0/#io-prometheus-write-v2-request
[ protobuf_message: <prometheus.WriteRequest | io.prometheus.write.v2.Request> | default = prometheus.WriteRequest ]
# Timeout for requests to the remote write endpoint.
[ remote_timeout: <duration> | default = 30s ]
# Custom HTTP headers to be sent along with each remote write request.
# Be aware that headers that are set by Prometheus itself can't be overwritten.
headers:
[ <string>: <string> ... ]
# List of remote write relabel configurations.
write_relabel_configs:
[ - <relabel_config> ... ]
# Name of the remote write config, which if specified must be unique among remote write configs.
# The name will be used in metrics and logging in place of a generated value to help users distinguish between
# remote write configs.
[ name: <string> ]
# Enables sending of exemplars over remote write. Note that exemplar storage itself must be enabled for exemplars to be scraped in the first place.
[ send_exemplars: <boolean> | default = false ]
# Enables sending of native histograms, also known as sparse histograms, over remote write.
# For the `io.prometheus.write.v2.Request` message, this option is noop (always true).
[ send_native_histograms: <boolean> | default = false ]
# When enabled, remote-write will resolve the URL host name via DNS, choose one of the IP addresses at random, and connect to it.
# When disabled, remote-write relies on Go's standard behavior, which is to try to connect to each address in turn.
# The connection timeout applies to the whole operation, i.e. in the latter case it is spread over all attempt.
# This is an experimental feature, and its behavior might still change, or even get removed.
[ round_robin_dns: <boolean> | default = false ]
# Optionally configures AWS's Signature Verification 4 signing process to
# sign requests. Cannot be set at the same time as basic_auth, authorization, oauth2, or azuread.
# To use the default credentials from the AWS SDK, use `sigv4: {}`.
sigv4:
# The AWS region. If blank, the region from the default credentials chain
# is used.
[ region: <string> ]
# The AWS API keys. If blank, the environment variables `AWS_ACCESS_KEY_ID`
# and `AWS_SECRET_ACCESS_KEY` are used.
[ access_key: <string> ]
[ secret_key: <secret> ]
# Named AWS profile used to authenticate.
[ profile: <string> ]
# AWS Role ARN, an alternative to using AWS API keys.
[ role_arn: <string> ]
# AWS External ID used when assuming a role.
# Can only be used with role_arn.
[ external_id: <string> ]
# Defines the FIPS mode for the AWS STS endpoint.
# Requires Prometheus >= 2.54.0
# Note: FIPS STS selection should be configured via use_fips_sts_endpoint rather than environment variables. (The problem report that motivated this: AWS_USE_FIPS_ENDPOINT no longer works.)
[ use_fips_sts_endpoint: <boolean> | default = false ]
# Optional AzureAD configuration.
# Cannot be used at the same time as basic_auth, authorization, oauth2, sigv4 or google_iam.
azuread:
# The Azure Cloud. Options are 'AzurePublic', 'AzureChina', or 'AzureGovernment'.
[ cloud: <string> | default = AzurePublic ]
# Azure Managed Identity. Leave 'client_id' blank to use the default managed identity.
[ managed_identity:
[ client_id: <string> ] ]
# Azure Workload Identity.
[ workload_identity:
client_id: <string>
tenant_id: <string>
[ token_file_path: <string> | default = "/var/run/secrets/azure/tokens/azure-identity-token" ] ]
# Azure OAuth.
[ oauth:
[ client_id: <string> ]
[ client_secret: <string> ]
[ tenant_id: <string> ] ]
# Azure Certificate-based authentication.
[ certificate:
client_id: <string>
tenant_id: <string>
certificate_path: <file_name>
# Optional path to private key file if separate from certificate
[ certificate_key_path: <file_name> ]
# Optional password for password-protected certificate files (PFX/PKCS12)
[ certificate_password: <secret> ]
# Whether to send the certificate chain in the x5c header
[ send_certificate_chain: <boolean> | default = false ] ]
# Azure SDK auth.
# See https://learn.microsoft.com/en-us/azure/developer/go/azure-sdk-authentication
[ sdk:
[ tenant_id: <string> ] ]
# Optional custom OAuth 2.0 scope to request when acquiring tokens.
# If not specified, defaults to the appropriate monitoring scope for the cloud:
# - AzurePublic: https://monitor.azure.com//.default
# - AzureGovernment: https://monitor.azure.us//.default
# - AzureChina: https://monitor.azure.cn//.default
# Use this to authenticate against custom Azure applications or non-standard endpoints.
[ scope: <string> ]
# WARNING: Remote write is NOT SUPPORTED by Google Cloud. This configuration is reserved for future use.
# Optional Google Cloud Monitoring configuration.
# Cannot be used at the same time as basic_auth, authorization, oauth2, sigv4 or azuread.
# To use the default credentials from the Google Cloud SDK, use `google_iam: {}`.
google_iam:
# Service account key with monitoring write permissions.
credentials_file: <file_name>
# Configures the queue used to write to remote storage.
queue_config:
# Number of samples to buffer per shard before we block reading of more
# samples from the WAL. It is recommended to have enough capacity in each
# shard to buffer several requests to keep throughput up while processing
# occasional slow remote requests.
[ capacity: <int> | default = 10000 ]
# Maximum number of shards, i.e. amount of concurrency.
[ max_shards: <int> | default = 50 ]
# Minimum number of shards, i.e. amount of concurrency.
[ min_shards: <int> | default = 1 ]
# Maximum number of samples per send.
[ max_samples_per_send: <int> | default = 2000]
# Maximum time a sample will wait for a send. The sample might wait less
# if the buffer is full. Further time might pass due to potential retries.
[ batch_send_deadline: <duration> | default = 5s ]
# Initial retry delay. Gets doubled for every retry.
[ min_backoff: <duration> | default = 30ms ]
# Maximum retry delay.
[ max_backoff: <duration> | default = 5s ]
# Retry upon receiving a 429 status code from the remote-write storage.
# This is experimental and might change in the future.
[ retry_on_http_429: <boolean> | default = false ]
# If set, any sample that is older than sample_age_limit
# will not be sent to the remote storage. The default value is 0s,
# which means that all samples are sent.
[ sample_age_limit: <duration> | default = 0s ]
# Configures the sending of series metadata to remote storage
# if the `prometheus.WriteRequest` message was chosen. When
# `io.prometheus.write.v2.Request` is used, metadata is always sent.
#
# Metadata configuration is subject to change at any point
# or be removed in future releases.
metadata_config:
# Whether metric metadata is sent to remote storage or not.
[ send: <boolean> | default = true ]
# How frequently metric metadata is sent to remote storage.
[ send_interval: <duration> | default = 1m ]
# Maximum number of samples per send.
[ max_samples_per_send: <int> | default = 500]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
# enable_http2 defaults to false for remote-write.
[ <http_config> ]
這裡有此功能的整合列表。
<remote_read>
# The URL of the endpoint to query from.
url: <string>
# Name of the remote read config, which if specified must be unique among remote read configs.
# The name will be used in metrics and logging in place of a generated value to help users distinguish between
# remote read configs.
[ name: <string> ]
# An optional list of equality matchers which have to be
# present in a selector to query the remote read endpoint.
required_matchers:
[ <labelname>: <labelvalue> ... ]
# Timeout for requests to the remote read endpoint.
[ remote_timeout: <duration> | default = 1m ]
# Custom HTTP headers to be sent along with each remote read request.
# Be aware that headers that are set by Prometheus itself can't be overwritten.
headers:
[ <string>: <string> ... ]
# Whether reads should be made for queries for time ranges that
# the local storage should have complete data for.
[ read_recent: <boolean> | default = false ]
# Whether to use the external labels as selectors for the remote read endpoint.
[ filter_external_labels: <boolean> | default = true ]
# HTTP client settings, including authentication methods (such as basic auth and
# authorization), proxy configurations, TLS options, custom HTTP headers, etc.
[ <http_config> ]
這裡有此功能的整合列表。
<tsdb>
tsdb 允許您配置 TSDB 執行時可過載的配置設定。
# Configures how old an out-of-order/out-of-bounds sample can be w.r.t. the TSDB max time.
# An out-of-order/out-of-bounds sample is ingested into the TSDB as long as the timestamp
# of the sample is >= TSDB.MaxTime-out_of_order_time_window.
#
# When out_of_order_time_window is >0, the errors out-of-order and out-of-bounds are
# combined into a single error called 'too-old'; a sample is either (a) ingestible
# into the TSDB, i.e. it is an in-order sample or an out-of-order/out-of-bounds sample
# that is within the out-of-order window, or (b) too-old, i.e. not in-order
# and before the out-of-order window.
#
# When out_of_order_time_window is greater than 0, it also affects experimental agent. It allows
# the agent's WAL to accept out-of-order samples that fall within the specified time window relative
# to the timestamp of the last appended sample for the same series.
[ out_of_order_time_window: <duration> | default = 0s ]
# Configures the trigger point for compacting the stale series from the memory into persistent blocks
# and remove those stale series from the memory.
#
# The threshold is a number between 0.0 and 1.0. It represents the ratio of stale series in the memory
# to the total series in the memory. The stale series compaction is triggered when this ratio crosses
# the configured threshold. It may not trigger the stale series compaction if the usual head compaction
# is about to happen soon.
#
# If set to 0, stale series compaction is disabled.
#
# This is an experimental feature, this behaviour could change or be removed in the future.
[ stale_series_compaction_threshold: <float> | default = 0 ]
# Configures the float chunk encoding to use for new chunks.
# Valid values are 'xor' and 'xor2'. When absent, the encoding follows the
# --enable-feature=xor2-encoding flag: 'xor2' if the flag is set, 'xor' otherwise.
# Setting 'xor' forces standard XOR encoding even when --enable-feature=xor2-encoding is set.
# Setting 'xor2' is only valid when --enable-feature=xor2-encoding is set;
# Prometheus will refuse to reload if 'xor2' is set without the feature flag.
# Setting 'xor' is incompatible with --enable-feature=st-storage (XOR chunks do not store
# start timestamps); Prometheus will refuse to reload in that case too.
# Omitting 'floats' (or the entire 'chunk_encoding' field) is equivalent; the encoding
# follows the --enable-feature=xor2-encoding flag.
# This field is runtime-reloadable.
# When --enable-feature=st-storage is disabled, XOR and XOR2 are compatible
# encodings and in-progress chunks are not cut on an encoding change; the new
# encoding takes effect when the current chunk is next cut for any reason (size, time range, or sample count).
# When --enable-feature=st-storage is enabled, XOR and XOR2 are not compatible
# (XOR chunks do not store start timestamps), so an in-progress chunk is cut
# on the next append after the encoding changes.
[ chunk_encoding:
[ floats: <string> ] ]
# Configures data retention settings for TSDB.
#
# Note: When retention is changed at runtime, the retention
# settings are updated immediately, but block deletion based on the new retention policy
# occurs during the next block reload cycle. This happens automatically within 1 minute
# or when a compaction completes, whichever comes first.
[ retention: <retention> ] :
# How long to retain samples in storage. If neither this option nor the size option
# is set, the retention time defaults to 15d. Setting this to 0 disables time-based retention.
# This option takes precedence over the deprecated command-line flag --storage.tsdb.retention.time.
[ time: <duration> ]
# Maximum number of bytes that can be stored for blocks. A unit is required,
# supported units: B, KB, MB, GB, TB, PB, EB. Ex: "512MB". Based on powers-of-2, so 1KB is 1024B.
# If set to 0 or not set, size-based retention is disabled.
# This option takes precedence over the deprecated command-line flag --storage.tsdb.retention.size.
[ size: <size> | default = 0 ]
# Maximum percent of total disk space allowed for storage of blocks. Alternative to `size` and
# behaves the same as if size was calculated by hand as a percentage of the total storage capacity.
# Prometheus will fail to start if this config is enabled, but it fails to query the total storage capacity.
# The total disk space allowed will automatically adapt to volume resize.
# If set to 0 or not set, percentage-based retention is disabled.
#
# This is an experimental feature, this behaviour could change or be removed in the future.
[ percentage: <uint> | default = 0 ]
<exemplars>
請注意,示例(exemplar)儲存仍被視為實驗性功能,必須透過 --enable-feature=exemplar-storage 啟用。
# Configures the maximum size of the circular buffer used to store exemplars for all series. Resizable during runtime.
[ max_exemplars: <int> | default = 100000 ]
<tracing_config>
tracing_config 配置了透過 OTLP 協議將跟蹤(traces)從 Prometheus 匯出到跟蹤後端。跟蹤目前是一項實驗性功能,未來可能會發生改變。
# Client used to export the traces. Options are 'http' or 'grpc'.
[ client_type: <string> | default = grpc ]
# Endpoint to send the traces to. Should be provided in format <host>:<port>.
[ endpoint: <string> ]
# Sets the probability a given trace will be sampled. Must be a float from 0 through 1.
[ sampling_fraction: <float> | default = 0 ]
# If disabled, the client will use a secure connection.
[ insecure: <boolean> | default = false ]
# Key-value pairs to be used as headers associated with gRPC or HTTP requests.
headers:
[ <string>: <string> ... ]
# Compression key for supported compression types. Supported compression: gzip.
[ compression: <string> ]
# Maximum time the exporter will wait for each batch export.
[ timeout: <duration> | default = 10s ]
# TLS configuration.
tls_config:
[ <tls_config> ]
如果同時啟用了查詢日誌記錄和跟蹤,traceID 和 spanID 將被注入到查詢日誌檔案中,以便用於日誌/跟蹤關聯。