环境

操作系统:CentOS 7

问题

私有化部署gitlab,后期发现磁盘占用过高,经过查询是gitlab中prometheus的data文件夹占用过大,据说这是prometheus的监控日志,我这里每天会产生大概80M左右的文件,默认是保留15天的

解决

经过查阅,网上大致给出的都是两种方式 gitlab配置文件默认位置:/etc/gitlab/gitlab.rb

方式一

直接停止prometheus的监控,操作方法,找到配置文件中以下代码块,默认是注释掉的

# prometheus['enable'] = true
# prometheus['monitor_kubernetes'] = true
# prometheus['username'] = 'gitlab-prometheus'
# prometheus['group'] = 'gitlab-prometheus'
# prometheus['uid'] = nil
# prometheus['gid'] = nil
# prometheus['shell'] = '/bin/sh'
# prometheus['home'] = '/var/opt/gitlab/prometheus'
# prometheus['log_directory'] = '/var/log/gitlab/prometheus'
# prometheus['rules_files'] = ['/var/opt/gitlab/prometheus/rules/*.rules']
# prometheus['scrape_interval'] = 15
# prometheus['scrape_timeout'] = 15
# prometheus['external_labels'] = { }
# prometheus['env_directory'] = '/opt/gitlab/etc/prometheus/env'
# prometheus['env'] = {
# 'SSL_CERT_DIR' => "/opt/gitlab/embedded/ssl/certs/"
# }

将配置文件中的

# prometheus['enable'] = true

取消注释后修改为

prometheus['enable'] = false

方式二

修改gitlab默认存储天数,默认保留15天,超过这个天数的会自动删除,找到以下代码块,默认是全部被注释掉的,需要打开,截图展示是已经打开过的

# prometheus['flags'] = {
# 'storage.tsdb.path' => "/var/opt/gitlab/prometheus/data",#默认储存路径,可修改
# 'storage.tsdb.retention.time' => "3d",#默认保留天数是15d,这里修改为3d,代表保留3天
# 'config.file' => "/var/opt/gitlab/prometheus/prometheus.yml"
# }

最后重新配置

停止

gitlab-ctl stop

重新配置

gitlab-ctl reconfigure

启动

gitlab-ctl start

我的博客即将同步至腾讯云开发者社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=3rv2fz93gikgk