@@ -25,6 +25,7 @@ type Metrics struct {
25
25
registry * prometheus.Registry
26
26
containerImageVersion * prometheus.GaugeVec
27
27
containerImageDuration * prometheus.GaugeVec
28
+ containerImageErrors * prometheus.CounterVec
28
29
29
30
// Contains all metrics for the roundtripper
30
31
roundTripper * RoundTripper
@@ -62,12 +63,23 @@ func NewServer(log *logrus.Entry) *Metrics {
62
63
},
63
64
[]string {"namespace" , "pod" , "container" , "image" },
64
65
)
66
+ containerImageErrors := promauto .With (reg ).NewCounterVec (
67
+ prometheus.CounterOpts {
68
+ Namespace : "version_checker" ,
69
+ Name : "image_failures_total" ,
70
+ Help : "Total number of errors where the version-checker was unable to get the latest upstream registry version" ,
71
+ },
72
+ []string {
73
+ "namespace" , "pod" , "container" , "image" ,
74
+ },
75
+ )
65
76
66
77
return & Metrics {
67
78
log : log .WithField ("module" , "metrics" ),
68
79
registry : reg ,
69
80
containerImageVersion : containerImageVersion ,
70
81
containerImageDuration : containerImageDuration ,
82
+ containerImageErrors : containerImageErrors ,
71
83
containerCache : make (map [string ]cacheItem ),
72
84
roundTripper : NewRoundTripper (reg ),
73
85
}
@@ -160,6 +172,11 @@ func (m *Metrics) latestImageIndex(namespace, pod, container, containerType stri
160
172
return strings .Join ([]string {namespace , pod , container , containerType }, "" )
161
173
}
162
174
175
+ func (m * Metrics ) ErrorsReporting (namespace , pod , container , imageURL string ) {
176
+
177
+ m .containerImageErrors .WithLabelValues (namespace , pod , container , imageURL ).Inc ()
178
+ }
179
+
163
180
func (m * Metrics ) buildLabels (namespace , pod , container , containerType , imageURL , currentVersion , latestVersion string ) prometheus.Labels {
164
181
return prometheus.Labels {
165
182
"namespace" : namespace ,
0 commit comments