Skip to content
Closed
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
45 changes: 45 additions & 0 deletions src/go/plugin/go.d/collector/mssql/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"database/sql"
_ "embed"
"errors"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -72,6 +73,26 @@ type Config struct {
// Default: true - MSSQL Query Store may contain unmasked PII in query text
QueryStoreFunctionEnabled *bool `yaml:"query_store_function_enabled,omitempty" json:"query_store_function_enabled"`

// DeadlockInfoFunctionEnabled controls whether the deadlock-info function is available
// Uses pointer to distinguish "unset" from explicit "false":
// - nil (unset): Apply default of true (enabled)
// - false: Explicitly disabled
// - true: Explicitly enabled
// Default: true
DeadlockInfoFunctionEnabled *bool `yaml:"deadlock_info_function_enabled,omitempty" json:"deadlock_info_function_enabled"`

// ErrorInfoFunctionEnabled controls whether the error-info function is available
// Uses pointer to distinguish "unset" from explicit "false":
// - nil (unset): Apply default of true (enabled)
// - false: Explicitly disabled
// - true: Explicitly enabled
// Default: true
ErrorInfoFunctionEnabled *bool `yaml:"error_info_function_enabled,omitempty" json:"error_info_function_enabled"`

// ErrorInfoSessionName sets the Extended Events session name for error-info
// Default: "netdata_errors"
ErrorInfoSessionName string `yaml:"error_info_session_name,omitempty" json:"error_info_session_name,omitempty"`

// TopQueriesLimit is the maximum number of queries to return
TopQueriesLimit int `yaml:"top_queries_limit,omitempty" json:"top_queries_limit,omitempty"`
}
Expand All @@ -92,6 +113,30 @@ func (c *Config) GetQueryStoreFunctionEnabled() bool {
return *c.QueryStoreFunctionEnabled
}

// GetDeadlockInfoFunctionEnabled returns whether the deadlock-info function is enabled (default: true)
func (c *Config) GetDeadlockInfoFunctionEnabled() bool {
if c.DeadlockInfoFunctionEnabled == nil {
return true
}
return *c.DeadlockInfoFunctionEnabled
}

// GetErrorInfoFunctionEnabled returns whether the error-info function is enabled (default: true)
func (c *Config) GetErrorInfoFunctionEnabled() bool {
if c.ErrorInfoFunctionEnabled == nil {
return true
}
return *c.ErrorInfoFunctionEnabled
}

// GetErrorInfoSessionName returns the Extended Events session name for error-info.
func (c *Config) GetErrorInfoSessionName() string {
if strings.TrimSpace(c.ErrorInfoSessionName) == "" {
return "netdata_errors"
}
return c.ErrorInfoSessionName
}

type Collector struct {
module.Base
Config `yaml:",inline" json:""`
Expand Down
30 changes: 29 additions & 1 deletion src/go/plugin/go.d/collector/mssql/config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@
"minimum": 1,
"maximum": 5000,
"default": 500
},
"deadlock_info_function_enabled": {
"title": "Enable Deadlock Info Function",
"description": "Enable the deadlock-info function. WARNING: query text may contain unmasked sensitive literals (PII). This function reads deadlock graphs from the system_health session and requires VIEW SERVER STATE. Grant with: GRANT VIEW SERVER STATE TO [netdata_user];",
"type": "boolean",
"default": true
},
"error_info_function_enabled": {
"title": "Enable Error Info Function",
"description": "Enable the error-info function. WARNING: error messages and query text may contain unmasked sensitive literals (PII). This function reads from a user-managed Extended Events session and requires VIEW SERVER STATE.",
"type": "boolean",
"default": true
},
"error_info_session_name": {
"title": "Error Info Session Name",
"description": "Name of the Extended Events session that captures error_reported events for error-info. The session must be created by an administrator and include a ring_buffer target.",
"type": "string",
"default": "netdata_errors"
}
},
"required": [
Expand Down Expand Up @@ -79,6 +97,15 @@
"query_store_time_window_days": {
"ui:help": "Limits Query Store data to recent days. Lower values improve performance on busy servers."
},
"deadlock_info_function_enabled": {
"ui:help": "When enabled, the deadlock-info function becomes available in the Netdata dashboard. WARNING: query text may contain unmasked sensitive literals and requires VIEW SERVER STATE permission."
},
"error_info_function_enabled": {
"ui:help": "When enabled, the error-info function becomes available in the Netdata dashboard. WARNING: error messages and query text may include sensitive literals."
},
"error_info_session_name": {
"ui:help": "The Extended Events session must be created by an administrator and include a ring_buffer target capturing sqlserver.error_reported with sql_text action."
},
"ui:flavour": "tabs",
"ui:options": {
"tabs": [
Expand All @@ -88,7 +115,8 @@
"update_every",
"dsn",
"timeout",
"vnode"
"vnode",
"deadlock_info_function_enabled"
]
},
{
Expand Down
Loading
Loading