Add Prometheus metrics for image push failure alerting#56
Open
Add Prometheus metrics for image push failure alerting#56
Conversation
Author
|
@kebe7jun 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Co-authored-by: kebe7jun <7303612+kebe7jun@users.noreply.github.com>
Co-authored-by: kebe7jun <7303612+kebe7jun@users.noreply.github.com>
Co-authored-by: kebe7jun <7303612+kebe7jun@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [Feature Request] Support alerting on image push failure
Add Prometheus metrics for image push failure alerting
Sep 8, 2025
Collaborator
|
@kebe7jun 这个pr啥时候能合入哇 |
Collaborator
你帮忙测试 Review 一下? |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #56 +/- ##
==========================================
+ Coverage 22.03% 23.60% +1.57%
==========================================
Files 6 7 +1
Lines 926 953 +27
==========================================
+ Hits 204 225 +21
- Misses 701 706 +5
- Partials 21 22 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements Prometheus metrics to enable reliable alerting on image push failures in kube-snapshot, addressing the need for explicit, machine-readable indicators of push operations.
Problem
Previously, when image push operations failed (due to registry auth issues, network problems, or other errors), the only way to detect failures was through log parsing or generic task status monitoring. This made it difficult for platform teams to:
Solution
Added comprehensive Prometheus metrics that expose detailed information about image push operations:
New Metrics
snapshot_image_push_total- Counter tracking all push attempts with labels:namespace,pod,image- Resource identificationstatus- "success" or "failure"reason- Failure categorization (auth_error, push_failed, image_not_exists, runtime_error)snapshot_image_push_failures_total- Counter tracking only failed pushes with detailed failure reasonssnapshot_tasks_total- Counter tracking task phase transitions (CREATED, COMPLETED, FAILED)Key Features
:8080Example Usage
Alerting Examples
Implementation Details
internal/metricspackage with Prometheus counter definitionsreconcilePushImagefunction to record metrics on success/failure:8080The implementation provides the explicit, machine-readable indicators requested, enabling platform teams to build reliable monitoring and alerting around image push operations.
Fixes #55.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://storage.googleapis.com/storage/v1/b/kubebuilder-tools/o/kubebuilder-tools-1.30.0-linux-amd64.tar.gz/home/REDACTED/work/kube-snapshot/kube-snapshot/bin/setup-envtest-release-0.18 use 1.30.0 --bin-dir /home/REDACTED/work/kube-snapshot/kube-snapshot/bin -p path(http block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.