From 27cc1072fe5c4abea171a52ed10e0968249b0f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D1=8F=D0=BA=D0=BE=D0=B2=20=D0=98=D0=B3?= =?UTF-8?q?=D0=BE=D1=80=D1=8C?= Date: Sun, 4 Aug 2019 00:55:28 +0300 Subject: [PATCH 1/5] Initial transactions collector implementation --- collector/mssql.go | 238 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 237 insertions(+), 1 deletion(-) diff --git a/collector/mssql.go b/collector/mssql.go index b54670292..a5bd99259 100644 --- a/collector/mssql.go +++ b/collector/mssql.go @@ -91,7 +91,7 @@ func mssqlBuildWMIInstanceClass(suffix string, instance string) string { type mssqlCollectorsMap map[string]mssqlCollectorFunc func mssqlAvailableClassCollectors() string { - return "accessmethods,availreplica,bufman,databases,dbreplica,genstats,locks,memmgr,sqlstats,sqlerrors" + return "accessmethods,availreplica,bufman,databases,dbreplica,genstats,locks,memmgr,sqlstats,sqlerrors,transactions" } func (c *MSSQLCollector) getMSSQLCollectors() mssqlCollectorsMap { @@ -106,6 +106,7 @@ func (c *MSSQLCollector) getMSSQLCollectors() mssqlCollectorsMap { mssqlCollectors["memmgr"] = c.collectMemoryManager mssqlCollectors["sqlstats"] = c.collectSQLStats mssqlCollectors["sqlerrors"] = c.collectSQLErrors + mssqlCollectors["transactions"] = c.collectTransactions return mssqlCollectors } @@ -362,6 +363,21 @@ type MSSQLCollector struct { // Win32_PerfRawData_{instance}_SQLServerSQLErrors SQLErrorsTotal *prometheus.Desc + // Win32_PerfRawData_{instance}_SQLServerTransactions + TransactionsFreeSpaceInTempDbKB *prometheus.Desc + TransactionsLongestTransactionRunningTime *prometheus.Desc + TransactionsNonSnapshotVersionTotalActive *prometheus.Desc + TransactionsSnapshotTotalActive *prometheus.Desc + TransactionsTotalActive *prometheus.Desc + TransactionsUpdateConflictRatio *prometheus.Desc + TransactionsUpdateSnapshotTotalActive *prometheus.Desc + TransactionsVersionCleanupRateKBs *prometheus.Desc + TransactionsVersionGenerationRateKBs *prometheus.Desc + TransactionsVersionStoreSizeKB *prometheus.Desc + TransactionsVersionStoreUnitCount *prometheus.Desc + TransactionsVersionStoreUnitCreation *prometheus.Desc + TransactionsVersionStoreUnitTruncation *prometheus.Desc + mssqlInstances mssqlInstancesType mssqlCollectors mssqlCollectorsMap mssqlChildCollectorFailure int @@ -1649,6 +1665,98 @@ func NewMSSQLCollector() (Collector, error) { nil, ), + // Win32_PerfRawData_{instance}_SQLServerTransactions + TransactionsFreeSpaceInTempDbKB: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "transactions_tempdb_free_space_bytes"), + "(Transactions.FreeSpaceInTempDbKB)", + []string{"instance"}, + nil, + ), + + TransactionsLongestTransactionRunningTime: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "transactions_longest_transaction_running_seconds"), + "(Transactions.LongestTransactionRunningTime)", + []string{"instance"}, + nil, + ), + + TransactionsNonSnapshotVersionTotalActive: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "transactions_nonsnapshot_version_active_total"), + "(Transactions.NonSnapshotVersionTotalActive)", + []string{"instance"}, + nil, + ), + + TransactionsSnapshotTotalActive: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "transactions_snapshot_active_total"), + "(Transactions.SnapshotTotalActive)", + []string{"instance"}, + nil, + ), + + TransactionsTotalActive: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "transactions_active_total"), + "(Transactions.TotalActive)", + []string{"instance"}, + nil, + ), + + TransactionsUpdateConflictRatio: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "transactions_update_conflict_ratio"), + "(Transactions.UpdateConflictRatio)", + []string{"instance"}, + nil, + ), + + TransactionsUpdateSnapshotTotalActive: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "transactions_update_snapshot_active_total"), + "(Transactions.UpdateSnapshotTotalActive)", + []string{"instance"}, + nil, + ), + + TransactionsVersionCleanupRateKBs: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "transactions_version_cleanup_rate_bytes"), + "(Transactions.VersionCleanupRateKBs)", + []string{"instance"}, + nil, + ), + + TransactionsVersionGenerationRateKBs: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "transactions_version_generation_rate_bytes"), + "(Transactions.VersionGenerationRateKBs)", + []string{"instance"}, + nil, + ), + + TransactionsVersionStoreSizeKB: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "transactions_version_store_size_bytes"), + "(Transactions.VersionStoreSizeKB)", + []string{"instance"}, + nil, + ), + + TransactionsVersionStoreUnitCount: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "transactions_version_store_units"), + "(Transactions.VersionStoreUnitCount)", + []string{"instance"}, + nil, + ), + + TransactionsVersionStoreUnitCreation: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "transactions_version_store_creation_units"), + "(Transactions.VersionStoreUnitCreation)", + []string{"instance"}, + nil, + ), + + TransactionsVersionStoreUnitTruncation: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "transactions_version_store_truncation_units"), + "(Transactions.VersionStoreUnitTruncation)", + []string{"instance"}, + nil, + ), + mssqlInstances: getMSSQLInstances(), } @@ -3599,5 +3707,133 @@ func (c *MSSQLCollector) collectSQLErrors(ch chan<- prometheus.Metric, sqlInstan ) } + return nil, nil +} + +type win32PerfRawDataSqlServerTransactions struct { + FreeSpaceInTempDbKB uint64 + LongestTransactionRunningTime uint64 + NonSnapshotVersionTransactions uint64 + SnapshotTransactions uint64 + Transactions uint64 + UpdateConflictRatio uint64 + UpdateSnapshotTransactions uint64 + VersionCleanupRateKBs uint64 + VersionGenerationRateKBs uint64 + VersionStoreSizeKB uint64 + VersionStoreUnitCount uint64 + VersionStoreUnitCreation uint64 + VersionStoreUnitTruncation uint64 +} + +// Win32_PerfRawData_MSSQLSERVER_Transactions docs: +// - https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-transactions-object +func (c *MSSQLCollector) collectTransactions(ch chan<- prometheus.Metric, sqlInstance string) (*prometheus.Desc, error) { + var dst []win32PerfRawDataSqlServerTransactions + log.Debugf("mssql_transactions collector iterating sql instance %s.", sqlInstance) + + class := mssqlBuildWMIInstanceClass("Transactions", sqlInstance) + q := queryAllForClass(&dst, class) + if err := wmi.Query(q, &dst); err != nil { + return nil, err + } + + if len(dst) == 0 { + return nil, errors.New("WMI query returned empty result set") + } + + v := dst[0] + + ch <- prometheus.MustNewConstMetric( + c.TransactionsFreeSpaceInTempDbKB, + prometheus.GaugeValue, + float64(v.FreeSpaceInTempDbKB), + sqlInstance, + ) + + ch <- prometheus.MustNewConstMetric( + c.TransactionsLongestTransactionRunningTime, + prometheus.GaugeValue, + float64(v.LongestTransactionRunningTime), + sqlInstance, + ) + + ch <- prometheus.MustNewConstMetric( + c.TransactionsNonSnapshotVersionTotalActive, + prometheus.CounterValue, + float64(v.NonSnapshotVersionTransactions), + sqlInstance, + ) + + ch <- prometheus.MustNewConstMetric( + c.TransactionsSnapshotTotalActive, + prometheus.CounterValue, + float64(v.SnapshotTransactions), + sqlInstance, + ) + + ch <- prometheus.MustNewConstMetric( + c.TransactionsTotalActive, + prometheus.CounterValue, + float64(v.Transactions), + sqlInstance, + ) + + ch <- prometheus.MustNewConstMetric( + c.TransactionsUpdateConflictRatio, + prometheus.GaugeValue, + float64(v.UpdateConflictRatio), + sqlInstance, + ) + + ch <- prometheus.MustNewConstMetric( + c.TransactionsUpdateSnapshotTotalActive, + prometheus.CounterValue, + float64(v.UpdateSnapshotTransactions), + sqlInstance, + ) + + ch <- prometheus.MustNewConstMetric( + c.TransactionsVersionCleanupRateKBs, + prometheus.GaugeValue, + float64(v.VersionCleanupRateKBs), + sqlInstance, + ) + + ch <- prometheus.MustNewConstMetric( + c.TransactionsVersionGenerationRateKBs, + prometheus.GaugeValue, + float64(v.VersionGenerationRateKBs), + sqlInstance, + ) + + ch <- prometheus.MustNewConstMetric( + c.TransactionsVersionStoreSizeKB, + prometheus.GaugeValue, + float64(v.VersionStoreSizeKB), + sqlInstance, + ) + + ch <- prometheus.MustNewConstMetric( + c.TransactionsVersionStoreUnitCount, + prometheus.CounterValue, + float64(v.VersionStoreUnitCount), + sqlInstance, + ) + + ch <- prometheus.MustNewConstMetric( + c.TransactionsVersionStoreUnitCreation, + prometheus.CounterValue, + float64(v.VersionStoreUnitCreation), + sqlInstance, + ) + + ch <- prometheus.MustNewConstMetric( + c.TransactionsVersionStoreUnitTruncation, + prometheus.CounterValue, + float64(v.VersionStoreUnitTruncation), + sqlInstance, + ) + return nil, nil } \ No newline at end of file From 4f0a3a89ab311aa55ea59fe6d7780bb703e305c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D1=8F=D0=BA=D0=BE=D0=B2=20=D0=98=D0=B3?= =?UTF-8?q?=D0=BE=D1=80=D1=8C?= Date: Sun, 4 Aug 2019 02:46:33 +0300 Subject: [PATCH 2/5] Counter struct field names now are strict equal to WMI names --- .gitignore | 1 + collector/mssql.go | 66 +++++++++++++++++++++++----------------------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index c3015a88a..39fbde390 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ VERSION *.swp *.un~ output/ +.vscode \ No newline at end of file diff --git a/collector/mssql.go b/collector/mssql.go index a5bd99259..8d65c7b52 100644 --- a/collector/mssql.go +++ b/collector/mssql.go @@ -361,22 +361,22 @@ type MSSQLCollector struct { SQLStatsUnsafeAutoParams *prometheus.Desc // Win32_PerfRawData_{instance}_SQLServerSQLErrors - SQLErrorsTotal *prometheus.Desc + SQLErrorsTotal *prometheus.Desc // Win32_PerfRawData_{instance}_SQLServerTransactions - TransactionsFreeSpaceInTempDbKB *prometheus.Desc - TransactionsLongestTransactionRunningTime *prometheus.Desc - TransactionsNonSnapshotVersionTotalActive *prometheus.Desc - TransactionsSnapshotTotalActive *prometheus.Desc - TransactionsTotalActive *prometheus.Desc - TransactionsUpdateConflictRatio *prometheus.Desc - TransactionsUpdateSnapshotTotalActive *prometheus.Desc - TransactionsVersionCleanupRateKBs *prometheus.Desc - TransactionsVersionGenerationRateKBs *prometheus.Desc - TransactionsVersionStoreSizeKB *prometheus.Desc - TransactionsVersionStoreUnitCount *prometheus.Desc - TransactionsVersionStoreUnitCreation *prometheus.Desc - TransactionsVersionStoreUnitTruncation *prometheus.Desc + TransactionsFreeSpaceInTempDbKB *prometheus.Desc + TransactionsLongestTransactionRunningTime *prometheus.Desc + TransactionsNonSnapshotVersionTotalActive *prometheus.Desc + TransactionsSnapshotTotalActive *prometheus.Desc + TransactionsTotalActive *prometheus.Desc + TransactionsUpdateConflictRatio *prometheus.Desc + TransactionsUpdateSnapshotTotalActive *prometheus.Desc + TransactionsVersionCleanupRateKBs *prometheus.Desc + TransactionsVersionGenerationRateKBs *prometheus.Desc + TransactionsVersionStoreSizeKB *prometheus.Desc + TransactionsVersionStoreUnitCount *prometheus.Desc + TransactionsVersionStoreUnitCreation *prometheus.Desc + TransactionsVersionStoreUnitTruncation *prometheus.Desc mssqlInstances mssqlInstancesType mssqlCollectors mssqlCollectorsMap @@ -1666,7 +1666,7 @@ func NewMSSQLCollector() (Collector, error) { ), // Win32_PerfRawData_{instance}_SQLServerTransactions - TransactionsFreeSpaceInTempDbKB: prometheus.NewDesc( + TransactionsFreeSpaceInTempDbKB: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_tempdb_free_space_bytes"), "(Transactions.FreeSpaceInTempDbKB)", []string{"instance"}, @@ -1756,7 +1756,7 @@ func NewMSSQLCollector() (Collector, error) { []string{"instance"}, nil, ), - + mssqlInstances: getMSSQLInstances(), } @@ -3680,8 +3680,8 @@ func (c *MSSQLCollector) collectSQLStats(ch chan<- prometheus.Metric, sqlInstanc } type win32PerfRawDataSQLServerSQLErrors struct { - Name string - Errorssec uint64 + Name string + ErrorsPersec uint64 } // Win32_PerfRawData_MSSQLSERVER_SQLServerErrors docs: @@ -3702,7 +3702,7 @@ func (c *MSSQLCollector) collectSQLErrors(ch chan<- prometheus.Metric, sqlInstan ch <- prometheus.MustNewConstMetric( c.SQLErrorsTotal, prometheus.CounterValue, - float64(v.Errorssec), + float64(v.ErrorsPersec), sqlInstance, resource, ) } @@ -3711,19 +3711,19 @@ func (c *MSSQLCollector) collectSQLErrors(ch chan<- prometheus.Metric, sqlInstan } type win32PerfRawDataSqlServerTransactions struct { - FreeSpaceInTempDbKB uint64 + FreeSpaceintempdbKB uint64 LongestTransactionRunningTime uint64 NonSnapshotVersionTransactions uint64 SnapshotTransactions uint64 Transactions uint64 - UpdateConflictRatio uint64 + Updateconflictratio uint64 UpdateSnapshotTransactions uint64 - VersionCleanupRateKBs uint64 - VersionGenerationRateKBs uint64 + VersionCleanuprateKBPers uint64 + VersionGenerationrateKBPers uint64 VersionStoreSizeKB uint64 - VersionStoreUnitCount uint64 - VersionStoreUnitCreation uint64 - VersionStoreUnitTruncation uint64 + VersionStoreunitcount uint64 + VersionStoreunitcreation uint64 + VersionStoreunittruncation uint64 } // Win32_PerfRawData_MSSQLSERVER_Transactions docs: @@ -3747,7 +3747,7 @@ func (c *MSSQLCollector) collectTransactions(ch chan<- prometheus.Metric, sqlIns ch <- prometheus.MustNewConstMetric( c.TransactionsFreeSpaceInTempDbKB, prometheus.GaugeValue, - float64(v.FreeSpaceInTempDbKB), + float64(v.FreeSpaceintempdbKB), sqlInstance, ) @@ -3782,7 +3782,7 @@ func (c *MSSQLCollector) collectTransactions(ch chan<- prometheus.Metric, sqlIns ch <- prometheus.MustNewConstMetric( c.TransactionsUpdateConflictRatio, prometheus.GaugeValue, - float64(v.UpdateConflictRatio), + float64(v.Updateconflictratio), sqlInstance, ) @@ -3796,14 +3796,14 @@ func (c *MSSQLCollector) collectTransactions(ch chan<- prometheus.Metric, sqlIns ch <- prometheus.MustNewConstMetric( c.TransactionsVersionCleanupRateKBs, prometheus.GaugeValue, - float64(v.VersionCleanupRateKBs), + float64(v.VersionCleanuprateKBPers), sqlInstance, ) ch <- prometheus.MustNewConstMetric( c.TransactionsVersionGenerationRateKBs, prometheus.GaugeValue, - float64(v.VersionGenerationRateKBs), + float64(v.VersionGenerationrateKBPers), sqlInstance, ) @@ -3817,21 +3817,21 @@ func (c *MSSQLCollector) collectTransactions(ch chan<- prometheus.Metric, sqlIns ch <- prometheus.MustNewConstMetric( c.TransactionsVersionStoreUnitCount, prometheus.CounterValue, - float64(v.VersionStoreUnitCount), + float64(v.VersionStoreunitcount), sqlInstance, ) ch <- prometheus.MustNewConstMetric( c.TransactionsVersionStoreUnitCreation, prometheus.CounterValue, - float64(v.VersionStoreUnitCreation), + float64(v.VersionStoreunitcreation), sqlInstance, ) ch <- prometheus.MustNewConstMetric( c.TransactionsVersionStoreUnitTruncation, prometheus.CounterValue, - float64(v.VersionStoreUnitTruncation), + float64(v.VersionStoreunittruncation), sqlInstance, ) From 8251ddd17654d07581a1c4c81f7bd4deec3df651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D1=8F=D0=BA=D0=BE=D0=B2=20=D0=98=D0=B3?= =?UTF-8?q?=D0=BE=D1=80=D1=8C?= Date: Sun, 4 Aug 2019 03:04:00 +0300 Subject: [PATCH 3/5] Docs for mssql transactions --- collector/mssql.go | 22 +++++----------------- docs/collector.mssql.md | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/collector/mssql.go b/collector/mssql.go index 8d65c7b52..0707632ec 100644 --- a/collector/mssql.go +++ b/collector/mssql.go @@ -1672,84 +1672,72 @@ func NewMSSQLCollector() (Collector, error) { []string{"instance"}, nil, ), - TransactionsLongestTransactionRunningTime: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_longest_transaction_running_seconds"), "(Transactions.LongestTransactionRunningTime)", []string{"instance"}, nil, ), - TransactionsNonSnapshotVersionTotalActive: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_nonsnapshot_version_active_total"), - "(Transactions.NonSnapshotVersionTotalActive)", + "(Transactions.NonSnapshotVersionTransactions)", []string{"instance"}, nil, ), - TransactionsSnapshotTotalActive: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_snapshot_active_total"), - "(Transactions.SnapshotTotalActive)", + "(Transactions.SnapshotTransactions)", []string{"instance"}, nil, ), - TransactionsTotalActive: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_active_total"), - "(Transactions.TotalActive)", + "(Transactions.Transactions)", []string{"instance"}, nil, ), - TransactionsUpdateConflictRatio: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_update_conflict_ratio"), "(Transactions.UpdateConflictRatio)", []string{"instance"}, nil, ), - TransactionsUpdateSnapshotTotalActive: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_update_snapshot_active_total"), - "(Transactions.UpdateSnapshotTotalActive)", + "(Transactions.UpdateSnapshotTransactions)", []string{"instance"}, nil, ), - TransactionsVersionCleanupRateKBs: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_version_cleanup_rate_bytes"), "(Transactions.VersionCleanupRateKBs)", []string{"instance"}, nil, ), - TransactionsVersionGenerationRateKBs: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_version_generation_rate_bytes"), "(Transactions.VersionGenerationRateKBs)", []string{"instance"}, nil, ), - TransactionsVersionStoreSizeKB: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_version_store_size_bytes"), "(Transactions.VersionStoreSizeKB)", []string{"instance"}, nil, ), - TransactionsVersionStoreUnitCount: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_version_store_units"), "(Transactions.VersionStoreUnitCount)", []string{"instance"}, nil, ), - TransactionsVersionStoreUnitCreation: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_version_store_creation_units"), "(Transactions.VersionStoreUnitCreation)", []string{"instance"}, nil, ), - TransactionsVersionStoreUnitTruncation: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_version_store_truncation_units"), "(Transactions.VersionStoreUnitTruncation)", @@ -3836,4 +3824,4 @@ func (c *MSSQLCollector) collectTransactions(ch chan<- prometheus.Metric, sqlIns ) return nil, nil -} \ No newline at end of file +} diff --git a/docs/collector.mssql.md b/docs/collector.mssql.md index 76c7c1a1c..4e21f8fa5 100644 --- a/docs/collector.mssql.md +++ b/docs/collector.mssql.md @@ -5,14 +5,14 @@ The mssql collector exposes metrics about the MSSQL server ||| -|- Metric name prefix | `mssql` -Classes | [`Win32_PerfRawData_MSSQLSERVER_SQLServerAccessMethods`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-access-methods-object)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerAvailabilityReplica`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-availability-replica)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-buffer-manager-object)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerDatabaseReplica`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-database-replica)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-databases-object?view=sql-server-2017)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerGeneralStatistics`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-general-statistics-object)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerLocks`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-locks-object)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerMemoryManager`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-memory-manager-object)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerSQLStatistics`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-sql-statistics-object)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerSQLErrors`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-sql-errors-object) +Classes | [`Win32_PerfRawData_MSSQLSERVER_SQLServerAccessMethods`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-access-methods-object)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerAvailabilityReplica`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-availability-replica)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-buffer-manager-object)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerDatabaseReplica`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-database-replica)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-databases-object?view=sql-server-2017)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerGeneralStatistics`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-general-statistics-object)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerLocks`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-locks-object)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerMemoryManager`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-memory-manager-object)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerSQLStatistics`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-sql-statistics-object)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerSQLErrors`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-sql-errors-object)
[`Win32_PerfRawData_MSSQLSERVER_SQLServerTransactions`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-transactions-object) Enabled by default? | No ## Flags ### `--collectors.mssql.classes-enabled` -Comma-separated list of MSSQL WMI classes to use. Supported values are `accessmethods`, `availreplica`, `bufman`, `databases`, `dbreplica`, `genstats`, `locks`, `memmgr`, `sqlstats` and `sqlerrors`. +Comma-separated list of MSSQL WMI classes to use. Supported values are `accessmethods`, `availreplica`, `bufman`, `databases`, `dbreplica`, `genstats`, `locks`, `memmgr`, `sqlstats`, `sqlerrors` and `transactions`. ### `--collectors.mssql.class-print` @@ -231,6 +231,19 @@ Name | Description | Type | Labels `wmi_mssql_sqlstats_sql_recompilations` | _Not yet documented_ | counter | `instance` `wmi_mssql_sqlstats_unsafe_auto_parameterization_attempts` | _Not yet documented_ | counter | `instance` `wmi_mssql_sql_errors_total` | _Not yet documented_ | counter | `instance`, `resource` +`wmi_mssql_transactions_tempdb_free_space_bytes` | _Not yet documented_ | gauge | `instance` +`wmi_mssql_transactions_longest_transaction_running_seconds` | _Not yet documented_ | gauge | `instance` +`wmi_mssql_transactions_nonsnapshot_version_active_total` | _Not yet documented_ | counter | `instance` +`wmi_mssql_transactions_snapshot_active_total` | _Not yet documented_ | counter | `instance` +`wmi_mssql_transactions_active_total` | _Not yet documented_ | counter | `instance` +`wmi_mssql_transactions_update_conflict_ratio` | _Not yet documented_ | gauge | `instance` +`wmi_mssql_transactions_update_snapshot_active_total` | _Not yet documented_ | counter | `instance` +`wmi_mssql_transactions_version_cleanup_rate_bytes` | _Not yet documented_ | gauge | `instance` +`wmi_mssql_transactions_version_generation_rate_bytes` | _Not yet documented_ | gauge | `instance` +`wmi_mssql_transactions_version_store_size_bytes` | _Not yet documented_ | gauge | `instance` +`wmi_mssql_transactions_version_store_units` | _Not yet documented_ | counter | `instance` +`wmi_mssql_transactions_version_store_creation_units` | _Not yet documented_ | counter | `instance` +`wmi_mssql_transactions_version_store_truncation_units` | _Not yet documented_ | counter | `instance` ### Example metric _This collector does not yet have explained examples, we would appreciate your help adding them!_ From a283608812b2eb045635f652c27cc1020e3e478a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D1=8F=D0=BA=D0=BE=D0=B2=20=D0=98=D0=B3?= =?UTF-8?q?=D0=BE=D1=80=D1=8C?= Date: Sun, 4 Aug 2019 13:47:00 +0300 Subject: [PATCH 4/5] Fix review comments --- collector/mssql.go | 82 +++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/collector/mssql.go b/collector/mssql.go index 0707632ec..ab53080b8 100644 --- a/collector/mssql.go +++ b/collector/mssql.go @@ -364,19 +364,19 @@ type MSSQLCollector struct { SQLErrorsTotal *prometheus.Desc // Win32_PerfRawData_{instance}_SQLServerTransactions - TransactionsFreeSpaceInTempDbKB *prometheus.Desc - TransactionsLongestTransactionRunningTime *prometheus.Desc - TransactionsNonSnapshotVersionTotalActive *prometheus.Desc - TransactionsSnapshotTotalActive *prometheus.Desc - TransactionsTotalActive *prometheus.Desc - TransactionsUpdateConflictRatio *prometheus.Desc - TransactionsUpdateSnapshotTotalActive *prometheus.Desc - TransactionsVersionCleanupRateKBs *prometheus.Desc - TransactionsVersionGenerationRateKBs *prometheus.Desc - TransactionsVersionStoreSizeKB *prometheus.Desc - TransactionsVersionStoreUnitCount *prometheus.Desc - TransactionsVersionStoreUnitCreation *prometheus.Desc - TransactionsVersionStoreUnitTruncation *prometheus.Desc + TransactionsTempDbFreeSpaceBytes *prometheus.Desc + TransactionsLongestTransactionRunningSeconds *prometheus.Desc + TransactionsNonSnapshotVersionActiveTotal *prometheus.Desc + TransactionsSnapshotActiveTotal *prometheus.Desc + TransactionsActiveTotal *prometheus.Desc + TransactionsUpdateConflictRatio *prometheus.Desc + TransactionsUpdateSnapshotActiveTotal *prometheus.Desc + TransactionsVersionCleanupRateBytes *prometheus.Desc + TransactionsVersionGenerationRateBytes *prometheus.Desc + TransactionsVersionStoreSizeBytes *prometheus.Desc + TransactionsVersionStoreUnits *prometheus.Desc + TransactionsVersionStoreCreationUnits *prometheus.Desc + TransactionsVersionStoreTruncationUnits *prometheus.Desc mssqlInstances mssqlInstancesType mssqlCollectors mssqlCollectorsMap @@ -1666,31 +1666,31 @@ func NewMSSQLCollector() (Collector, error) { ), // Win32_PerfRawData_{instance}_SQLServerTransactions - TransactionsFreeSpaceInTempDbKB: prometheus.NewDesc( + TransactionsTempDbFreeSpaceBytes: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_tempdb_free_space_bytes"), "(Transactions.FreeSpaceInTempDbKB)", []string{"instance"}, nil, ), - TransactionsLongestTransactionRunningTime: prometheus.NewDesc( + TransactionsLongestTransactionRunningSeconds: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_longest_transaction_running_seconds"), "(Transactions.LongestTransactionRunningTime)", []string{"instance"}, nil, ), - TransactionsNonSnapshotVersionTotalActive: prometheus.NewDesc( + TransactionsNonSnapshotVersionActiveTotal: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_nonsnapshot_version_active_total"), "(Transactions.NonSnapshotVersionTransactions)", []string{"instance"}, nil, ), - TransactionsSnapshotTotalActive: prometheus.NewDesc( + TransactionsSnapshotActiveTotal: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_snapshot_active_total"), "(Transactions.SnapshotTransactions)", []string{"instance"}, nil, ), - TransactionsTotalActive: prometheus.NewDesc( + TransactionsActiveTotal: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_active_total"), "(Transactions.Transactions)", []string{"instance"}, @@ -1702,43 +1702,43 @@ func NewMSSQLCollector() (Collector, error) { []string{"instance"}, nil, ), - TransactionsUpdateSnapshotTotalActive: prometheus.NewDesc( + TransactionsUpdateSnapshotActiveTotal: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_update_snapshot_active_total"), "(Transactions.UpdateSnapshotTransactions)", []string{"instance"}, nil, ), - TransactionsVersionCleanupRateKBs: prometheus.NewDesc( + TransactionsVersionCleanupRateBytes: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_version_cleanup_rate_bytes"), "(Transactions.VersionCleanupRateKBs)", []string{"instance"}, nil, ), - TransactionsVersionGenerationRateKBs: prometheus.NewDesc( + TransactionsVersionGenerationRateBytes: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_version_generation_rate_bytes"), "(Transactions.VersionGenerationRateKBs)", []string{"instance"}, nil, ), - TransactionsVersionStoreSizeKB: prometheus.NewDesc( + TransactionsVersionStoreSizeBytes: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_version_store_size_bytes"), "(Transactions.VersionStoreSizeKB)", []string{"instance"}, nil, ), - TransactionsVersionStoreUnitCount: prometheus.NewDesc( + TransactionsVersionStoreUnits: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_version_store_units"), "(Transactions.VersionStoreUnitCount)", []string{"instance"}, nil, ), - TransactionsVersionStoreUnitCreation: prometheus.NewDesc( + TransactionsVersionStoreCreationUnits: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_version_store_creation_units"), "(Transactions.VersionStoreUnitCreation)", []string{"instance"}, nil, ), - TransactionsVersionStoreUnitTruncation: prometheus.NewDesc( + TransactionsVersionStoreTruncationUnits: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "transactions_version_store_truncation_units"), "(Transactions.VersionStoreUnitTruncation)", []string{"instance"}, @@ -3733,35 +3733,35 @@ func (c *MSSQLCollector) collectTransactions(ch chan<- prometheus.Metric, sqlIns v := dst[0] ch <- prometheus.MustNewConstMetric( - c.TransactionsFreeSpaceInTempDbKB, + c.TransactionsTempDbFreeSpaceBytes, prometheus.GaugeValue, - float64(v.FreeSpaceintempdbKB), + float64(v.FreeSpaceintempdbKB*1024), sqlInstance, ) ch <- prometheus.MustNewConstMetric( - c.TransactionsLongestTransactionRunningTime, + c.TransactionsLongestTransactionRunningSeconds, prometheus.GaugeValue, float64(v.LongestTransactionRunningTime), sqlInstance, ) ch <- prometheus.MustNewConstMetric( - c.TransactionsNonSnapshotVersionTotalActive, + c.TransactionsNonSnapshotVersionActiveTotal, prometheus.CounterValue, float64(v.NonSnapshotVersionTransactions), sqlInstance, ) ch <- prometheus.MustNewConstMetric( - c.TransactionsSnapshotTotalActive, + c.TransactionsSnapshotActiveTotal, prometheus.CounterValue, float64(v.SnapshotTransactions), sqlInstance, ) ch <- prometheus.MustNewConstMetric( - c.TransactionsTotalActive, + c.TransactionsActiveTotal, prometheus.CounterValue, float64(v.Transactions), sqlInstance, @@ -3775,49 +3775,49 @@ func (c *MSSQLCollector) collectTransactions(ch chan<- prometheus.Metric, sqlIns ) ch <- prometheus.MustNewConstMetric( - c.TransactionsUpdateSnapshotTotalActive, + c.TransactionsUpdateSnapshotActiveTotal, prometheus.CounterValue, float64(v.UpdateSnapshotTransactions), sqlInstance, ) ch <- prometheus.MustNewConstMetric( - c.TransactionsVersionCleanupRateKBs, + c.TransactionsVersionCleanupRateBytes, prometheus.GaugeValue, - float64(v.VersionCleanuprateKBPers), + float64(v.VersionCleanuprateKBPers*1024), sqlInstance, ) ch <- prometheus.MustNewConstMetric( - c.TransactionsVersionGenerationRateKBs, + c.TransactionsVersionGenerationRateBytes, prometheus.GaugeValue, - float64(v.VersionGenerationrateKBPers), + float64(v.VersionGenerationrateKBPers*1024), sqlInstance, ) ch <- prometheus.MustNewConstMetric( - c.TransactionsVersionStoreSizeKB, + c.TransactionsVersionStoreSizeBytes, prometheus.GaugeValue, - float64(v.VersionStoreSizeKB), + float64(v.VersionStoreSizeKB*1024), sqlInstance, ) ch <- prometheus.MustNewConstMetric( - c.TransactionsVersionStoreUnitCount, + c.TransactionsVersionStoreUnits, prometheus.CounterValue, float64(v.VersionStoreunitcount), sqlInstance, ) ch <- prometheus.MustNewConstMetric( - c.TransactionsVersionStoreUnitCreation, + c.TransactionsVersionStoreCreationUnits, prometheus.CounterValue, float64(v.VersionStoreunitcreation), sqlInstance, ) ch <- prometheus.MustNewConstMetric( - c.TransactionsVersionStoreUnitTruncation, + c.TransactionsVersionStoreTruncationUnits, prometheus.CounterValue, float64(v.VersionStoreunittruncation), sqlInstance, From a90f9cda0f4829ee6079b2dd517e0aebd76fcd26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D1=8F=D0=BA=D0=BE=D0=B2=20=D0=98=D0=B3?= =?UTF-8?q?=D0=BE=D1=80=D1=8C?= Date: Sun, 4 Aug 2019 17:13:41 +0300 Subject: [PATCH 5/5] Change transaction_conflict_ratio to total --- collector/mssql.go | 10 +++++----- docs/collector.mssql.md | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/collector/mssql.go b/collector/mssql.go index ab53080b8..c166ecbc6 100644 --- a/collector/mssql.go +++ b/collector/mssql.go @@ -369,7 +369,7 @@ type MSSQLCollector struct { TransactionsNonSnapshotVersionActiveTotal *prometheus.Desc TransactionsSnapshotActiveTotal *prometheus.Desc TransactionsActiveTotal *prometheus.Desc - TransactionsUpdateConflictRatio *prometheus.Desc + TransactionsUpdateConflictsTotal *prometheus.Desc TransactionsUpdateSnapshotActiveTotal *prometheus.Desc TransactionsVersionCleanupRateBytes *prometheus.Desc TransactionsVersionGenerationRateBytes *prometheus.Desc @@ -1696,8 +1696,8 @@ func NewMSSQLCollector() (Collector, error) { []string{"instance"}, nil, ), - TransactionsUpdateConflictRatio: prometheus.NewDesc( - prometheus.BuildFQName(Namespace, subsystem, "transactions_update_conflict_ratio"), + TransactionsUpdateConflictsTotal: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "transactions_update_conflicts_total"), "(Transactions.UpdateConflictRatio)", []string{"instance"}, nil, @@ -3768,8 +3768,8 @@ func (c *MSSQLCollector) collectTransactions(ch chan<- prometheus.Metric, sqlIns ) ch <- prometheus.MustNewConstMetric( - c.TransactionsUpdateConflictRatio, - prometheus.GaugeValue, + c.TransactionsUpdateConflictsTotal, + prometheus.CounterValue, float64(v.Updateconflictratio), sqlInstance, ) diff --git a/docs/collector.mssql.md b/docs/collector.mssql.md index 4e21f8fa5..4b619673d 100644 --- a/docs/collector.mssql.md +++ b/docs/collector.mssql.md @@ -236,7 +236,7 @@ Name | Description | Type | Labels `wmi_mssql_transactions_nonsnapshot_version_active_total` | _Not yet documented_ | counter | `instance` `wmi_mssql_transactions_snapshot_active_total` | _Not yet documented_ | counter | `instance` `wmi_mssql_transactions_active_total` | _Not yet documented_ | counter | `instance` -`wmi_mssql_transactions_update_conflict_ratio` | _Not yet documented_ | gauge | `instance` +`wmi_mssql_transactions_update_conflicts_total` | _Not yet documented_ | counter | `instance` `wmi_mssql_transactions_update_snapshot_active_total` | _Not yet documented_ | counter | `instance` `wmi_mssql_transactions_version_cleanup_rate_bytes` | _Not yet documented_ | gauge | `instance` `wmi_mssql_transactions_version_generation_rate_bytes` | _Not yet documented_ | gauge | `instance`