【发布时间】:2019-08-02 01:11:07
【问题描述】:
我们正在尝试使用 Grafana 和 Prometheus Operator 监控 K8S。大多数指标都按预期工作,我能够看到具有正确值的仪表板,我们的系统包含 10 个节点,总共 500 个 pod。现在,当我重新启动 Prometheus 时,所有数据都已删除。我希望它保存两周。
我的问题是,如何定义 Prometheus 卷以将数据保留两周或 100GB 数据库。
我发现了以下内容(我们使用Prometheus 运算符):
https://github.com/coreos/prometheus-operator/blob/master/Documentation/user-guides/storage.md
这是 Prometheus Operator 的配置
apiVersion: apps/v1beta2
kind: Deployment
metadata:
labels:
k8s-app: prometheus-operator
name: prometheus-operator
namespace: monitoring
spec:
replicas: 1
selector:
matchLabels:
k8s-app: prometheus-operator
template:
metadata:
labels:
k8s-app: prometheus-operator
spec:
containers:
- args:
- --kubelet-service=kube-system/kubelet
- --logtostderr=true
- --config-reloader-image=quay.io/coreos/configmap-reload:v0.0.1
- --prometheus-config-reloader=quay.io/coreos/prometheus-config-reloader:v0.29.0
image: quay.io/coreos/prometheus-operator:v0.29.0
name: prometheus-operator
ports:
- containerPort: 8080
name: http
这是 Prometheus 的配置
apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
name: prometheus
namespace: monitoring
labels:
prometheus: prometheus
spec:
replica: 2
serviceAccountName: prometheus
serviceMonitorNamespaceSelector: {}
serviceMonitorSelector:
matchLabels:
role: observeable
tolerations:
- key: "WorkGroup"
operator: "Equal"
value: "operator"
effect: "NoSchedule"
- key: "WorkGroup"
operator: "Equal"
value: "operator"
effect: "NoExecute"
resources:
limits:
cpu: 8000m
memory: 24000Mi
requests:
cpu: 6000m
memory: 6000Mi
storage:
volumeClaimTemplate:
spec:
selector:
matchLabels:
app: prometheus
resources:
requests:
storage: 100Gi
https://github.com/coreos/prometheus-operator/blob/master/Documentation/user-guides/storage.md
我们有文件系统(nfs),上面的存储配置不起作用, 我的问题是:
- 我在这里想念的是如何在下面的
nfs部分下配置volume、server、path?我应该在哪里找到这个/path/to/prom/db?我怎样才能参考它?我应该以某种方式创建它,还是只提供路径?
我们在系统中配置了 NFS。
- 如何与 Prometheus 结合?
由于我对pvc 和pv 没有深入了解,我创建了以下内容(不确定这些值,我的服务器是什么以及我应该提供什么路径)...
server: myServer
path: "/path/to/prom/db"
我应该放什么以及如何使 我的 Prometheus(即我在问题中提供的配置)来使用它?
apiVersion: v1
kind: PersistentVolume
metadata:
name: prometheus
namespace: monitoring
labels:
app: prometheus
prometheus: prometheus
spec:
capacity:
storage: 100Gi
accessModes:
- ReadWriteOnce # required
nfs:
server: myServer
path: "/path/to/prom/db"
除了nfs 之外,我是否可以将任何其他持久性卷用于我的用例?请指教如何。
【问题讨论】:
-
查询是否直接从 Prometheus 工作?我的意思是当你直接从 Prometheus UI 查询时。
-
您还启用了审核日志记录吗?如果是,您能否看到 API 请求是否从 prometheus 服务帐户/用户发送到 API 服务器?
-
@JasonStanley - 感谢您的建议,我应该如何在 Prometheus
{pod=~"^$Pod$"})查询 UI 中使用它?我想运行查询以获取all pods in the cluster的数据 ...(所有节点 pod) -
在 prometheus UI 中,只需运行查询
kube_pod_container_resource_limits_cpu_cores这应该会返回所有 pod 的一长串指标列表。如果此结果返回,则表示 prometheus 配置正常,需要在 Grafana 上进行一些调整。但是,如果您没有收到对查询的响应,那么问题出在您的 Prometheus 配置上。 -
是的,您的查询只能是
kube_pod_container_resource_limits_cpu_cores
标签: amazon-web-services kubernetes google-cloud-platform prometheus prometheus-operator