Harbor exposes some key metrics needed for operators and administrators to monitor how your Harbor instance is running in real time. Observability is a key feature for operating a service in production and using this data you can identify abnormal statuses and make informed decisions to fix issues when an error occurs. Harbor exposes metrics using the Prometheus data model so you can easily start scraping your Harbor instance’s metrics using Prometheus.

In Harbor v2.2 and later you are able to enable metrics in your Harbor configuration file. Harbor metrics are available at <harbor_instance>:<metrics_port>/<metrics_path> based on your configured values.

Harbor metrics show data related to

  • Runtime information from the GO library
  • Performance metrics about all API requests in core
  • Number of requests in flight in core
  • Metrics provided by the docker distribution itself
  • Some data related to business logic which already exist in the Harbor database

Metrics are exposed by three components: exporter, core and registry. In addition to runtime and performance data, these components expose Harbor specific metrics. Thee following sections list the available Harbor metrics.

Harbor Exporter Metrics

The exporter component metrics relate to your Harbor instance configuration and collects some data from the Harbor database. Metrics are available at <harbor_instance>:<metrics_port>/<metrics_path>.

Metrics exposed by the Harbor Exporter
NameDescriptionLabels (Values)Metric type
harbor_project_totalTotal number of public and private projectspublic (true,false)gauge
harbor_project_repo_totalTotal number of repositories in a projectpublic (true,false), project_namegauge
harbor_project_member_totalTotal number of members in a projectproject_namegauge
harbor_project_quota_usage_byteTotal used resources of a projectproject_namegauge
harbor_project_quota_byteQuota set in a projectproject_namegauge
harbor_artifact_pulledNumber of images pulled in a projectproject_namegauge
harbor_project_artifact_totalTotal number of artifacts type in a projectartifact_type , project_name, public (true,false)gauge
harbor_healthCurrent status of Harborgauge
harbor_system_infoInformation about your Harbor instanceauth_mode (db_auth, ldap_auth, uaa_auth, http_auth, oidc_auth), harbor_version, self_registration(true,false)gauge
harbor_upRunning status of Harbor componentscomponent (chartmuseum, core, database, jobservice, portal, redis, registry, registryctl, trivy)gauge

Harbor Core Metrics

The following are metrics pulled from the Harbor core pod and are available at <harbor_instance>:<metrics_port>/<metrics_path>?comp=core.

Metrics exposed by Harbor Core
NameDescriptionLabels (Values)Metric type
harbor_core_http_inflight_requestsThe total number of requestsoperation (values from operationId in Harbor API. Some legacy endpoints do not have an operationId, so the label value is unknown)gauge
harbor_core_http_request_duration_secondsThe time duration of the requestsmethod (GET, POST, HEAD, PATCH, PUT), operation (values from operationId in Harbor API. Some legacy endpoints do not have an operationId, so the label value is unknown), quantilesummary
harbor_core_http_request_totalThe total number of requestsmethod (GET, POST, HEAD, PATCH, PUT), operation (values from operationId in Harbor API. Some legacy endpoints do not have an operationId, so the label value is unknown)counter

Registry Metrics

The following are metrics pulled from the Docker distribution and are available at <harbor_instance>:<metrics_port>/<metrics_path>?comp=registry.

Metrics exposed by Harbor Core
NameDescriptionLabels (Values)Metric type
registry_http_in_flight_requestsThe in-flight HTTP requestshandlergauge
registry_http_request_duration_secondsThe HTTP request latencies in secondshandler, method (GET, POST, HEAD, PATCH, PUT), lehistogram
registry_http_request_size_bytesThe HTTP request sizes in bytes.handler, lehistogram

Scrapping Metrics with Prometheus

To begin accessing your Harbor instance’s metrics with Prometheus,

  1. Enable exposing metrics in your harbor.yml configuration file and set the port and path for metrics to be exposed on. Also see more about reconfiguring your Harbor instance.

  2. Set up a Prometheus server, see the Prometheus documentation for more information on installing.

  3. Configure your Prometheus config file to scrape Harbor metrics exposed at your configured port and path. Below is an example scrape config, see the Prometheus documentation for all available scrape configuration options.

    1. scrape_configs:
    2. - job_name: 'harbor-exporter'
    3. scrape_interval: 20s
    4. static_configs:
    5. # Scrape metrics from the Harbor exporter component
    6. - targets: ['<harbor_instance>:<metrics_port>']
    7. - job_name: 'harbor-core'
    8. scrape_interval: 20s
    9. params:
    10. # Scrape metrics from the Harbor core component
    11. comp: ['core']
    12. static_configs:
    13. - targets: ['<harbor_instance>:<metrics_port>']
    14. - job_name: 'harbor-registry'
    15. scrape_interval: 20s
    16. params:
    17. # Scrape metrics from the Harbor registry component
    18. comp: ['registry']
    19. static_configs:
    20. - targets: ['<harbor_instance>:<metrics_port>']
  4. Once you have configured your Prometheus server to collect your Harbor metrics, you can use Grafana to visualize your data.