diff --git a/internal/prometheus/constants.go b/internal/prometheus/constants.go new file mode 100644 index 000000000..32de1f1a4 --- /dev/null +++ b/internal/prometheus/constants.go @@ -0,0 +1,7 @@ +package prometheus + +const ( + Namespace = "image_builder" + ComposerSubsystem = "composer" + WorkerSubsystem = "worker" +) diff --git a/internal/prometheus/http_metrics.go b/internal/prometheus/http_metrics.go index bcc5c21a2..e49830d73 100644 --- a/internal/prometheus/http_metrics.go +++ b/internal/prometheus/http_metrics.go @@ -5,16 +5,11 @@ import ( "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, + Namespace: Namespace, + Subsystem: ComposerSubsystem, Help: "total number of http requests made to osbuild-composer", }) ) @@ -23,8 +18,8 @@ var ( // update this to count all 500s ComposeFailures = promauto.NewCounter(prometheus.CounterOpts{ Name: "total_failed_compose_requests", - Namespace: namespace, - Subsystem: subsystem, + Namespace: Namespace, + Subsystem: ComposerSubsystem, Help: "total number of failed compose requests", }) ) @@ -32,8 +27,8 @@ var ( var ( ComposeRequests = promauto.NewCounter(prometheus.CounterOpts{ Name: "total_compose_requests", - Namespace: namespace, - Subsystem: subsystem, + Namespace: Namespace, + Subsystem: ComposerSubsystem, Help: "total number of compose requests made to osbuild-composer", }) ) @@ -41,8 +36,8 @@ var ( var ( httpDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ Name: "http_duration_seconds", - Namespace: namespace, - Subsystem: subsystem, + Namespace: Namespace, + Subsystem: ComposerSubsystem, 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"}) diff --git a/internal/prometheus/job_metrics.go b/internal/prometheus/job_metrics.go index 607ba4dba..32f5fddfa 100644 --- a/internal/prometheus/job_metrics.go +++ b/internal/prometheus/job_metrics.go @@ -8,13 +8,11 @@ import ( "github.com/prometheus/client_golang/prometheus/promauto" ) -const workerSubsystem = "worker" - var ( TotalJobs = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "total_jobs", - Namespace: namespace, - Subsystem: workerSubsystem, + Namespace: Namespace, + Subsystem: WorkerSubsystem, Help: "Total jobs", }, []string{"type", "status", "tenant", "arch"}) ) @@ -22,8 +20,8 @@ var ( var ( PendingJobs = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "pending_jobs", - Namespace: namespace, - Subsystem: workerSubsystem, + Namespace: Namespace, + Subsystem: WorkerSubsystem, Help: "Currently pending jobs", }, []string{"type", "tenant"}) ) @@ -31,8 +29,8 @@ var ( var ( RunningJobs = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "running_jobs", - Namespace: namespace, - Subsystem: workerSubsystem, + Namespace: Namespace, + Subsystem: WorkerSubsystem, Help: "Currently running jobs", }, []string{"type", "tenant"}) ) @@ -40,8 +38,8 @@ var ( var ( JobDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ Name: "job_duration_seconds", - Namespace: namespace, - Subsystem: workerSubsystem, + Namespace: Namespace, + Subsystem: WorkerSubsystem, Help: "Duration spent by workers on a job.", Buckets: []float64{.1, .2, .5, 1, 2, 4, 8, 16, 32, 40, 48, 64, 96, 128, 160, 192, 224, 256, 320, 382, 448, 512, 640, 768, 896, 1024, 1280, 1536, 1792, 2049}, }, []string{"type", "status", "tenant", "arch"}) @@ -50,8 +48,8 @@ var ( var ( JobWaitDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ Name: "job_wait_duration_seconds", - Namespace: namespace, - Subsystem: workerSubsystem, + Namespace: Namespace, + Subsystem: WorkerSubsystem, Help: "Duration a job spends on the queue.", Buckets: []float64{.1, .2, .5, 1, 2, 4, 8, 16, 32, 40, 48, 64, 96, 128, 160, 192, 224, 256, 320, 382, 448, 512, 640, 768, 896, 1024, 1280, 1536, 1792, 2049}, }, []string{"type", "tenant"})