【问题标题】:Helm, Promethus : Install prometheus with data/default directory on ec2 instanceHelm,Promethus:在 ec2 实例上安装带有数据/默认目录的 prometheus
【发布时间】:2021-02-08 10:25:23
【问题描述】:

我正在 Kubernetes 环境中开发 prometheus,我想在其中监控我们的 pod,这些 pod 正准备将指标直接发送到 prometheus。我可以通过 helm install stable/prometheus 命令安装 prometheus,但是 prometheus.yml 抓取文件位于 pod 内,并且在 pod 重启时也不会持久。

由于我们仍在试验中,抓取文件将经过一些迭代,然后我们才能确定它是否适合我们。我坚持使用 helm 的原因是它还安装了其他包,如 grafana、nodeexpoerter 等,这些包很有帮助

如何指示 helm 使用 AWS 上的特定数据目录。假设 /var/prometheus。如果这不可能,那么至少一个自定义 prometheus.yml,在服务器端更新时可以反映在 prometheus pod 中。

到目前为止,至少,我想补充一下

        kubernetes_sd_configs:
          - role: pod
        relabel_configs:
          - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
            action: keep
            regex: true
          - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
            action: replace
            target_label: __metrics_path__
            regex: (.+)
          - source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
            action: replace
            regex: ([^:]+)(?::\d+)?;(\d+)
            replacement: $1:$2
            target_label: __address__
          - action: labelmap
            regex: __meta_kubernetes_pod_label_(.+)
          - source_labels: [__meta_kubernetes_namespace]
            action: replace
            target_label: kubernetes_namespace
          - action: labeldrop
            regex: '(kubernetes_pod|app_kubernetes_io_instance|app_kubernetes_io_name|instance)'


This in the scraping file. What am I missing? Thank you. :-) 

【问题讨论】:

    标签: kubernetes prometheus kubernetes-helm helmfile


    【解决方案1】:

    回答您的问题:

    可以使用hostPath 类型的卷:https://kubernetes.io/docs/concepts/storage/volumes/#hostpath。它可以是单个文件或目录。所以挂载一个 Prometheus 配置目录或只是prometheus.ymlRelated vars for stable Prometheus chart.

    解决您的问题:

    这里的问题是 Prometheus 不会自动重新加载更新的配置。要解决这个问题,您有两种选择:

    【讨论】:

    • 如何在 helm install prometheus 中使用 hostpath?
    • 所以我一直在寻找稳定的图表变量并找到了这个github.com/helm/charts/blob/master/stable/prometheus/…和这个github.com/helm/charts/blob/master/stable/prometheus/…因为重新加载器已经是普罗米修斯图表的一部分,你可以尝试将这两个部分结合起来使用hostPath 获得自动解决方案(我的答案的第 1 部分)
    • 更新了我的答案,不幸的是 reloader 不包括基于 hostPath 的配置更新,所以我的答案的两个部分仍然适用。
    猜你喜欢
    • 1970-01-01
    • 2017-01-02
    • 2016-10-23
    • 1970-01-01
    • 2020-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-04
    相关资源
    最近更新 更多