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

Fix docs and metrics semantics #23

Merged
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions collector/dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func NewCollector(webService sapcontrol.WebService) (*dispatcherCollector, error
}

c.SetDescriptor("queue_now", "Work process current queue length", []string{"type"})
c.SetDescriptor("queue_high", "Work process highest queue length", []string{"type"})
c.SetDescriptor("queue_high", "Work process peak queue length", []string{"type"})
c.SetDescriptor("queue_max", "Work process maximum queue length", []string{"type"})
c.SetDescriptor("queue_writes", "Work process queue writes", []string{"type"})
c.SetDescriptor("queue_reads", "Work process queue reads", []string{"type"})
Expand Down Expand Up @@ -47,9 +47,9 @@ func (c *dispatcherCollector) recordWorkProcessQueueStats(ch chan<- prometheus.M
// for each work queue, we record a different line for each stat of that queue, with the type as a common label
for _, queue := range queueStatistic.Queues {
ch <- c.MakeGaugeMetric("queue_now", float64(queue.Now), queue.Type)
ch <- c.MakeGaugeMetric("queue_high", float64(queue.High), queue.Type)
ch <- c.MakeCounterMetric("queue_high", float64(queue.High), queue.Type)
ch <- c.MakeGaugeMetric("queue_max", float64(queue.Max), queue.Type)
ch <- c.MakeGaugeMetric("queue_writes", float64(queue.Writes), queue.Type)
ch <- c.MakeGaugeMetric("queue_reads", float64(queue.Reads), queue.Type)
ch <- c.MakeCounterMetric("queue_writes", float64(queue.Writes), queue.Type)
ch <- c.MakeCounterMetric("queue_reads", float64(queue.Reads), queue.Type)
}
}
8 changes: 4 additions & 4 deletions collector/dispatcher/dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func TestWorkProcessQueueStatsMetric(t *testing.T) {
}, nil)

