<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # Monitoring GitLab with Prometheus > 原文:[https://docs.gitlab.com/ee/administration/monitoring/prometheus/](https://docs.gitlab.com/ee/administration/monitoring/prometheus/) * [Overview](#overview) * [Configuring Prometheus](#configuring-prometheus) * [Changing the port and address Prometheus listens on](#changing-the-port-and-address-prometheus-listens-on) * [Adding custom scrape configurations](#adding-custom-scrape-configurations) * [Using an external Prometheus server](#using-an-external-prometheus-server) * [Viewing performance metrics](#viewing-performance-metrics) * [Prometheus as a Grafana data source](#prometheus-as-a-grafana-data-source) * [GitLab metrics](#gitlab-metrics) * [Bundled software metrics](#bundled-software-metrics) * [Node exporter](#node-exporter) * [Redis exporter](#redis-exporter) * [PostgreSQL exporter](#postgresql-exporter) * [PgBouncer exporter](#pgbouncer-exporter) * [Registry exporter](#registry-exporter) * [GitLab exporter](#gitlab-exporter) * [Configuring Prometheus to monitor Kubernetes](#configuring-prometheus-to-monitor-kubernetes) # Monitoring GitLab with Prometheus[](#monitoring-gitlab-with-prometheus "Permalink") > **Notes:** > > * 本頁中列出的 Prometheus 和各種出口商都捆綁在 Omnibus GitLab 軟件包中. 查看每個出口商的文檔以了解添加的時間表. 對于源安裝,您必須自己安裝. 在后續版本中,將捕獲其他的 GitLab 指標. > * GitLab 9.0 默認情況下會啟用 Prometheus 服務. > * Prometheus 及其出口商不對用戶進行身份驗證,任何可以訪問它們的人都可以使用. [Prometheus](https://s0prometheus0io.icopy.site)是一項功能強大的時間序列監視服務,為監視 GitLab 和其他軟件產品提供了靈活的平臺. GitLab 提供了 Prometheus 的開箱即用監視功能,可輕松訪問 GitLab 服務的高質量時間序列監視. ## Overview[](#overview "Permalink") Prometheus 的工作方式是定期連接到數據源,并通過[各種出口商](#bundled-software-metrics)收集其績效指標. 要查看和使用監視數據,您可以[直接連接到 Prometheus](#viewing-performance-metrics)或使用儀表板工具(例如[Grafana)](https://grafana.com) . ## Configuring Prometheus[](#configuring-prometheus "Permalink") **注意:**對于源安裝,您必須自己安裝和配置. 從 GitLab 9.0 開始,Prometheus 及其出口商默認情況下處于打開狀態. Prometheus 將以`gitlab-prometheus`用戶身份運行,并監聽`http://localhost:9090` . 默認情況下,只能從 GitLab 服務器本身訪問 Prometheus. 除非單獨禁用,否則每個出口商將自動設置為 Prometheus 的監視目標. 要禁用 Prometheus 及其所有出口商以及將來添加的任何出口商,請執行以下操作: 1. Edit `/etc/gitlab/gitlab.rb` 2. 添加或查找并取消注釋以下行,確保將其設置為`false` : ``` prometheus_monitoring['enable'] = false ``` 3. 保存文件并[重新配置 GitLab,](../../restart_gitlab.html#omnibus-gitlab-reconfigure)以使更改生效. ### Changing the port and address Prometheus listens on[](#changing-the-port-and-address-prometheus-listens-on "Permalink") **注意:** [Omnibus GitLab 8.17 中](https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/1261)添加了以下更改. 盡管可能,但不建議更改 Prometheus 監聽的端口,因為這可能會影響 GitLab 服務器上運行的其他服務或與之沖突. 繼續需要您自擔風險. 為了從 GitLab 服務器外部訪問 Prometheus,您需要在`prometheus['listen_address']`設置 FQDN 或 IP. 更改 Prometheus 監聽的地址/端口: 1. Edit `/etc/gitlab/gitlab.rb` 2. 添加或查找并取消注釋以下行: ``` prometheus['listen_address'] = 'localhost:9090' ``` 將`localhost:9090`替換為您希望 Prometheus 監聽的地址或端口. 如果要允許除`localhost`以外的其他主機訪問 Prometheus,請忽略該主機,或使用`0.0.0.0`允許公共訪問: ``` prometheus['listen_address'] = ':9090' # or prometheus['listen_address'] = '0.0.0.0:9090' ``` 3. 保存文件并[重新配置 GitLab,](../../restart_gitlab.html#omnibus-gitlab-reconfigure)以使更改生效 ### Adding custom scrape configurations[](#adding-custom-scrape-configurations "Permalink") 您可以使用[Prometheus 刮擦目標配置](https://s0prometheus0io.icopy.site/docs/prometheus/latest/configuration/configuration/)語法在`/etc/gitlab/gitlab.rb`編輯`prometheus['scrape_configs']` , `/etc/gitlab/gitlab.rb`為 Omnibus GitLab 捆綁的 Prometheus 配置其他刮擦目標. 這是刮取`http://1.1.1.1:8060/probe?param_a=test&param_b=additional_test`的示例配置: ``` prometheus['scrape_configs'] = [ { 'job_name': 'custom-scrape', 'metrics_path': '/probe', 'params' => { 'param_a' => ['test'], 'param_b' => ['additional_test'] }, 'static_configs' => [ 'targets' => ['1.1.1.1:8060'], ], }, ] ``` ### Using an external Prometheus server[](#using-an-external-prometheus-server "Permalink") **注意:** Prometheus 和大多數導出器不支持身份驗證. 我們不建議將它們公開在本地網絡之外. 需要進行一些配置更改,才能由外部 Prometheus 服務器監視 GitLab. 對于[具有多個節點的 GitLab 部署,](../../reference_architectures/index.html)建議使用外部服務器. 要使用外部 Prometheus 服務器: 1. Edit `/etc/gitlab/gitlab.rb`. 2. 禁用捆綁的 Prometheus: ``` prometheus['enable'] = false ``` 3. 將每個捆綁服務的[導出器設置](#bundled-software-metrics)為偵聽網絡地址,例如: ``` gitlab_exporter['listen_address'] = '0.0.0.0' sidekiq['listen_address'] = '0.0.0.0' gitlab_exporter['listen_port'] = '9168' node_exporter['listen_address'] = '0.0.0.0:9100' redis_exporter['listen_address'] = '0.0.0.0:9121' postgres_exporter['listen_address'] = '0.0.0.0:9187' gitaly['prometheus_listen_addr'] = "0.0.0.0:9236" gitlab_workhorse['prometheus_listen_addr'] = "0.0.0.0:9229" ``` 4. 如有必要,請使用[官方安裝說明](https://s0prometheus0io.icopy.site/docs/prometheus/latest/installation/)安裝并設置專用的 Prometheus 實例. 5. 將 Prometheus 服務器 IP 地址添加到[監視 IP 白名單](../ip_whitelist.html) . 例如: ``` gitlab_rails['monitoring_whitelist'] = ['127.0.0.0/8', '192.168.0.1'] ``` 6. 在**所有** GitLab Rails(Puma / Unicorn,Sidekiq)服務器上,設置 Prometheus 服務器 IP 地址和監聽端口. 例如: ``` gitlab_rails['prometheus_address'] = '192.168.0.1:9090' ``` 7. 要抓取 NGINX 指標,您還需要配置 NGINX 以允許 Prometheus 服務器 IP. 例如: ``` nginx['status']['options'] = { "server_tokens" => "off", "access_log" => "off", "allow" => "192.168.0.1", "deny" => "all", } ``` 8. [重新配置 GitLab](../../restart_gitlab.html#omnibus-gitlab-reconfigure)以應用更改. 9. 編輯 Prometheus 服務器的配置文件. 10. 將每個節點的導出器添加到 Prometheus 服務器的[抓取目標配置中](https://s0prometheus0io.icopy.site/docs/prometheus/latest/configuration/configuration/) . 例如,使用`static_configs`的樣本片段: ``` 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" static_configs: - targets: - 1.1.1.1:8080 - 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 ``` 11. 重新加載 Prometheus 服務器. ## Viewing performance metrics[](#viewing-performance-metrics "Permalink") 您可以訪問`http://localhost:9090` ,以獲取 Prometheus 默認提供的儀表板. > **注意:**如果在您的 GitLab 實例上啟用了 SSL,由于[HSTS,](https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security)如果使用相同的 FQDN,則可能無法在與 GitLab 相同的瀏覽器上訪問 Prometheus. 我們計劃[通過 GitLab 提供訪問](https://gitlab.com/gitlab-org/multi-user-prometheus) ,但是在此期間,有一些解決方法:使用單獨的 FQDN,使用服務器 IP,使用單獨的 Prometheus 瀏覽器,重置 HSTS 或使用[NGINX 代理](https://docs.gitlab.com/omnibus/settings/nginx.html) . Prometheus 收集的性能數據可以在 Prometheus 控制臺中直接查看,也可以通過兼容的儀表板工具查看. Prometheus 界面提供了一種[靈活的查詢語言](https://s0prometheus0io.icopy.site/docs/prometheus/latest/querying/basics/) ,可與收集的數據一起使用,您可以在其中可視化輸出. 要獲得功能更全面的儀表板,可以使用 Grafana 并已[對 Prometheus 進行了官方支持](https://s0prometheus0io.icopy.site/docs/visualization/grafana/) . 普羅米修斯樣本查詢: * **可用內存百分比:** `((node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) or ((node_memory_MemFree_bytes + node_memory_Buffers_bytes + node_memory_Cached_bytes) / node_memory_MemTotal_bytes)) * 100` * **CPU 使用率百分比:** `1 - avg without (mode,cpu) (rate(node_cpu_seconds_total{mode="idle"}[5m]))` * **傳輸的數據:** `rate(node_network_transmit_bytes_total{device!="lo"}[5m])` * **收到的數據:** `rate(node_network_receive_bytes_total{device!="lo"}[5m])` ## Prometheus as a Grafana data source[](#prometheus-as-a-grafana-data-source "Permalink") Grafana 允許您導入 Prometheus 性能指標作為數據源,并將指標呈現為圖形和儀表板,這有助于可視化. To add a Prometheus dashboard for a single server GitLab setup: 1. 在 Grafana 中創建一個新的數據源. 2. 命名您的數據源(如 GitLab). 3. 在類型下拉框中選擇`Prometheus` . 4. 將您的 Prometheus 偵聽地址添加為 URL,并設置對`Browser`訪問權限. 5. 將 HTTP 方法設置為`GET` . 6. 保存并測試您的配置以驗證其是否有效. ## GitLab metrics[](#gitlab-metrics "Permalink") 在 GitLab 9.3 中引入. GitLab 監視其自身的內部服務指標,并使其在`/-/metrics`端點可用. 與其他導出器不同,此終結點需要身份驗證,因為它可以在與用戶流量相同的 URL 和端口上使用. [? Read more about the GitLab Metrics.](gitlab_metrics.html) ## Bundled software metrics[](#bundled-software-metrics "Permalink") Omnibus GitLab 中捆綁的許多 GitLab 依賴項都已預先配置為導出 Prometheus 指標. ### Node exporter[](#node-exporter "Permalink") 節點導出器允許您測量各種機器資源,例如內存,磁盤和 CPU 利用率. [Read more about the node exporter](node_exporter.html). ### Redis exporter[](#redis-exporter "Permalink") Redis 導出器允許您測量各種 Redis 指標. [Read more about the Redis exporter](redis_exporter.html). ### PostgreSQL exporter[](#postgresql-exporter "Permalink") PostgreSQL 導出器允許您測量各種 PostgreSQL 指標. [Read more about the PostgreSQL exporter](postgres_exporter.html). ### PgBouncer exporter[](#pgbouncer-exporter "Permalink") PgBouncer 導出器允許您測量各種 PgBouncer 指標. [Read more about the PgBouncer exporter](pgbouncer_exporter.html). ### Registry exporter[](#registry-exporter "Permalink") 注冊表導出器允許您測量各種注冊表指標. [Read more about the Registry exporter](registry_exporter.html). ### GitLab exporter[](#gitlab-exporter "Permalink") GitLab 導出器允許您測量從 Redis 和數據庫中提取的各種 GitLab 指標. [Read more about the GitLab exporter](gitlab_exporter.html). ## Configuring Prometheus to monitor Kubernetes[](#configuring-prometheus-to-monitor-kubernetes "Permalink") 版本歷史 * 在 GitLab 9.0 中引入. * 在 GitLab 9.4 中引入了 Pod 監控. 如果您的 GitLab 服務器在 Kubernetes 中運行,則 Prometheus 將從群集中的節點和帶[注釋的](https://s0prometheus0io.icopy.site/docs/prometheus/latest/configuration/configuration/) Pod 收集指標,包括每個容器上的性能數據. 如果您的 CI / CD 環境在同一群集中運行,這將特別有用,因為您可以使用[Prometheus 項目集成](../../../user/project/integrations/prometheus.html)來監視它們. 要禁用對 Kubernetes 的監視: 1. Edit `/etc/gitlab/gitlab.rb`. 2. 添加(或查找并取消注釋)以下行并將其設置為`false` : ``` prometheus['monitor_kubernetes'] = false ``` 3. 保存文件并[重新配置 GitLab,](../../restart_gitlab.html#omnibus-gitlab-reconfigure)以使更改生效.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看