Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature export Harbor statistics as Prometheus metric #18679

Merged

Conversation

tpoxa
Copy link
Contributor

@tpoxa tpoxa commented May 15, 2023

This PR exposes the Harbor statistics as Prometheus metric.

The data exposed as metrics are 1:1 taken from thestatistics API, including the name.

New Metrics

  • harbor_statistics_private_project_amount
  • harbor_statistics_private_repo_amount
  • harbor_statistics_public_project_amount
  • harbor_statistics_public_repo_amount
  • harbor_statistics_total_project_amount
  • harbor_statistics_total_repo_amount
  • harbor_statistics_total_storage_consumption

Please indicate you've done the following:

  • Well-Written Title and Summary of the PR
  • Label the PR as needed. release-note/enhancement
  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Made sure tests are passing and test coverage is added if needed.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed in website repository.

@tpoxa tpoxa requested a review from a team as a code owner May 15, 2023 19:49
@codecov
Copy link

codecov bot commented May 15, 2023

Codecov Report

Attention: Patch coverage is 58.88889% with 37 lines in your changes missing coverage. Please review.

Project coverage is 66.27%. Comparing base (c8c11b4) to head (7ea6628).
Report is 265 commits behind head on main.

Files Patch % Lines
src/pkg/exporter/statistics_collector.go 60.91% 27 Missing and 7 partials ⚠️
src/pkg/exporter/exporter.go 0.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main   #18679       +/-   ##
===========================================
+ Coverage   45.36%   66.27%   +20.90%     
===========================================
  Files         244     1047      +803     
  Lines       13333   114251   +100918     
  Branches     2719     2845      +126     
===========================================
+ Hits         6049    75722    +69673     
- Misses       6983    34400    +27417     
- Partials      301     4129     +3828     
Flag Coverage Δ
unittests 66.27% <58.88%> (+20.90%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/pkg/exporter/exporter.go 6.66% <0.00%> (ø)
src/pkg/exporter/statistics_collector.go 60.91% <60.91%> (ø)

... and 1285 files with indirect coverage changes

@Vad1mo Vad1mo added the release-note/enhancement Label to mark PR to be added under release notes as enhancement label May 15, 2023
@tpoxa tpoxa force-pushed the feature/global-storage-usage-metric branch 2 times, most recently from b5391d5 to becc332 Compare May 15, 2023 21:30
@Vad1mo Vad1mo changed the title Feature/global storage usage metric Feature export Harbor statistics as Prometheus metric May 19, 2023
@tpoxa tpoxa force-pushed the feature/global-storage-usage-metric branch 5 times, most recently from 47e5614 to a60cc15 Compare May 21, 2023 16:07
Copy link
Member

@Vad1mo Vad1mo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great, thank you

@github-actions
Copy link

This PR is being marked stale due to a period of inactivty. If this PR is still relevant, please comment or remove the stale label. Otherwise, this PR will close in 30 days.

@github-actions github-actions bot added the Stale label Jul 21, 2023
@github-actions
Copy link

This PR was closed because it has been stalled for 30 days with no activity. If this PR is still relevant, please re-open a new PR against main.

@github-actions github-actions bot closed this Aug 21, 2023
@Vad1mo Vad1mo added never-stale Do not stale and removed Stale labels Nov 18, 2023
@Vad1mo Vad1mo reopened this Nov 18, 2023
@Vad1mo Vad1mo enabled auto-merge (squash) November 18, 2023 15:00
@Vad1mo Vad1mo force-pushed the feature/global-storage-usage-metric branch from a60cc15 to c36292d Compare November 18, 2023 15:04
Vad1mo added a commit to goharbor/website that referenced this pull request Nov 20, 2023
Vad1mo added a commit to container-registry/harbor-next that referenced this pull request Nov 20, 2023
@wy65701436
Copy link
Contributor

@Vad1mo since we've reached the FC of v2.10 this week, I just put it into the v2.11 candidate.

@wy65701436 wy65701436 disabled auto-merge January 15, 2024 05:46
@tpoxa tpoxa force-pushed the feature/global-storage-usage-metric branch 3 times, most recently from a4c1d63 to 620d00d Compare February 14, 2024 22:12
Signed-off-by: Maksym Trofimenko <[email protected]>
@tpoxa tpoxa force-pushed the feature/global-storage-usage-metric branch from 620d00d to 5c949c1 Compare February 25, 2024 15:23
@Vad1mo
Copy link
Member

Vad1mo commented Apr 9, 2024

@wy65701436 any chance we can get this merged into 2.11?

@Vad1mo Vad1mo enabled auto-merge (squash) May 28, 2024 12:56
Vad1mo added a commit that referenced this pull request Jun 18, 2024
@Vad1mo
Copy link
Member

Vad1mo commented Aug 27, 2024

@goharbor/all-maintainers, can we get this merged? we have it now running since 1 year in prod across multiple instances and I don't see a reason not merging it.

@Vad1mo Vad1mo merged commit 44284ac into goharbor:main Aug 27, 2024
12 checks passed
@chlins
Copy link
Member

chlins commented Aug 28, 2024

@tpoxa Hi, I have several questions about this PR, as follows:

  1. The description says that the metric name taken from response from statistics API, but in the API response it is private_project_count not private_project_amount, and IMH the name should follow the name style of previous metrics.
  2. I think some metrics are duplicated with previous metrics, FYI: https://goharbor.io/docs/main/administration/metrics/.
  3. The docs should be updated as well if we add some new metrics to harbor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
candidate/2.12.0 never-stale Do not stale release-note/enhancement Label to mark PR to be added under release notes as enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants