Cloud Native 6 min read

How to Set Up Harbor Monitoring with Prometheus and Grafana

Learn step‑by‑step how to deploy the harbor‑exporter, configure Prometheus to scrape Harbor metrics, verify data collection, and add official Grafana dashboards, enabling real‑time monitoring of your Harbor registry for improved stability, security, and performance in cloud‑native environments.

Linux Ops Smart Journey
Linux Ops Smart Journey
Linux Ops Smart Journey
How to Set Up Harbor Monitoring with Prometheus and Grafana

As cloud computing and micro‑service architectures become mainstream, container technologies are essential, but managing many containers grows complex. Harbor, an open‑source enterprise‑grade Docker registry, offers secure image storage and built‑in monitoring, allowing enterprises to track container health and respond quickly.

Deploy harbor‑exporter

Add Harbor deployment parameters to enable metrics exposure:

<code>$ cat <<'EOF' | sudo tee -a /etc/kubernetes/addons/harbor-value.yml
# harbor exposes metrics data
metrics:
  enabled: true
EOF</code>

Upgrade the Harbor release with the new values:

<code>$ helm -n harbor upgrade harbor -f /etc/kubernetes/addons/harbor-value.yml /etc/kubernetes/addons/harbor</code>

Verify the pods are running:

<code>$ kubectl -n harbor get pod
NAME                                 READY   STATUS    RESTARTS   AGE
harbor-core-655b8cdd5d-n7vbx        1/1     Running   0          71s
harbor-core-655b8cdd5d-pb896        1/1     Running   0          51s
harbor-exporter-5b789d5fb6-4dcr2    1/1     Running   0          71s
harbor-exporter-5b789d5fb6-6lzgf    1/1     Running   0          95s
harbor-jobservice-69c54699b9-8wlhw 1/1     Running   0          71s
harbor-jobservice-69c54699b9-tsbm7 1/1     Running   0          41s
harbor-portal-767957d4c6-ggrc2      1/1     Running   1 (168m ago) 29h
harbor-portal-767957d4c6-lkrsj      1/1     Running   1 (168m ago) 30h
harbor-registry-86b67f89fc-7w67v   2/2     Running   0          68s
harbor-registry-86b67f89fc-rbqtf   2/2     Running   0          71s
harbor-trivy-0                       1/1     Running   1 (168m ago) 29h
harbor-trivy-1                       1/1     Running   1 (168m ago) 30h</code>

Prometheus collects Harbor metrics

Edit the Prometheus ConfigMap to add scrape jobs for Harbor components:

<code>$ kubectl -n kube-system edit cm prometheus
    - job_name: 'harbor-exporter'
      scrape_interval: 15s
      kubernetes_sd_configs:
      - role: service
      relabel_configs:
      - source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name, __meta_kubernetes_service_port_name]
        action: keep
        regex: harbor;harbor-exporter;http-metrics

    - job_name: 'harbor-core'
      scrape_interval: 15s
      kubernetes_sd_configs:
      - role: service
      relabel_configs:
      - source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name, __meta_kubernetes_service_port_name]
        action: keep
        regex: harbor;harbor-core;http-metrics

    - job_name: 'harbor-registry'
      scrape_interval: 15s
      kubernetes_sd_configs:
      - role: service
      relabel_configs:
      - source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name, __meta_kubernetes_service_port_name]
        action: keep
        regex: harbor;harbor-registry;http-metrics

    - job_name: 'harbor-jobservice'
      scrape_interval: 15s
      kubernetes_sd_configs:
      - role: service
      relabel_configs:
      - source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name, __meta_kubernetes_service_port_name]
        action: keep
        regex: harbor;harbor-jobservice;http-metrics</code>

Check that Prometheus successfully scrapes the jobs:

<code>$ curl -s $(kubectl -n kube-system get svc prometheus -ojsonpath='{.spec.clusterIP}:{.spec.ports[0].port}')/prometheus/api/v1/query --data-urlencode 'query=up{job=~"harbor-.*"}' | jq '.data.result[] | {job: .metric.job, status: .value[1]}'
{ "job": "harbor-core", "status": "1" }
{ "job": "harbor-exporter", "status": "1" }
{ "job": "harbor-jobservice", "status": "1" }
{ "job": "harbor-registry", "status": "1" }</code>

Add Harbor monitoring panel to Grafana

Import the official Harbor exporter dashboard into Grafana (JSON file available at the Harbor GitHub repository):

https://github.com/goharbor/harbor/blob/main/contrib/grafana-dashboard/metrics-example.json

Below are example screenshots of the resulting Grafana dashboards:

Tip: Register‑related metrics appear only after a pull or push action occurs.

Conclusion

In today’s fast‑changing tech landscape, effective IT infrastructure management is crucial for competitiveness. The Harbor monitoring panel equips enterprises with a powerful tool to understand and control their container ecosystem, enhancing stability, security, and overall performance. Mastering this monitoring setup delivers long‑term benefits for both daily operations and future challenges.

Monitoringcloud nativekubernetesPrometheusGrafanaHarbor
Linux Ops Smart Journey
Written by

Linux Ops Smart Journey

The operations journey never stops—pursuing excellence endlessly.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.