gitlab有哪些metrics

默认有哪些指标收集job

prometheus.yml文件中定义了默认的job。配置文件在prometheus数据目录下 ,gitlab.rb配置文件中有定义位置:

prometheus['home'] = ''

默认job;访问方式:

  • gitaly;访问方式:ip:9236/metrics
  • gitlab sidekiq;访问方式:ip:8082/metrics
  • gitlab workhorse;访问方式:ip:9229/metrics
  • gitlab rails(puma);访问方式:127.0.0.1:8080/-/metrics,ip:(80/443)/-/metrics
  • gitlab_exporter;访问方式:ip:9168/metrics
  • nginx;访问方式:ip:8060/metrics
  • prometheus;访问方式:ip:9090/metrics
  • node_exporter;访问方式:ip:9100/metrics
  • redis_exporter;访问方式:ip:9121/metrics
  • postgres_exporter;访问方式:ip:9187/metrics
  • kubernetes相关

gitlab.rb配置文件修改监听

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",
}

使用外部prometheus的job配置示例

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。

参考文档

Monitoring GitLab with Prometheus | GitLabDocumentation for GitLab Community Edition, GitLab Enterprise Edition, Omnibus GitLab, and GitLab Runner.https://docs.gitlab.com/15.3/ee/administration/monitoring/prometheus/index.html#gitlab-metrics

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值