首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何为prometheus操作符启用额外的信任

如何为prometheus操作符启用额外的信任
EN

Stack Overflow用户
提问于 2019-12-05 18:17:38
回答 2查看 8K关注 0票数 7

根据Prometheus-运营商文档,我们应该能够提供我们的额外配置很容易通过秘密文件。有没有人真的成功了这一步?我有几个问题:

  • 这些配置会出现在普罗米修斯舱里吗?
  • 此配置是以prometheus配置文件的形式进行,还是仅列出附加的刮取项?
  • 我们是否可以通过file_sd_configs:提供额外的文件(json信任),如果是的话,如何将这些文件提供给prometheus清单文件?

不管这些问题,我都很难添加额外的配置。我基本上遵循了文档的具体步骤,下面是我的观察结果:

  1. 这是我的新配置
代码语言:javascript
复制
    cat prometheus-additional.yaml
    - job_name: "prometheus-custom"
      static_configs:
      - targets: ["localhost:9090"]
  1. 添加新的秘密文件
代码语言:javascript
复制
    kubectl create secret generic additional-scrape-configs --from-file=prometheus-additional.yaml
  1. 使用附加配置创建prometheus.yml文件
代码语言:javascript
复制
    apiVersion: monitoring.coreos.com/v1
    kind: Prometheus
    metadata:
      name: prometheus
    spec:
      replicas: 2
      resources:
        requests:
          memory: 400Mi
      additionalScrapeConfigs:
        name: additional-scrape-configs
        key: prometheus-additional.yaml
  1. 部署prometheus.yaml
代码语言:javascript
复制
    kubectl apply -f prometheus.yaml
  1. 检查日志,没有显示我的新配置。
代码语言:javascript
复制
kubectl logs prometheus-prometheus-0 -c prometheus
level=info ts=2019-12-05T18:07:30.217852541Z caller=main.go:302 msg="Starting Prometheus" version=" (version=2.7.1, branch=HEAD, revision=62e591f928ddf6b3468308b7ac1de1c63aa7fcf3)"
level=info ts=2019-12-05T18:07:30.217916972Z caller=main.go:303 build_context="(go=go1.11.5, user=root@f9f82868fc43, date=20190131-11:16:59)"
level=info ts=2019-12-05T18:07:30.217971648Z caller=main.go:304 host_details="(Linux 4.19.3-300.fc29.x86_64 #1 SMP Wed Nov 21 15:27:25 UTC 2018 x86_64 prometheus-prometheus-0 (none))"
level=info ts=2019-12-05T18:07:30.217994128Z caller=main.go:305 fd_limits="(soft=1048576, hard=1048576)"
level=info ts=2019-12-05T18:07:30.218236509Z caller=main.go:306 vm_limits="(soft=unlimited, hard=unlimited)"
level=info ts=2019-12-05T18:07:30.219359123Z caller=main.go:620 msg="Starting TSDB ..."
level=info ts=2019-12-05T18:07:30.219487263Z caller=web.go:416 component=web msg="Start listening for connections" address=0.0.0.0:9090
level=info ts=2019-12-05T18:07:30.230944675Z caller=main.go:635 msg="TSDB started"
level=info ts=2019-12-05T18:07:30.231037536Z caller=main.go:695 msg="Loading configuration file" filename=/etc/prometheus/config_out/prometheus.env.yaml
level=info ts=2019-12-05T18:07:30.23125837Z caller=main.go:722 msg="Completed loading of configuration file" filename=/etc/prometheus/config_out/prometheus.env.yaml
level=info ts=2019-12-05T18:07:30.231294106Z caller=main.go:589 msg="Server is ready to receive web requests."
level=info ts=2019-12-05T18:07:33.568068248Z caller=main.go:695 msg="Loading configuration file" filename=/etc/prometheus/config_out/prometheus.env.yaml
level=info ts=2019-12-05T18:07:33.568305994Z caller=main.go:722 msg="Completed loading of configuration file" filename=/etc/prometheus/config_out/prometheus.env.yaml

而且,当我登录到prometheus时,我也看不到任何额外的配置,当我检查我的prometheus控制台时,我看不到任何配置。

EN

回答 2

Stack Overflow用户

发布于 2019-12-05 20:17:01

结果发现,prometheus操作符仍然依赖于清单文件的serviceMonitorSelector: {}部分,根据这个票证。因此,为了添加其他配置,我们需要有以下清单:

代码语言:javascript
复制
apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
  name: prometheus
spec:
  replicas: 2
  resources:
    requests:
      memory: 400Mi
  additionalScrapeConfigs:
    name: prometheus-config
    key: prometheus-config.yaml
  serviceMonitorSelector: {}

其中prometheus-config.yaml将包含prometheus刮取规则,并通过秘密部署到prometheus集群。我还根据经验发现,当前的prometheus操作符在prometheus配置(sad)中不支持file_sd_configs,而且需要在prometheus-config.yaml文件中编写完整的规则。

票数 5
EN

Stack Overflow用户

发布于 2022-08-30 20:43:30

文档在某种程度上是错误的,当前的操作符不需要serviceMonitorSelector,但是使用上面的配置会抛出一个无法解组!!映射到[]yaml.MapSlice错误。正确的引用是additionalScrapeConfigsSecret

代码语言:javascript
复制
additionalScrapeConfigsSecret:
      enabled: true
      name: additional-scrape-configs
      key: prometheus-additional.yaml

否则您将得到错误cannot unmarshal !!map into []yaml.MapSlice

下面是一个更好的文档:https://github.com/prometheus-community/helm-charts/blob/8b45bdbdabd9b54766c4beb3c562b766b268a034/charts/kube-prometheus-stack/values.yaml#L2691

根据这一点,您可以在没有包装的情况下将刮擦的秘密添加到下面这样的秘密中:

代码语言:javascript
复制
additionalScrapeConfigs: |
  - job_name: "prometheus"
  static_configs:
  - targets: ["localhost:9090"]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59201108

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档