Skip to content

Commit

Permalink
rename base and ratio metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
secustor committed Mar 1, 2020
1 parent 46ffc58 commit b2f521d
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 99 deletions.
192 changes: 96 additions & 96 deletions collector/mssql.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,50 +137,50 @@ type MSSQLCollector struct {
mssqlScrapeSuccessDesc *prometheus.Desc

// Win32_PerfRawData_{instance}_SQLServerAccessMethods
AccessMethodsAUcleanupbatches *prometheus.Desc
AccessMethodsAUcleanups *prometheus.Desc
AccessMethodsByreferenceLobCreateCount *prometheus.Desc
AccessMethodsByreferenceLobUseCount *prometheus.Desc
AccessMethodsCountLobReadahead *prometheus.Desc
AccessMethodsCountPullInRow *prometheus.Desc
AccessMethodsCountPushOffRow *prometheus.Desc
AccessMethodsDeferreddroppedAUs *prometheus.Desc
AccessMethodsDeferredDroppedrowsets *prometheus.Desc
AccessMethodsDroppedrowsetcleanups *prometheus.Desc
AccessMethodsDroppedrowsetsskipped *prometheus.Desc
AccessMethodsExtentDeallocations *prometheus.Desc
AccessMethodsExtentsAllocated *prometheus.Desc
AccessMethodsFailedAUcleanupbatches *prometheus.Desc
AccessMethodsFailedleafpagecookie *prometheus.Desc
AccessMethodsFailedtreepagecookie *prometheus.Desc
AccessMethodsForwardedRecords *prometheus.Desc
AccessMethodsFreeSpacePageFetches *prometheus.Desc
AccessMethodsFreeSpaceScans *prometheus.Desc
AccessMethodsFullScans *prometheus.Desc
AccessMethodsIndexSearches *prometheus.Desc
AccessMethodsInSysXactwaits *prometheus.Desc
AccessMethodsLobHandleCreateCount *prometheus.Desc
AccessMethodsLobHandleDestroyCount *prometheus.Desc
AccessMethodsLobSSProviderCreateCount *prometheus.Desc
AccessMethodsLobSSProviderDestroyCount *prometheus.Desc
AccessMethodsLobSSProviderTruncationCount *prometheus.Desc
AccessMethodsMixedpageallocations *prometheus.Desc
AccessMethodsPagecompressionattempts *prometheus.Desc
AccessMethodsPageDeallocations *prometheus.Desc
AccessMethodsPagesAllocated *prometheus.Desc
AccessMethodsPagescompressed *prometheus.Desc
AccessMethodsPageSplits *prometheus.Desc
AccessMethodsProbeScans *prometheus.Desc
AccessMethodsRangeScans *prometheus.Desc
AccessMethodsScanPointRevalidations *prometheus.Desc
AccessMethodsSkippedGhostedRecords *prometheus.Desc
AccessMethodsTableLockEscalations *prometheus.Desc
AccessMethodsUsedleafpagecookie *prometheus.Desc
AccessMethodsUsedtreepagecookie *prometheus.Desc
AccessMethodsWorkfilesCreated *prometheus.Desc
AccessMethodsWorktablesCreated *prometheus.Desc
AccessMethodsWorktablesFromCacheRatio *prometheus.Desc
AccessMethodsWorktablesFromCacheRatio_Base *prometheus.Desc
AccessMethodsAUcleanupbatches *prometheus.Desc
AccessMethodsAUcleanups *prometheus.Desc
AccessMethodsByreferenceLobCreateCount *prometheus.Desc
AccessMethodsByreferenceLobUseCount *prometheus.Desc
AccessMethodsCountLobReadahead *prometheus.Desc
AccessMethodsCountPullInRow *prometheus.Desc
AccessMethodsCountPushOffRow *prometheus.Desc
AccessMethodsDeferreddroppedAUs *prometheus.Desc
AccessMethodsDeferredDroppedrowsets *prometheus.Desc
AccessMethodsDroppedrowsetcleanups *prometheus.Desc
AccessMethodsDroppedrowsetsskipped *prometheus.Desc
AccessMethodsExtentDeallocations *prometheus.Desc
AccessMethodsExtentsAllocated *prometheus.Desc
AccessMethodsFailedAUcleanupbatches *prometheus.Desc
AccessMethodsFailedleafpagecookie *prometheus.Desc
AccessMethodsFailedtreepagecookie *prometheus.Desc
AccessMethodsForwardedRecords *prometheus.Desc
AccessMethodsFreeSpacePageFetches *prometheus.Desc
AccessMethodsFreeSpaceScans *prometheus.Desc
AccessMethodsFullScans *prometheus.Desc
AccessMethodsIndexSearches *prometheus.Desc
AccessMethodsInSysXactwaits *prometheus.Desc
AccessMethodsLobHandleCreateCount *prometheus.Desc
AccessMethodsLobHandleDestroyCount *prometheus.Desc
AccessMethodsLobSSProviderCreateCount *prometheus.Desc
AccessMethodsLobSSProviderDestroyCount *prometheus.Desc
AccessMethodsLobSSProviderTruncationCount *prometheus.Desc
AccessMethodsMixedpageallocations *prometheus.Desc
AccessMethodsPagecompressionattempts *prometheus.Desc
AccessMethodsPageDeallocations *prometheus.Desc
AccessMethodsPagesAllocated *prometheus.Desc
AccessMethodsPagescompressed *prometheus.Desc
AccessMethodsPageSplits *prometheus.Desc
AccessMethodsProbeScans *prometheus.Desc
AccessMethodsRangeScans *prometheus.Desc
AccessMethodsScanPointRevalidations *prometheus.Desc
AccessMethodsSkippedGhostedRecords *prometheus.Desc
AccessMethodsTableLockEscalations *prometheus.Desc
AccessMethodsUsedleafpagecookie *prometheus.Desc
AccessMethodsUsedtreepagecookie *prometheus.Desc
AccessMethodsWorkfilesCreated *prometheus.Desc
AccessMethodsWorktablesCreated *prometheus.Desc
AccessMethodsWorktablesFromCacheHits *prometheus.Desc
AccessMethodsWorktablesFromCacheLookups *prometheus.Desc

// Win32_PerfRawData_{instance}_SQLServerAvailabilityReplica
AvailReplicaBytesReceivedfromReplica *prometheus.Desc
Expand All @@ -195,8 +195,8 @@ type MSSQLCollector struct {

// Win32_PerfRawData_{instance}_SQLServerBufferManager
BufManBackgroundwriterpages *prometheus.Desc
BufManBuffercachehitratio *prometheus.Desc
BufManBuffercachehitratio_Base *prometheus.Desc
BufManBuffercachehits *prometheus.Desc
BufManBuffercachelookups *prometheus.Desc
BufManCheckpointpages *prometheus.Desc
BufManDatabasepages *prometheus.Desc
BufManExtensionallocatedpages *prometheus.Desc
Expand Down Expand Up @@ -254,8 +254,8 @@ type MSSQLCollector struct {
DatabasesDBCCLogicalScanBytes *prometheus.Desc
DatabasesGroupCommitTime *prometheus.Desc
DatabasesLogBytesFlushed *prometheus.Desc
DatabasesLogCacheHitRatio *prometheus.Desc
DatabasesLogCacheHitRatio_Base *prometheus.Desc
DatabasesLogCacheHits *prometheus.Desc
DatabasesLogCacheLookups *prometheus.Desc
DatabasesLogCacheReads *prometheus.Desc
DatabasesLogFilesSizeKB *prometheus.Desc
DatabasesLogFilesUsedSizeKB *prometheus.Desc
Expand Down Expand Up @@ -320,14 +320,14 @@ type MSSQLCollector struct {
GenStatsUserConnections *prometheus.Desc

// Win32_PerfRawData_{instance}_SQLServerLocks
LocksAverageWaitTimems *prometheus.Desc
LocksAverageWaitTimems_Base *prometheus.Desc
LocksLockRequests *prometheus.Desc
LocksLockTimeouts *prometheus.Desc
LocksLockTimeoutstimeout0 *prometheus.Desc
LocksLockWaits *prometheus.Desc
LocksLockWaitTimems *prometheus.Desc
LocksNumberofDeadlocks *prometheus.Desc
LocksLockWaitTime *prometheus.Desc
LocksLockCount *prometheus.Desc
LocksLockRequests *prometheus.Desc
LocksLockTimeouts *prometheus.Desc
LocksLockTimeoutstimeout0 *prometheus.Desc
LocksLockWaits *prometheus.Desc
LocksLockWaitTimems *prometheus.Desc
LocksNumberofDeadlocks *prometheus.Desc

// Win32_PerfRawData_{instance}_SQLServerMemoryManager
MemMgrConnectionMemoryKB *prometheus.Desc
Expand Down Expand Up @@ -660,14 +660,14 @@ func NewMSSQLCollector() (Collector, error) {
[]string{"instance"},
nil,
),
AccessMethodsWorktablesFromCacheRatio: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "accessmethods_worktables_from_cache_ratio"),
AccessMethodsWorktablesFromCacheHits: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "accessmethods_worktables_from_cache_hits"),
"(AccessMethods.WorktablesFromCacheRatio)",
[]string{"instance"},
nil,
),
AccessMethodsWorktablesFromCacheRatio_Base: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "accessmethods_worktables_from_cache_ratio_lookups"),
AccessMethodsWorktablesFromCacheLookups: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "accessmethods_worktables_from_cache_lookups"),
"(AccessMethods.WorktablesFromCacheRatio_Base)",
[]string{"instance"},
nil,
Expand Down Expand Up @@ -736,14 +736,14 @@ func NewMSSQLCollector() (Collector, error) {
[]string{"instance"},
nil,
),
BufManBuffercachehitratio: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "bufman_buffer_cache_hit_ratio"),
BufManBuffercachehits: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "bufman_buffer_cache_hits_total"),
"(BufferManager.Buffercachehitratio)",
[]string{"instance"},
nil,
),
BufManBuffercachehitratio_Base: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "bufman_buffer_cache_hit_ratio_lookups"),
BufManBuffercachelookups: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "bufman_buffer_cache_lookups"),
"(BufferManager.Buffercachehitratio_Base)",
[]string{"instance"},
nil,
Expand Down Expand Up @@ -1070,15 +1070,15 @@ func NewMSSQLCollector() (Collector, error) {
[]string{"instance", "database"},
nil,
),
DatabasesLogCacheHitRatio: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "databases_log_cache_hit_ratio"),
"(Databases.LogCacheHitRatio)",
DatabasesLogCacheHits: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "databases_log_cache_hits"),
"(Databases.LogCacheHits)",
[]string{"instance", "database"},
nil,
),
DatabasesLogCacheHitRatio_Base: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "databases_log_cache_hit_ratio_lookups"),
"(Databases.LogCacheHitRatio_Base)",
DatabasesLogCacheLookups: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "databases_log_cache_hit_lookups"),
"(Databases.LogCacheLookups)",
[]string{"instance", "database"},
nil,
),
Expand Down Expand Up @@ -1446,15 +1446,15 @@ func NewMSSQLCollector() (Collector, error) {
),

