metrics: add prometheus namespaces
Make use of the prometheus namespace and subsystem to give the metrics a consistent namespaces in openshift.
This commit is contained in:
parent
c8f198166d
commit
91f2457363
3 changed files with 49 additions and 47 deletions
49
internal/prometheus/http_metrics.go
Normal file
49
internal/prometheus/http_metrics.go
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
package prometheus
|
||||
|
||||
import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
)
|
||||
|
||||
const (
|
||||
namespace = "image_builder"
|
||||
subsystem = "composer"
|
||||
)
|
||||
|
||||
var (
|
||||
TotalRequests = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "total_requests",
|
||||
Namespace: namespace,
|
||||
Subsystem: subsystem,
|
||||
Help: "total number of http requests made to osbuild-composer",
|
||||
})
|
||||
)
|
||||
|
||||
var (
|
||||
// update this to count all 500s
|
||||
ComposeFailures = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "total_failed_compose_requests",
|
||||
Namespace: namespace,
|
||||
Subsystem: subsystem,
|
||||
Help: "total number of failed compose requests",
|
||||
})
|
||||
)
|
||||
|
||||
var (
|
||||
ComposeRequests = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "total_compose_requests",
|
||||
Namespace: namespace,
|
||||
Subsystem: subsystem,
|
||||
Help: "total number of compose requests made to osbuild-composer",
|
||||
})
|
||||
)
|
||||
|
||||
var (
|
||||
httpDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Name: "http_duration_seconds",
|
||||
Namespace: namespace,
|
||||
Subsystem: subsystem,
|
||||
Help: "Duration of HTTP requests.",
|
||||
Buckets: []float64{.025, .05, .075, .1, .2, .5, .75, 1, 1.5, 2, 3, 4, 5, 6, 8, 10, 12, 14, 16, 20},
|
||||
}, []string{"path"})
|
||||
)
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
package prometheus
|
||||
|
||||
import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
)
|
||||
|
||||
var (
|
||||
TotalRequests = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "composer_total_http_requests",
|
||||
Help: "total number of http requests made to osbuild-composer",
|
||||
})
|
||||
)
|
||||
|
||||
var (
|
||||
ComposeRequests = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "total_compose_requests",
|
||||
Help: "total number of compose requests made to osbuild-composer",
|
||||
})
|
||||
)
|
||||
|
||||
var (
|
||||
ComposeSuccesses = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "total_successful_compose_requests",
|
||||
Help: "total number of successful compose requests",
|
||||
})
|
||||
)
|
||||
|
||||
var (
|
||||
ComposeFailures = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "total_failed_compose_requests",
|
||||
Help: "total number of failed compose requests",
|
||||
})
|
||||
)
|
||||
|
||||
var (
|
||||
httpDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Name: "composer_http_duration_seconds",
|
||||
Help: "Duration of HTTP requests.",
|
||||
Buckets: []float64{.025, .05, .075, .1, .2, .5, .75, 1, 1.5, 2, 3, 4, 5, 6, 8, 10, 12, 14, 16, 20},
|
||||
}, []string{"path"})
|
||||
)
|
||||
|
|
@ -21,7 +21,6 @@ import (
|
|||
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/jobqueue"
|
||||
"github.com/osbuild/osbuild-composer/internal/prometheus"
|
||||
"github.com/osbuild/osbuild-composer/internal/worker/api"
|
||||
)
|
||||
|
||||
|
|
@ -306,10 +305,6 @@ func (s *Server) FinishJob(token uuid.UUID, result json.RawMessage) error {
|
|||
return fmt.Errorf("error finding job status: %v", err)
|
||||
}
|
||||
|
||||
if jobResult.Success {
|
||||
prometheus.ComposeSuccesses.Inc()
|
||||
}
|
||||
|
||||
// Move artifacts from the temporary location to the final job
|
||||
// location. Log any errors, but do not treat them as fatal. The job is
|
||||
// already finished.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue