scrape_interval
, an HTTP request is made to this target. In response, you get metrics in your own format , which are saved to the database.evaluation_interval
rules are processed, based on which:scrape_configs
- settings for finding targets for monitoring (for more details, see the next section);rule_files
- the list of directories where the rules are to be loaded: rule_files: - /etc/prometheus/rules/rules-0/* - /etc/prometheus/rules/rules-1/*
alerting
- alerting
search settings to which alerts are sent. The section is very similar to scrape_configs
with the difference that the result of its work is a list of endpoints to which Prometheus will send alerts.scrape_configs
section, according to which it configures its internal Service Discovery mechanism.scrape_configs
is a list of scrape scrape_configs
(this is an internal concept of Prometheus), each of which is defined as follows: scrape_configs: # - job_name: kube-prometheus/custom/0 # scrape job' # Service Discovery scrape_interval: 30s # scrape_timeout: 10s # metrics_path: /metrics # path, scheme: http # http https # Service Discovery kubernetes_sd_configs: # , targets Kubernetes - api_server: null # API- # ( ) role: endpoints # targets endpoints namespaces: names: # endpoints namespaces - foo - baz # "" ( enpoints , — ) "" # ( — ) relabel_configs: # prometheus_custom_target, # service, endpoint - source_labels: [__meta_kubernetes_service_label_prometheus_custom_target] regex: .+ # action: keep # - source_labels: [__meta_kubernetes_endpoint_port_name] regex: http-metrics # , http-metrics action: keep # job, prometheus_custom_target # service, "custom-" # # job — Prometheus. , # target targets, # , targets ( # rules dashboards) - source_labels: [__meta_kubernetes_service_label_prometheus_custom_target] regex: (.*) target_label: job replacement: custom-$1 action: replace # namespace - source_labels: [__meta_kubernetes_namespace] regex: (.*) target_label: namespace replacement: $1 action: replace # service - source_labels: [__meta_kubernetes_service_name] regex: (.*) target_label: service replacement: $1 action: replace # instance ( ) - source_labels: [__meta_kubernetes_pod_name] regex: (.*) target_label: instance replacement: $1 action: replace
prometheus
- defines the installation (cluster) of Prometheus;servicemonitor
- defines how to monitor a set of services (ie, collect their metrics);alertmanager
- defines a cluster of Alertmanagers (we do not use them, because we send metrics directly to our notification system, which receives, aggregates and ranks data from a variety of sources - including, integrates with Slack and Telegram).prometheus
resources and generates for each of them:prometheus.yaml
(Prometheus config) and configmaps.json
(config for prometheus-config-reloader
).servicemonitor
resources and ConfigMaps with the rules, and on their basis updates the configs prometheus.yaml
and configmaps.json
(they are kept secret).prometheus
- Prometheus itself;prometheus-config-reloader
is a binding that monitors changes to prometheus.yaml
and, if necessary, causes a reload of the Prometheus configuration (with a special HTTP request — see below for details), and also monitors ConfigMaps with the rules (they are specified in configmaps.json
— see more below) and downloads them as needed and restarts Prometheus.config
- the mounted secret (two files: prometheus.yaml
and configmaps.json
). Connected to both containers;rules
- emptyDir
, which fills prometheus-config-reloader
, and reads prometheus
. Connected to both containers, but in prometheus
- in read-only mode;data
- Prometheus data. Mounted only in prometheus
.prometheus
resource prometheus
(see the documentation for details).any: true
), Prometheus Operator computes (referring to the Kubernetes API) a list of namespaces in which there are Services matching the labels specified in the Service Monitor .servicemonitor
resources (see the documentation ) and on the basis of the calculated namespaces, Prometheus Operator generates a part of the config (section scrape_configs
) and saves the config to the appropriate secret.prometheus.yaml
updated).prometheus-config-reloader
, which via HTTP sends a request to Prometheus to reboot.scrape_configs
, which it processes already according to its work logic (see details above).ruleSelector
specified in the prometheus
resource.prometheus.yaml
, after which the logic exactly corresponding to the Service Monitors processing (see above) is triggered.configmaps.json
(it contains a list of ConfigMaps and their checksums).configmaps.json
updated).prometheus-config-reloader
, which downloads the changed ConfigMaps to the rules
directory (this is emptyDir
).prometheus-config-reloader
sends an HTTP request to Prometheus to reboot.Source: https://habr.com/ru/post/353410/
All Articles