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 several Harbor components: exporter, core, jobservice, and registry. In addition to runtime and performance data, these components also expose Harbor specific metrics. The 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_task_queue_sizeThe total number of tasks per type in the queueinstance, job, typegauge
harbor_task_queue_latencyHow long ago the next job to be processed was enqueued per typeinstance, job, typegauge
harbor_task_scheduled_totalNumber of scheduled tasksinstance, jobgauge
harbor_task_concurrencyTotal number of concurrent tasks per type on a poolinstance, job, pool, typegauge

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

Harbor Jobservice metrics

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

Metrics exposed by Harbor Jobservice
NameDescriptionLabels (Values)Metric type
harbor_jobservice_infoThe information of Jobserviceinstance, job, node, pool, workersgauge
harbor_jobservice_task_totalThe number of processed tasks per job typeinstance, job, status, typecounter
harbor_jobservice_task_process_time_secondsThe duration of the task processing timeinstance, job, quantile, status, typesummary

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>']
    21. - job_name: 'harbor-jobservice'
    22. scrape_interval: 20s
    23. params:
    24. # Scrape metrics from the Harbor jobservice component
    25. comp: ['jobservice']
    26. static_configs:
    27. - 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. An example Grafana dashboard is available in the Harbor repo to help you get started visualizing Harbor metrics.

From a Kubernetes cluster

You can also use Prometheus to collect metrics from a Harbor instance deployed in your Kubernetes cluster. You should already have installed Prometheus and set up to pull metrics from your cluster.

  1. Create a ServiceMonitor in Prometheus for Harbor.

    1. apiVersion: monitoring.coreos.com/v1
    2. kind: ServiceMonitor
    3. metadata:
    4. name: harbor
    5. labels:
    6. app: harbor
    7. spec:
    8. selector:
    9. matchLabels:
    10. app: harbor
    11. endpoints:
    12. - port: metrics
  2. Enable Harbor to expose metrics by updating your harbor-helm values.yaml file and set metrics.enabled to true. You can also edit the port and path the metrics are exposed on by updating the available harbor-helm chart configuration options for metrics.

Prometheus should now show your Harbor instance’s metrics.