// Win32_PerfRawData_{instance}_SQLServerLocks
LocksAverageWaitTimems: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "locks_average_wait_seconds"),
"(Locks.AverageWaitTimems)",
LocksLockWaitTime: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "locks_wait_time_seconds"),
"(Locks.LockWaitTime. Total time in ms which locks have been holding resources)",
[]string{"instance", "resource"},
nil,
),
LocksAverageWaitTimems_Base: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "locks_average_wait_seconds_lookups"),
"(Locks.AverageWaitTimems_Base)",
LocksLockCount: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "locks_count"),
"(Locks.LockCount. count of how often requests have run into locks)",
[]string{"instance", "resource"},
nil,
),
Expand Down Expand Up @@ -2204,14 +2204,14 @@ func (c *MSSQLCollector) collectAccessMethods(ch chan<- prometheus.Metric, sqlIn
)

ch <- prometheus.MustNewConstMetric(
c.AccessMethodsWorktablesFromCacheRatio,
c.AccessMethodsWorktablesFromCacheHits,
prometheus.CounterValue,
float64(v.WorktablesFromCacheRatio),
sqlInstance,
)

ch <- prometheus.MustNewConstMetric(
c.AccessMethodsWorktablesFromCacheRatio_Base,
c.AccessMethodsWorktablesFromCacheLookups,
prometheus.CounterValue,
float64(v.WorktablesFromCacheRatio_Base),
sqlInstance,
Expand Down Expand Up @@ -2317,8 +2317,8 @@ func (c *MSSQLCollector) collectAvailabilityReplica(ch chan<- prometheus.Metric,
// https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-buffer-manager-object
type win32PerfRawDataSQLServerBufferManager struct {
BackgroundwriterpagesPersec uint64
Buffercachehitratio uint64
Buffercachehitratio_Base uint64
Buffercachehits uint64
Buffercachelookups uint64
CheckpointpagesPersec uint64
Databasepages uint64
Extensionallocatedpages uint64
Expand Down Expand Up @@ -2364,16 +2364,16 @@ func (c *MSSQLCollector) collectBufferManager(ch chan<- prometheus.Metric, sqlIn
)

ch <- prometheus.MustNewConstMetric(
c.BufManBuffercachehitratio,
c.BufManBuffercachehits,
prometheus.GaugeValue,
float64(v.Buffercachehitratio),
float64(v.Buffercachehits),
sqlInstance,
)

ch <- prometheus.MustNewConstMetric(
c.BufManBuffercachehitratio_Base,
c.BufManBuffercachelookups,
prometheus.GaugeValue,
float64(v.Buffercachehitratio_Base),
float64(v.Buffercachehits),
sqlInstance,
)

Expand Down Expand Up @@ -2747,8 +2747,8 @@ type win32PerfRawDataSQLServerDatabases struct {
DBCCLogicalScanBytesPersec uint64
GroupCommitTimePersec uint64
LogBytesFlushedPersec uint64
LogCacheHitRatio uint64
LogCacheHitRatio_Base uint64
LogCacheHits uint64
LogCacheLookups uint64
LogCacheReadsPersec uint64
LogFilesSizeKB uint64
LogFilesUsedSizeKB uint64
Expand Down Expand Up @@ -2864,16 +2864,16 @@ func (c *MSSQLCollector) collectDatabases(ch chan<- prometheus.Metric, sqlInstan
)

ch <- prometheus.MustNewConstMetric(
c.DatabasesLogCacheHitRatio,
c.DatabasesLogCacheHits,
prometheus.GaugeValue,
float64(v.LogCacheHitRatio),
float64(v.LogCacheHits),
sqlInstance, dbName,
)

ch <- prometheus.MustNewConstMetric(
c.DatabasesLogCacheHitRatio_Base,
c.DatabasesLogCacheHits,
prometheus.GaugeValue,
float64(v.LogCacheHitRatio_Base),
float64(v.LogCacheLookups),
sqlInstance, dbName,
)

Expand Down Expand Up @@ -3350,8 +3350,8 @@ func (c *MSSQLCollector) collectGeneralStatistics(ch chan<- prometheus.Metric, s
// - https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-locks-object
type win32PerfRawDataSQLServerLocks struct {
Name string
AverageWaitTimems uint64
AverageWaitTimems_Base uint64
LockWaitTime uint64
LockCount uint64
LockRequestsPersec uint64
LockTimeoutsPersec uint64
LockTimeoutstimeout0Persec uint64
Expand All @@ -3374,16 +3374,16 @@ func (c *MSSQLCollector) collectLocks(ch chan<- prometheus.Metric, sqlInstance s
lockResourceName := v.Name

ch <- prometheus.MustNewConstMetric(
c.LocksAverageWaitTimems,
c.LocksLockWaitTime,
prometheus.GaugeValue,
float64(v.AverageWaitTimems)/1000.0,
float64(v.LockWaitTime)/1000.0,
sqlInstance, lockResourceName,
)

ch <- prometheus.MustNewConstMetric(
c.LocksAverageWaitTimems_Base,
c.LocksLockCount,
prometheus.GaugeValue,
float64(v.AverageWaitTimems_Base)/1000.0,
float64(v.LockCount)/1000.0,
sqlInstance, lockResourceName,
)

Expand Down
17 changes: 14 additions & 3 deletions docs/collector.mssql.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,23 @@ _This collector does not yet have explained examples, we would appreciate your h
### Buffer Cache Hit Ratio

When you read the counter in perfmon you will get the the percentage pages found in the buffer cache. This percentage is calculated internally based on the total number of cache hits divided by the total number of cache lookups over the last few thousand page accesses.
This collector retrieves the two internal values separately. In order to give any meaning to the value you will have to calculate the Buffer Cache Hit Ratio in PromQL.
This collector retrieves the two internal values separately. In order to calculate the Buffer Cache Hit Ratio in PromQL.

```
wmi_mssql_bufman_buffer_cache_hit_ratio{instance="host:9182", exported_instance="MSSQLSERVER"} /
wmi_mssql_bufman_buffer_cache_hit_ratio_lookups{instance="host:9182", exported_instance="MSSQLSERVER"}
wmi_mssql_bufman_buffer_cache_hits{instance="host:9182", exported_instance="MSSQLSERVER"} /
wmi_mssql_bufman_buffer_cache_lookups{instance="host:9182", exported_instance="MSSQLSERVER"}
```

This principal can be used for following metrics too:
- AccessMethodsWorktablesFromCacheHitRatio
- accessmethods_worktables_from_cache_hits
- accessmethods_worktables_from_cache_lookups
- LogCacheHitRatio
- databases_log_cache_hits
- databases_log_cache_lookups
- AverageLockWaitTime
- locks_wait_time_seconds
- locks_count

## Alerting examples
_This collector does not yet have alerting examples, we would appreciate your help adding them!_

0 comments on commit b2f521d

Please sign in to comment.