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

Adding Error Counter Metric #128

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Metrics struct {

registry *prometheus.Registry
containerImageVersion *prometheus.GaugeVec
containerImageErrors *prometheus.CounterVec
log *logrus.Entry

// container cache stores a cache of a container's current image, version,
Expand All @@ -47,14 +48,26 @@ func New(log *logrus.Entry) *Metrics {
"namespace", "pod", "container", "image", "current_version", "latest_version",
},
)
containerImageErrors := prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "version_checker",
Name: "image_failures",
Help: "Where the version-checker was unable to get the latest upstream registry version",
},
[]string{
"namespace", "pod", "container", "image",
},
)

registry := prometheus.NewRegistry()
registry.MustRegister(containerImageVersion)
registry.MustRegister(containerImageErrors)

return &Metrics{
log: log.WithField("module", "metrics"),
registry: registry,
containerImageVersion: containerImageVersion,
containerImageErrors: containerImageErrors,
containerCache: make(map[string]cacheItem),
}
}
Expand Down