简体   繁体   English

普罗米修斯(k8s)(指标)

[英]Prometheus in k8s (metrics)

I deploy prometheus in kubernetes on this manual 我在手册上在kubernetes中部署了普罗米修斯

As a storage scheme was invented: Prometeus in kubernetes stores the metrics within 24 hours. 由于发明了一种存储方案: kubernetes中的Prometeus可在24小时内存储指标。 Prometheus not in kubernetes stores the metrics in 1 week. 不在kubernetes中的Prometheus将在1周内存储指标。 A federation is set up between them. 它们之间建立了联盟。

Who faced with the fact that after removing the pods after a certain period of time (much less than 24 hours) metrics are missing on it. 谁面对这样的事实,即在一定时间段(少于24小时)内移除豆荚之后,缺少度量标准。

This is perfectly normal if you do not have a persistent storage configured for your prometheus pod. 如果您没有为Prometheus Pod配置持久存储,这是完全正常的。 You should use PV/PVC to define a stable place where you keep your prometheus data, otherwise if your pod is recreated, it starts with a clean slate. 您应该使用PV / PVC定义一个稳定的地方来保存普罗米修斯数据,否则,如果重新创建了pod,则以干净的状态开始。

PV/PVC needs dedicated storage servers in the cluster. PV / PVC在群集中需要专用的存储服务器。 If there is no money for storage servers, here is a cheaper approach: 如果没有钱购买存储服务器,这是一种更便宜的方法:

  1. Label a node: 标记节点:

     $ kubectl label nodes <node name> prometheus=yes 
  2. Force all the prometheus pods to be created on the same labeled node by using nodeSelector : 通过使用nodeSelector在同一标签节点上创建所有nodeSelector

     nodeSelector: prometheus: yes 
  3. Create an emptyDir volume for each prometheus pod. 为每个emptyDir创建一个emptyDir卷。 An emptyDir volume is first created when the Prometheus pod is assigned to the labeled node and exists as long as that pod is running on that node and is safe across container crashes and pod restarts. 当Prometheus Pod分配给带标签的节点时,只要该Pod在该节点上运行并且在容器崩溃和Pod重新启动时是安全的,它便会首先创建emptyDir卷。

     spec: containers: - image: <prometheus image> name: <prometheus pod name> volumeMounts: - mountPath: /cache name: cache-volume volumes: - name: cache-volume emptyDir: {} 

This approach makes all the Prometheus pods run on the same node with persistent storage for the metrics - a cheaper approach that prays the Prometheus node does not crash. 这种方法使所有Prometheus Pod都在具有持久存储指标的同一个节点上运行-一种较便宜的方法,祈祷Prometheus节点不会崩溃。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM