prometheus.yml文件中定义了默认的job。配置文件在prometheus数据目录下 ,gitlab.rb配置文件中有定义位置:
prometheus['home'] = ''
默认job;访问方式:
gitlab配置文件,prometheus、所有的监控exporter都是监听在127.0.0.1的无法直接访问到。如果需要迁移到外部prometheus,可以通过修改配置文件,将指标采集器监听到0.0.0.0上。
- #gitlay,/metrcis访问监控指标
- gitaly['prometheus_listen_addr'] = "0.0.0.0:9236"
-
- #sidekiq_exporter,/metrics访问监控指标
- sidekiq['listen_address'] = '0.0.0.0'
- sidekiq['listen_port'] = 8082
-
- #gitlab workhorse,/metrics访问监控指标
- gitlab_workhorse['prometheus_listen_addr'] = "0.0.0.0:9229"
-
- #puma(gitlab_rails),/metrcis访问监控指标
- puma['listen'] = '0.0.0.0'
- puma['port'] = 8080
-
- #nginx,监控8060端口/metrcis
- #默认在/var/opt/gitlab/nginx/conf/nginx-status.conf配置文件中配置监听
-
- #prometheus服务,/metrics访问监控指标
- prometheus['listen_address'] = '0.0.0.0:9090'
-
- #node_exporter(_database/sidekiq/ruby)
- node_exporter['listen_address'] = '0.0.0.0:9100'
-
- #gitlab_exporter
- gitlab_exporter['listen_address'] = '0.0.0.0'
- gitlab_exporter['listen_port'] = '9168'
-
- #redis_exporter
- redis_exporter['listen_address'] = '0.0.0.0:9121'
-
- #postgres_exporter
- postgres_exporter['listen_address'] = '0.0.0.0:9187'
-
- #可以使用true/false控制是否需要获取k8s监控指标
- prometheus['monitor_kubernetes'] = false
gitlab内嵌prometheus不需要配置下述权限。内嵌prometheus通过8080端口/-/metrcis获取rails指标;通过127.0.0.1:8060/metrics获取nginx指标。
prometheus服务器白名单配置(不配置不能通过80/443端口/-/metrics获取Rails指标)
gitlab_rails['monitoring_whitelist'] = ['127.0.0.0/8', '192.168.0.1']
nginx指标权限(不配置不能通过8060端口/metrics获取nginx指标)
- nginx['status']['options'] = {
- "server_tokens" => "off",
- "access_log" => "off",
- "allow" => "192.168.0.1",
- "deny" => "all",
- }
- scrape_configs:
- - job_name: nginx
- static_configs:
- - targets:
- - 1.1.1.1:8060
- - job_name: redis
- static_configs:
- - targets:
- - 1.1.1.1:9121
- - job_name: postgres
- static_configs:
- - targets:
- - 1.1.1.1:9187
- - job_name: node
- static_configs:
- - targets:
- - 1.1.1.1:9100
- - job_name: gitlab-workhorse
- static_configs:
- - targets:
- - 1.1.1.1:9229
- - job_name: gitlab-rails
- metrics_path: "/-/metrics"
- scheme: https
- static_configs:
- - targets:
- - 1.1.1.1
- - job_name: gitlab-sidekiq
- static_configs:
- - targets:
- - 1.1.1.1:8082
- - job_name: gitlab_exporter_database
- metrics_path: "/database"
- static_configs:
- - targets:
- - 1.1.1.1:9168
- - job_name: gitlab_exporter_sidekiq
- metrics_path: "/sidekiq"
- static_configs:
- - targets:
- - 1.1.1.1:9168
- - job_name: gitlab_exporter_process
- metrics_path: "/process"
- static_configs:
- - targets:
- - 1.1.1.1:9168
- - job_name: gitaly
- static_configs:
- - targets:
- - 1.1.1.1:9236
gitlab-rails job,在示例中默认是可以使用https协议获取指标。如果不支持https协议,则将scheme: https改为scheme: http,则会通过80端口获取metrics。