expectedMetrics := `
# HELP sap_dispatcher_queue_high Work process highest queue length
# TYPE sap_dispatcher_queue_high gauge
# HELP sap_dispatcher_queue_high Work process peak queue length
# TYPE sap_dispatcher_queue_high counter
sap_dispatcher_queue_high{type="ABAP/BTC"} 2
sap_dispatcher_queue_high{type="ABAP/DIA"} 5
sap_dispatcher_queue_high{type="ABAP/ENQ"} 0
Expand Down Expand Up @@ -72,7 +72,7 @@ func TestWorkProcessQueueStatsMetric(t *testing.T) {
sap_dispatcher_queue_now{type="ABAP/UPD"} 0
sap_dispatcher_queue_now{type="ICM/Intern"} 0
# HELP sap_dispatcher_queue_reads Work process queue reads
# TYPE sap_dispatcher_queue_reads gauge
# TYPE sap_dispatcher_queue_reads counter
sap_dispatcher_queue_reads{type="ABAP/BTC"} 10464
sap_dispatcher_queue_reads{type="ABAP/DIA"} 447173
sap_dispatcher_queue_reads{type="ABAP/ENQ"} 0
Expand All @@ -82,7 +82,7 @@ func TestWorkProcessQueueStatsMetric(t *testing.T) {
sap_dispatcher_queue_reads{type="ABAP/UPD"} 3491
sap_dispatcher_queue_reads{type="ICM/Intern"} 34877
# HELP sap_dispatcher_queue_writes Work process queue writes
# TYPE sap_dispatcher_queue_writes gauge
# TYPE sap_dispatcher_queue_writes counter
sap_dispatcher_queue_writes{type="ABAP/BTC"} 10464
sap_dispatcher_queue_writes{type="ABAP/DIA"} 447173
sap_dispatcher_queue_writes{type="ABAP/ENQ"} 0
Expand Down
90 changes: 44 additions & 46 deletions collector/enqueue_server/enqueue_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,33 @@ func NewCollector(webService sapcontrol.WebService) (*enqueueServerCollector, er
webService,
}

// TO-DO: describe all these metrics
// https://github.com/SUSE/sap_host_exporter/issues/11
c.SetDescriptor("owner_now", "TBD", nil)
c.SetDescriptor("owner_high", "TBD", nil)
c.SetDescriptor("owner_max", "TBD", nil)
c.SetDescriptor("owner_state", "TBD", nil)
c.SetDescriptor("arguments_now", "TBD", nil)
c.SetDescriptor("arguments_high", "TBD", nil)
c.SetDescriptor("arguments_max", "TBD", nil)
c.SetDescriptor("arguments_state", "TBD", nil)
c.SetDescriptor("locks_now", "TBD", nil)
c.SetDescriptor("locks_high", "TBD", nil)
c.SetDescriptor("locks_max", "TBD", nil)
c.SetDescriptor("locks_state", "TBD", nil)
c.SetDescriptor("enqueue_requests", "TBD", nil)
c.SetDescriptor("enqueue_rejects", "TBD", nil)
c.SetDescriptor("enqueue_errors", "TBD", nil)
c.SetDescriptor("dequeue_requests", "TBD", nil)
c.SetDescriptor("dequeue_errors", "TBD", nil)
c.SetDescriptor("dequeue_all_requests", "TBD", nil)
c.SetDescriptor("cleanup_requests", "TBD", nil)
c.SetDescriptor("backup_requests", "TBD", nil)
c.SetDescriptor("reporting_requests", "TBD", nil)
c.SetDescriptor("compress_requests", "TBD", nil)
c.SetDescriptor("verify_requests", "TBD", nil)
c.SetDescriptor("lock_time", "TBD", nil)
c.SetDescriptor("lock_wait_time", "TBD", nil)
c.SetDescriptor("server_time", "TBD", nil)
c.SetDescriptor("replication_state", "TBD", nil)
c.SetDescriptor("owner_now", "Current number of lock owners in the lock table", nil)
c.SetDescriptor("owner_high", "Peak number of lock owners that have been stored simultaneously in the lock table", nil)
c.SetDescriptor("owner_max", "Maximum number of lock owner IDs that can be stored in the lock table", nil)
c.SetDescriptor("owner_state", "General state of lock owners", nil)
c.SetDescriptor("arguments_now", "Current number of lock arguments in the lock table", nil)
c.SetDescriptor("arguments_high", "Peak number of lock arguments that have been stored simultaneously in the lock table", nil)
c.SetDescriptor("arguments_max", "Maximum number of lock arguments that can be stored in the lock table", nil)
c.SetDescriptor("arguments_state", "General state of lock arguments", nil)
c.SetDescriptor("locks_now", "Current number of elementary locks in the lock table", nil)
c.SetDescriptor("locks_high", "Peak number of elementary locks that have been stored simultaneously in the lock table", nil)
c.SetDescriptor("locks_max", "Maximum number of elementary locks that can be stored in the lock table", nil)
c.SetDescriptor("locks_state", "General state of elementary locks", nil)
c.SetDescriptor("enqueue_requests", "Lock acquisition requests", nil)
c.SetDescriptor("enqueue_rejects", "Rejected lock requests", nil)
c.SetDescriptor("enqueue_errors", "Lock acquisition errors", nil)
c.SetDescriptor("dequeue_requests", "Lock release requests", nil)
c.SetDescriptor("dequeue_errors", "Lock release errors", nil)
c.SetDescriptor("dequeue_all_requests", "Requests to release of all the locks of an LUW", nil)
c.SetDescriptor("cleanup_requests", "Requests to release of all the locks of an application server", nil)
c.SetDescriptor("backup_requests", "Number of requests forwarded to the update process", nil)
c.SetDescriptor("reporting_requests", "Number of reading operations on the lock table", nil)
c.SetDescriptor("compress_requests", "Internal use", nil)
c.SetDescriptor("verify_requests", "Internal use", nil)
c.SetDescriptor("lock_time", "Total time spent in lock operations", nil)
c.SetDescriptor("lock_wait_time", "Total waiting time of all work processes for accessing lock table", nil)
c.SetDescriptor("server_time", "Total time spent in lock operations by all processes in the enqueue server", nil)
c.SetDescriptor("replication_state", "General state of lock server replication", nil)

return c, nil
}
Expand All @@ -69,7 +67,7 @@ func (c *enqueueServerCollector) recordEnqStats(ch chan<- prometheus.Metric) {
}

ch <- c.MakeGaugeMetric("owner_now", float64(enqStatistic.OwnerNow))
ch <- c.MakeGaugeMetric("owner_high", float64(enqStatistic.OwnerHigh))
ch <- c.MakeCounterMetric("owner_high", float64(enqStatistic.OwnerHigh))
ch <- c.MakeGaugeMetric("owner_max", float64(enqStatistic.OwnerMax))

ownerState, err := sapcontrol.StateColorToFloat(enqStatistic.OwnerState)
Expand All @@ -80,7 +78,7 @@ func (c *enqueueServerCollector) recordEnqStats(ch chan<- prometheus.Metric) {
}

ch <- c.MakeGaugeMetric("arguments_now", float64(enqStatistic.ArgumentsNow))
ch <- c.MakeGaugeMetric("arguments_high", float64(enqStatistic.ArgumentsHigh))
ch <- c.MakeCounterMetric("arguments_high", float64(enqStatistic.ArgumentsHigh))
ch <- c.MakeGaugeMetric("arguments_max", float64(enqStatistic.ArgumentsMax))

argumentsState, err := sapcontrol.StateColorToFloat(enqStatistic.ArgumentsState)
Expand All @@ -91,7 +89,7 @@ func (c *enqueueServerCollector) recordEnqStats(ch chan<- prometheus.Metric) {
}

ch <- c.MakeGaugeMetric("locks_now", float64(enqStatistic.LocksNow))
ch <- c.MakeGaugeMetric("locks_high", float64(enqStatistic.LocksHigh))
ch <- c.MakeCounterMetric("locks_high", float64(enqStatistic.LocksHigh))
ch <- c.MakeGaugeMetric("locks_max", float64(enqStatistic.LocksMax))

locksState, err := sapcontrol.StateColorToFloat(enqStatistic.LocksState)
Expand All @@ -101,23 +99,23 @@ func (c *enqueueServerCollector) recordEnqStats(ch chan<- prometheus.Metric) {
ch <- c.MakeGaugeMetric("locks_state", locksState)
}

ch <- c.MakeGaugeMetric("enqueue_requests", float64(enqStatistic.EnqueueRequests))
ch <- c.MakeGaugeMetric("enqueue_rejects", float64(enqStatistic.EnqueueRejects))
ch <- c.MakeGaugeMetric("enqueue_errors", float64(enqStatistic.EnqueueErrors))
ch <- c.MakeCounterMetric("enqueue_requests", float64(enqStatistic.EnqueueRequests))
ch <- c.MakeCounterMetric("enqueue_rejects", float64(enqStatistic.EnqueueRejects))
ch <- c.MakeCounterMetric("enqueue_errors", float64(enqStatistic.EnqueueErrors))

ch <- c.MakeGaugeMetric("dequeue_requests", float64(enqStatistic.DequeueRequests))
ch <- c.MakeGaugeMetric("dequeue_errors", float64(enqStatistic.DequeueErrors))
ch <- c.MakeGaugeMetric("dequeue_all_requests", float64(enqStatistic.DequeueAllRequests))
ch <- c.MakeCounterMetric("dequeue_requests", float64(enqStatistic.DequeueRequests))
ch <- c.MakeCounterMetric("dequeue_errors", float64(enqStatistic.DequeueErrors))
ch <- c.MakeCounterMetric("dequeue_all_requests", float64(enqStatistic.DequeueAllRequests))

ch <- c.MakeGaugeMetric("cleanup_requests", float64(enqStatistic.CleanupRequests))
ch <- c.MakeGaugeMetric("backup_requests", float64(enqStatistic.BackupRequests))
ch <- c.MakeGaugeMetric("reporting_requests", float64(enqStatistic.ReportingRequests))
ch <- c.MakeGaugeMetric("compress_requests", float64(enqStatistic.CompressRequests))
ch <- c.MakeGaugeMetric("verify_requests", float64(enqStatistic.VerifyRequests))
ch <- c.MakeCounterMetric("cleanup_requests", float64(enqStatistic.CleanupRequests))
ch <- c.MakeCounterMetric("backup_requests", float64(enqStatistic.BackupRequests))
ch <- c.MakeCounterMetric("reporting_requests", float64(enqStatistic.ReportingRequests))
ch <- c.MakeCounterMetric("compress_requests", float64(enqStatistic.CompressRequests))
ch <- c.MakeCounterMetric("verify_requests", float64(enqStatistic.VerifyRequests))

ch <- c.MakeGaugeMetric("lock_time", float64(enqStatistic.LockTime))
ch <- c.MakeGaugeMetric("lock_wait_time", float64(enqStatistic.LockWaitTime))
ch <- c.MakeGaugeMetric("server_time", float64(enqStatistic.ServerTime))
ch <- c.MakeCounterMetric("lock_time", enqStatistic.LockTime)
ch <- c.MakeCounterMetric("lock_wait_time", enqStatistic.LockWaitTime)
ch <- c.MakeCounterMetric("server_time", enqStatistic.ServerTime)

replicationState, err := sapcontrol.StateColorToFloat(enqStatistic.ReplicationState)
if err != nil {
Expand Down
88 changes: 44 additions & 44 deletions collector/enqueue_server/enqueue_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,86 +58,86 @@ func TestProcessesMetric(t *testing.T) {
}, nil)

expectedMetrics := `
# HELP sap_enqueue_server_arguments_high TBD
# TYPE sap_enqueue_server_arguments_high gauge
# HELP sap_enqueue_server_arguments_high Peak number of lock arguments that have been stored simultaneously in the lock table
# TYPE sap_enqueue_server_arguments_high counter
sap_enqueue_server_arguments_high 5
# HELP sap_enqueue_server_arguments_max TBD
# HELP sap_enqueue_server_arguments_max Maximum number of lock arguments that can be stored in the lock table
# TYPE sap_enqueue_server_arguments_max gauge
sap_enqueue_server_arguments_max 6
# HELP sap_enqueue_server_arguments_now TBD
# HELP sap_enqueue_server_arguments_now Current number of lock arguments in the lock table
# TYPE sap_enqueue_server_arguments_now gauge
sap_enqueue_server_arguments_now 4
# HELP sap_enqueue_server_arguments_state TBD
# HELP sap_enqueue_server_arguments_state General state of lock arguments
# TYPE sap_enqueue_server_arguments_state gauge
sap_enqueue_server_arguments_state 1
# HELP sap_enqueue_server_backup_requests TBD
# TYPE sap_enqueue_server_backup_requests gauge
# HELP sap_enqueue_server_backup_requests Number of requests forwarded to the update process
# TYPE sap_enqueue_server_backup_requests counter
sap_enqueue_server_backup_requests 17
# HELP sap_enqueue_server_cleanup_requests TBD
# TYPE sap_enqueue_server_cleanup_requests gauge
# HELP sap_enqueue_server_cleanup_requests Requests to release of all the locks of an application server
# TYPE sap_enqueue_server_cleanup_requests counter
sap_enqueue_server_cleanup_requests 16
# HELP sap_enqueue_server_compress_requests TBD
# TYPE sap_enqueue_server_compress_requests gauge
# HELP sap_enqueue_server_compress_requests Internal use
# TYPE sap_enqueue_server_compress_requests counter
sap_enqueue_server_compress_requests 19
# HELP sap_enqueue_server_dequeue_all_requests TBD
# TYPE sap_enqueue_server_dequeue_all_requests gauge
# HELP sap_enqueue_server_dequeue_all_requests Requests to release of all the locks of an LUW
# TYPE sap_enqueue_server_dequeue_all_requests counter
sap_enqueue_server_dequeue_all_requests 15
# HELP sap_enqueue_server_dequeue_errors TBD
# TYPE sap_enqueue_server_dequeue_errors gauge
# HELP sap_enqueue_server_dequeue_errors Lock release errors
# TYPE sap_enqueue_server_dequeue_errors counter
sap_enqueue_server_dequeue_errors 14
# HELP sap_enqueue_server_dequeue_requests TBD
# TYPE sap_enqueue_server_dequeue_requests gauge
# HELP sap_enqueue_server_dequeue_requests Lock release requests
# TYPE sap_enqueue_server_dequeue_requests counter
sap_enqueue_server_dequeue_requests 13
# HELP sap_enqueue_server_enqueue_errors TBD
# TYPE sap_enqueue_server_enqueue_errors gauge
# HELP sap_enqueue_server_enqueue_errors Lock acquisition errors
# TYPE sap_enqueue_server_enqueue_errors counter
sap_enqueue_server_enqueue_errors 12
# HELP sap_enqueue_server_enqueue_rejects TBD
# TYPE sap_enqueue_server_enqueue_rejects gauge
# HELP sap_enqueue_server_enqueue_rejects Rejected lock requests
# TYPE sap_enqueue_server_enqueue_rejects counter
sap_enqueue_server_enqueue_rejects 11
# HELP sap_enqueue_server_enqueue_requests TBD
# TYPE sap_enqueue_server_enqueue_requests gauge
# HELP sap_enqueue_server_enqueue_requests Lock acquisition requests
# TYPE sap_enqueue_server_enqueue_requests counter
sap_enqueue_server_enqueue_requests 10
# HELP sap_enqueue_server_lock_time TBD
# TYPE sap_enqueue_server_lock_time gauge
# HELP sap_enqueue_server_lock_time Total time spent in lock operations
# TYPE sap_enqueue_server_lock_time counter
sap_enqueue_server_lock_time 21
# HELP sap_enqueue_server_lock_wait_time TBD
# TYPE sap_enqueue_server_lock_wait_time gauge
# HELP sap_enqueue_server_lock_wait_time Total waiting time of all work processes for accessing lock table
# TYPE sap_enqueue_server_lock_wait_time counter
sap_enqueue_server_lock_wait_time 22
# HELP sap_enqueue_server_locks_high TBD
# TYPE sap_enqueue_server_locks_high gauge
# HELP sap_enqueue_server_locks_high Peak number of elementary locks that have been stored simultaneously in the lock table
# TYPE sap_enqueue_server_locks_high counter
sap_enqueue_server_locks_high 8
# HELP sap_enqueue_server_locks_max TBD
# HELP sap_enqueue_server_locks_max Maximum number of elementary locks that can be stored in the lock table
# TYPE sap_enqueue_server_locks_max gauge
sap_enqueue_server_locks_max 9
# HELP sap_enqueue_server_locks_now TBD
# HELP sap_enqueue_server_locks_now Current number of elementary locks in the lock table
# TYPE sap_enqueue_server_locks_now gauge
sap_enqueue_server_locks_now 7
# HELP sap_enqueue_server_locks_state TBD
# HELP sap_enqueue_server_locks_state General state of elementary locks
# TYPE sap_enqueue_server_locks_state gauge
sap_enqueue_server_locks_state 3
# HELP sap_enqueue_server_owner_high TBD
# TYPE sap_enqueue_server_owner_high gauge
# HELP sap_enqueue_server_owner_high Peak number of lock owners that have been stored simultaneously in the lock table
# TYPE sap_enqueue_server_owner_high counter
sap_enqueue_server_owner_high 2
# HELP sap_enqueue_server_owner_max TBD
# HELP sap_enqueue_server_owner_max Maximum number of lock owner IDs that can be stored in the lock table
# TYPE sap_enqueue_server_owner_max gauge
sap_enqueue_server_owner_max 3
# HELP sap_enqueue_server_owner_now TBD
# HELP sap_enqueue_server_owner_now Current number of lock owners in the lock table
# TYPE sap_enqueue_server_owner_now gauge
sap_enqueue_server_owner_now 1
# HELP sap_enqueue_server_owner_state TBD
# HELP sap_enqueue_server_owner_state General state of lock owners
# TYPE sap_enqueue_server_owner_state gauge
sap_enqueue_server_owner_state 2
# HELP sap_enqueue_server_replication_state TBD
# HELP sap_enqueue_server_replication_state General state of lock server replication
# TYPE sap_enqueue_server_replication_state gauge
sap_enqueue_server_replication_state 4
# HELP sap_enqueue_server_reporting_requests TBD
# TYPE sap_enqueue_server_reporting_requests gauge
# HELP sap_enqueue_server_reporting_requests Number of reading operations on the lock table
# TYPE sap_enqueue_server_reporting_requests counter
sap_enqueue_server_reporting_requests 18
# HELP sap_enqueue_server_server_time TBD
# TYPE sap_enqueue_server_server_time gauge
# HELP sap_enqueue_server_server_time Total time spent in lock operations by all processes in the enqueue server
# TYPE sap_enqueue_server_server_time counter
sap_enqueue_server_server_time 23
# HELP sap_enqueue_server_verify_requests TBD
# TYPE sap_enqueue_server_verify_requests gauge
# HELP sap_enqueue_server_verify_requests Internal use
# TYPE sap_enqueue_server_verify_requests counter
sap_enqueue_server_verify_requests 20
`

Expand Down
23 changes: 16 additions & 7 deletions collector/start_service/start_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package start_service
import (
"strconv"

"github.com/pkg/errors"
log "github.com/sirupsen/logrus"

"github.com/prometheus/client_golang/prometheus"
Expand All @@ -18,7 +19,7 @@ func NewCollector(webService sapcontrol.WebService) (*startServiceCollector, err
webService,
}

c.SetDescriptor("processes", "The processes started by the SAP Start Service", []string{"name", "pid", "textstatus", "dispstatus"})
c.SetDescriptor("processes", "The processes started by the SAP Start Service", []string{"name", "pid", "status"})

return c, nil
}
Expand All @@ -31,19 +32,27 @@ type startServiceCollector struct {
func (c *startServiceCollector) Collect(ch chan<- prometheus.Metric) {
log.Debugln("Collecting SAP Start Service metrics")

c.recordProcesses(ch)
err := c.recordProcesses(ch)
if err != nil {
log.Warnf("Some metrics could not be recorded: %s", err)
return
}
}

func (c *startServiceCollector) recordProcesses(ch chan<- prometheus.Metric) {
func (c *startServiceCollector) recordProcesses(ch chan<- prometheus.Metric) error {
processList, err := c.webService.GetProcessList()

if err != nil {
log.Warnf("SAPControl web service error: %s", err)
return
return errors.Wrap(err, "SAPControl web service error")
}

for _, process := range processList.Processes {
dispStatus, _ := sapcontrol.StateColorToString(process.Dispstatus)
ch <- c.MakeGaugeMetric("processes", 1, process.Name, strconv.Itoa(int(process.Pid)), process.Textstatus, dispStatus)
state, err := sapcontrol.StateColorToFloat(process.Dispstatus)
if err != nil {
return errors.Wrapf(err, "Unable to process SAPControl OSProcess data: %v", *process)
}
ch <- c.MakeGaugeMetric("processes", state, process.Name, strconv.Itoa(int(process.Pid)), process.Textstatus)
}

return nil
}
Loading