Access Metrics
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>
.
Name | Description | Labels (Values) | Metric type |
---|---|---|---|
harbor_project_total |
Total number of public and private projects | public (true ,false ) |
gauge |
harbor_project_repo_total |
Total number of repositories in a project | public (true ,false ), project_name |
gauge |
harbor_project_member_total |
Total number of members in a project | project_name | gauge |
harbor_project_quota_usage_byte |
Total used resources of a project | project_name | gauge |
harbor_project_quota_byte |
Quota set in a project | project_name | gauge |
harbor_artifact_pulled |
Number of images pulled in a project | project_name | gauge |
harbor_project_artifact_total |
Total number of artifacts type in a project | artifact_type , project_name, public (true ,false ) |
gauge |
harbor_health |
Current status of Harbor | gauge | |
harbor_system_info |
Information about your Harbor instance | auth_mode (db_auth , ldap_auth , uaa_auth , http_auth , oidc_auth ), harbor_version, self_registration(true ,false ) |
gauge |
harbor_up |
Running status of Harbor components | component (chartmuseum , core , database , jobservice , portal , redis , registry , registryctl , trivy ) |
gauge |
harbor_task_queue_size |
The total number of tasks per type in the queue | instance, job, type | gauge |
harbor_task_queue_latency |
How long ago the next job to be processed was enqueued per type | instance, job, type | gauge |
harbor_task_scheduled_total |
Number of scheduled tasks | instance, job | gauge |
harbor_task_concurrency |
Total number of concurrent tasks per type on a pool | instance, job, pool, type | 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
.
Name | Description | Labels (Values) | Metric type |
---|---|---|---|
harbor_core_http_inflight_requests |
The total number of requests | operation (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_seconds |
The time duration of the requests | method (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 ), quantile |
summary |
harbor_core_http_request_total |
The total number of requests | method (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
.
Name | Description | Labels (Values) | Metric type |
---|---|---|---|
registry_http_in_flight_requests |
The in-flight HTTP requests | handler | gauge |
registry_http_request_duration_seconds |
The HTTP request latencies in seconds | handler, method (GET , POST , HEAD , PATCH , PUT ), le |
histogram |
registry_http_request_size_bytes |
The HTTP request sizes in bytes. | handler, le | histogram |
Harbor Jobservice metrics
The following are metrics pulled from the Harbor Jobservice and are available at <harbor_instance>:<metrics_port>/<metrics_path>?comp=jobservice
.
Name | Description | Labels (Values) | Metric type |
---|---|---|---|
harbor_jobservice_info |
The information of Jobservice | instance, job, node, pool, workers | gauge |
harbor_jobservice_task_total |
The number of processed tasks per job type | instance, job, status, type | counter |
harbor_jobservice_task_process_time_seconds |
The duration of the task processing time | instance, job, quantile, status, type | summary |
Scrapping Metrics with Prometheus
To begin accessing your Harbor instance’s metrics with Prometheus,
-
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. -
Set up a Prometheus server, see the Prometheus documentation for more information on installing.
-
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.
scrape_configs: - job_name: 'harbor-exporter' scrape_interval: 20s static_configs: # Scrape metrics from the Harbor exporter component - targets: ['<harbor_instance>:<metrics_port>'] - job_name: 'harbor-core' scrape_interval: 20s params: # Scrape metrics from the Harbor core component comp: ['core'] static_configs: - targets: ['<harbor_instance>:<metrics_port>'] - job_name: 'harbor-registry' scrape_interval: 20s params: # Scrape metrics from the Harbor registry component comp: ['registry'] static_configs: - targets: ['<harbor_instance>:<metrics_port>'] - job_name: 'harbor-jobservice' scrape_interval: 20s params: # Scrape metrics from the Harbor jobservice component comp: ['jobservice'] static_configs: - targets: ['<harbor_instance>:<metrics_port>']
-
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.
-
Create a ServiceMonitor in Prometheus for Harbor.
apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: harbor labels: app: harbor spec: selector: matchLabels: app: harbor endpoints: - port: metrics
-
Enable Harbor to expose metrics by updating your harbor-helm
values.yaml
file and setmetrics.enabled
totrue
. 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.
On this page
Contributing