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

fix: update metrics from sessions started via API #1531

Merged
merged 1 commit into from
Jan 22, 2023

Conversation

SamKirsch10
Copy link
Contributor

@SamKirsch10 SamKirsch10 commented Jan 21, 2023

Description

This PR fixes #1530. Metrics are not captured and returned to the metrics handler if called via the HTTP API. This code is already implemented in the existing codebase when a schedule is triggered.

watchtower/cmd/root.go

Lines 322 to 323 in c16ac96

metric := runUpdatesWithNotifications(filter)
metrics.RegisterScan(metric)

Tests

Ran binary with the following arguments: --cleanup --schedule "0 0 4 * * *" --http-api-update --http-api-token "******" --http-api-periodic-polls --http-api-metrics. And curl'd the update endpoint. The below logs were outputted after a successful run.

INFO[0015] Updates triggered by HTTP API request.
INFO[0022] Session done                                  Failed=0 Scanned=18 Updated=0 notify=no

Finally curled the metrics endpoint and saw the correct metric was updated.

watchtower_containers_scanned 18

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congratulations on opening your first pull request! We'll get back to you as soon as possible. In the meantime, please make sure you've updated the documentation to reflect your changes and have added test automation as needed. Thanks! 🙏🏼

@codecov
Copy link

codecov bot commented Jan 22, 2023

Codecov Report

Base: 66.19% // Head: 66.19% // No change to project coverage 👍

Coverage data is based on head (8fff7ca) compared to base (c16ac96).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1531   +/-   ##
=======================================
  Coverage   66.19%   66.19%           
=======================================
  Files          24       24           
  Lines        2313     2313           
=======================================
  Hits         1531     1531           
  Misses        682      682           
  Partials      100      100           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@piksel piksel left a comment

Choose a reason for hiding this comment

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

This seems like a really straight forward fix. Good job investigating this!

@piksel piksel changed the title Fix metric updates when invoked via HTTP API fix: update metrics from sessions started via API Jan 22, 2023
@piksel piksel merged commit 87c5695 into containrrr:main Jan 22, 2023
@SamKirsch10 SamKirsch10 deleted the samkirsch10/metrics-fix branch January 31, 2023 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Metrics not being updated
2 participants