编辑 prometheus.yml 个文件

Edit prometheus.yml file

我已使用 prometheus-community/kube-prometheus-stack version 13.10.0 Helm chart 将 Prometheus 部署到 Kubernetes 集群,并想编辑 /etc/prometheus/ 目录中的 prometheus.yml 文件。

原因是我需要为 Jenkins 添加额外的抓取配置,因为我无法通过额外的服务监视器动态地执行它。

是否可以编辑此文件? 描述 pod,我可以看到该文件是由一个秘密创建的。

Volumes:
  config:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  prometheus-prometheus-kube-prometheus-prometheus
    Optional:    false

但是我在任何地方都找不到创建这个秘密的模板。

这里是 link 似乎是一个解决方案:https://github.com/prometheus-community/helm-charts/blob/main/charts/kube-prometheus-stack/values.yaml#L2108-L2146


我决定提供一些简短的解释,因为有时 links 停止工作:

prometheus-community/kube-prometheus-stack 在 helm 图表的 values.yaml 文件中有 additionalScrapeConfigs 字段。

这是它的定义:

## AdditionalScrapeConfigs allows specifying additional Prometheus scrape configurations. Scrape configurations
## are appended to the configurations generated by the Prometheus Operator. Job configurations must have the form
## as specified in the official Prometheus documentation:
## https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config. As scrape configs are
## appended, the user is responsible to make sure it is valid. Note that using this feature may expose the possibility
## to break upgrades of Prometheus. It is advised to review Prometheus release notes to ensure that no incompatible
## scrape configs are going to break Prometheus after the upgrade.
##
## The scrape configuration example below will find master nodes, provided they have the name .*mst.*, relabel the
## port to 2379 and allow etcd scraping provided it is running on all Kubernetes master nodes
##
additionalScrapeConfigs: []