使用外部prometheus
准备一个虚拟机(此处用vagrant)
vagrant init envimation/ubuntu-xenial
修改Vagrantfile
配置网络模式和Ip
config.vm.network "public_network", ip:"192.168.1.22"
配置内存大小,此处2G
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
vagrant ssh
下载prometheus
tar zxf prometheus-2.6.0.linux-amd64.tar.gz
cd prometheus-2.6.0.linux-amd64
修改gitlab.rb,如下
禁用自带的prometheus
prometheus['enable'] = false
配置exporter
gitlab_monitor['listen_address'] = '0.0.0.0'
gitlab_monitor['listen_port'] = '9168'
gitaly['prometheus_listen_addr'] = "0.0.0.0:9236"
node_exporter['listen_address'] = '0.0.0.0:9100'
gitlab_rails['monitoring_whitelist'] = ['127.0.0.0/8', '192.168.1.22']
修改prometheus的scape_configs,内容如下
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
static_configs:
- targets: ['0.0.0.0:9090']
- job_name: 'gitlab_exporters'
static_configs:
- targets: ['192.168.1.19:9168', '192.168.1.19:9236', '192.168.1.19:9100']
- job_name: 'gitlab_metrics'
metrics_path: /-/metrics
static_configs:
- targets: ['192.168.1.19:443']