10

解决 gitlab 因 Prometheus 磁盘占用过大的问题

 2 years ago
source link: https://zhiqiang.org/it/gitlab-prometheus-use-too-many-storage.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

解决 gitlab 因 Prometheus 磁盘占用过大的问题

作者: 张志强

, 发表于 2022-06-14

, 共 822 字 , 共阅读 13 次

用 gitlab 搭建的 git 私有服务器,占用空间不断增长,已高达 400G。仔细检查了一下,真正的库数据/var/opt/gitlab/git-data/repositories只有 7 个 G ,真正占用空间的是/var/opt/gitlab/prometheus/data,占用了将近 400G ,里面很多 80M 一个的大文件。

/var/opt/gitlab/prometheus/data是 Prometheus 生成的监控数据文件,可参考文档Monitoring GitLab with Prometheus

我们可以通过修改配置文件,停用该服务、降低占用或者换目录地址。首先编辑配置文件:

sudo -E vim /etc/gitlab/gitlab.rb

打开之后可通过下面这一行直接关闭服务:

prometheus['enable'] = false

也可以设置数据天数,以及数据目录地址:

prometheus['flags'] = {
   'storage.tsdb.path' => "/var/opt/gitlab/prometheus/data",
   'storage.tsdb.retention.time' => "15d",
   'config.file' => "/var/opt/gitlab/prometheus/prometheus.yml"
}

注意,如果设置新目录,目录所有者和组需先设置为gitlab-prometheus

保存配置,再重启 gitalb 即可:

sudo gitlab-ctl stop
sudo gitlab-ctl reconfigure
sudo gitlab-ctl start 

Q. E. D.

avatar-0.jpg

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK