Prometheus Operator 修改数据存储时间

官方文档可以配置的说明

实际上修改prometheus operator时间是通过retention参数进行修改,上面也提示了在prometheus.spec下填写

#接下来进行填写,首先我们先下载operator,并将目录进行分类
wget -P /root/ http://down.i4t.com/abcdocker-prometheus-operator.yaml.zip
cd /root/
unzip abcdocker-prometheus-operator.yaml.zip
mkdir kube-prom
cp -a kube-prometheus-master/manifests/* kube-prom/
cd kube-prom/
mkdir -p node-exporter alertmanager grafana kube-state-metrics prometheus serviceMonitor adapter operator
mv *-serviceMonitor* serviceMonitor/
mv setup operator/
mv grafana-* grafana/
mv kube-state-metrics-* kube-state-metrics/
mv alertmanager-* alertmanager/
mv node-exporter-* node-exporter/
mv prometheus-adapter* adapter/
mv prometheus-* prometheus/
mv 0prometheus-operator-* operator/
mv 00namespace-namespace.yaml operator/
 
 
#接下来需要修改prometheus operator的deployment文件
cd /root/kube-prom/prometheus/
vim prometheus-prometheus.yaml
在spec.下面添加
retention: 7d

如果已经安装了可以直接修改prometheus-prometheus.yaml 然后通过kubectl apply -f 刷新即可

修改完毕后检查pod运行状态是否正常

[root@YZSJHL82-101 ~]# kubectl  get all -n monitoring 
NAME                                       READY   STATUS    RESTARTS   AGE
pod/alertmanager-main-0                    2/2     Running   0          44h
pod/alertmanager-main-1                    2/2     Running   0          44h
pod/alertmanager-main-2                    2/2     Running   0          44h
pod/grafana-558647b59-tlp8s                1/1     Running   0          44h
pod/kube-state-metrics-5bfc7db74d-8d4jk    4/4     Running   0          44h
pod/node-exporter-jwl9v                    2/2     Running   0          44h
pod/node-exporter-nxn2w                    2/2     Running   0          44h
pod/node-exporter-s6lpr                    2/2     Running   0          44h
pod/prometheus-adapter-57c497c557-svfs8    1/1     Running   0          44h
pod/prometheus-k8s-0                       3/3     Running   1          44h
pod/prometheus-k8s-1                       3/3     Running   1          44h
pod/prometheus-operator-69bd579bf9-tzr5z   1/1     Running   0          44h
 
NAME                            TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)             AGE
service/alertmanager-main       ClusterIP   10.254.149.37            9093/TCP            44h
service/alertmanager-operated   ClusterIP   None                     9093/TCP,6783/TCP   44h
service/grafana                 NodePort    10.254.134.244           3000:20614/TCP      44h
service/kube-state-metrics      ClusterIP   None                     8443/TCP,9443/TCP   44h
service/node-exporter           ClusterIP   None                     9100/TCP            44h
service/prometheus-adapter      ClusterIP   10.254.7.111             443/TCP             44h
service/prometheus-k8s          NodePort    10.254.130.51            9090:13535/TCP      44h
service/prometheus-operated     ClusterIP   None                     9090/TCP            44h
service/prometheus-operator     ClusterIP   None                     8080/TCP            44h
 
NAME                           DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR                 AGE
daemonset.apps/node-exporter   3         3         3       3            3           beta.kubernetes.io/os=linux   44h
 
NAME                                  READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/grafana               1/1     1            1           44h
deployment.apps/kube-state-metrics    1/1     1            1           44h
deployment.apps/prometheus-adapter    1/1     1            1           44h
deployment.apps/prometheus-operator   1/1     1            1           44h
 
NAME                                             DESIRED   CURRENT   READY   AGE
replicaset.apps/grafana-558647b59                1         1         1       44h
replicaset.apps/kube-state-metrics-5bfc7db74d    1         1         1       44h
replicaset.apps/prometheus-adapter-57c497c557    1         1         1       44h
replicaset.apps/prometheus-operator-69bd579bf9   1         1         1       44h
 
NAME                                 READY   AGE
statefulset.apps/alertmanager-main   3/3     44h
statefulset.apps/prometheus-k8s      2/2     44h

接下来可以访问grafana或者prometheus ui进行检查 (我这里修改完毕后等待2天,检查数据是否正常)

修改前

修改后

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

CN-FuWei

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值