Microsoft SQL Server Integration
| Version | 2.17.1 (View all) |
| Subscription level What's this? |
Basic |
| Developed by What's this? |
Elastic |
| Ingestion method(s) | API, Database, File |
| Minimum Kibana version(s) | 9.2.1 8.19.0 |
The Microsoft SQL Server integration package allows you to search, observe, and visualize the SQL Server audit logs, as well as performance and transaction log metrics, through Elasticsearch.
The Microsoft SQL Server integration collects two types of data streams: logs and metrics.
Log data streams provide records of events happening in Microsoft SQL Server:
audit: Events from the configured Windows event log channel, providing detailed auditing information. See SQL Server Audit.logs: Error logs created by the Microsoft SQL server for troubleshooting and system events.
Other log sources, such as files, are not supported.
Find more details in Logs.
Metrics data streams provide insights into SQL Server performance and health:
performance: Comprehensive performance counters and objects available on the server.transaction_log: Usage statistics and space utilization metrics for transaction logs.availability_groups: Health and synchronization metrics for Always On Availability Groups.
Find more details in Metrics.
You need Elasticsearch for storing and searching your data and Kibana for visualizing and managing it. You can use our hosted Elasticsearch Service on Elastic Cloud, which is recommended, or self-manage the Elastic Stack on your hardware.
Before you can start sending data to Elastic, make sure you have the necessary Microsoft SQL Server permissions.
If you browse Microsoft Developer Network (MSDN) for the following tables, you will find a "Permissions" section that defines the permission needed for each table (for example, the "Permissions" section on the sys.dm_db_log_space_usage page).
transaction_log:- sys.databases
- sys.dm_db_log_space_usage
- sys.dm_db_log_stats (DB_ID) (Available on SQL Server (MSSQL) 2016 (13.x) SP 2 and later)
performance:availability_groups:
Please make sure the user has the permissions to system as well as user-defined databases. For the particular user used in the integration, the following requirements are met:
User setup options:
- Grant specific permissions as mentioned in the MSDN pages above.
- Alteratively, use
sysadminrole (includes all required permissions): This can be configured via SQL Server Management Studio (SSMS) inServer Roles. Read more about joining a role in the SQL Server documentation.
User Mappings (using SQL Server Management Studio (SSMS)):
- Open SSMS and connect to your server.
- Navigate to "Object Explorer" > "Security" > "Logins".
- Right-click the user and select "Properties".
- In the "User Mapping" tab, select the appropriate database and grant the required permissions.
For step-by-step instructions on how to set up any integration, refer to the Getting started guide.
Below you'll find more specific details on setting up the Microsoft SQL Server integration.
Microsoft SQL Server has a feature that allows running multiple databases on the same host (or clustered hosts) with separate settings. Establish a named instance connection by using the instance name along with the hostname (e.g. host/instance_name or host:named_instance_port) to collect metrics. Details of the host configuration are provided below.
The data can be visualized in Kibana by filtering based on the instance name and server name. The instance name can be filtered by mssql.metrics.instance_name and the server name by mssql.metrics.server_name fields.
As part of the input configuration, you need to provide the user name, password and host details. The host configuration supports both named instances or default (no-name) instances, using the syntax below.
This integration supports collecting metrics from a single host. For multi-host metrics, each host can be run as a new integration.
Connecting to Default Instance (host):
host(e.g.localhost(Instance name is not needed when connecting to default instance))host:port(e.g.localhost:1433)
Connecting to Named Instance (host):
host/instance_name(e.g.localhost/namedinstance_01)host:named_instance_port(e.g.localhost:60873)
There are several levels of auditing for SQL Server, depending on government or standards requirements for your installation. The SQL Server Audit feature enables you to audit server-level and database-level groups of events and individual events.
For more information on the different audit levels, refer to SQL Server Audit Action Groups and Actions. Then to enable auditing for SQL Server, refer to these instructions.
For the integration package to be able to read and send audit events the event target must be configured to be Windows event log.
Collects SQL Server audit events from the specified windows event log channel.
The SQL Server log contains user-defined events and certain system events you can use for troubleshooting.
Read more in View the SQL Server error log in SQL Server Management Studio.
Collects the performance counter metrics. The dynamic counter feature provides flexibility to collect metrics by providing the counter as an input.
This input can be a regular expression which will filter results based on pattern.
For example, if %grant% is given as input, it will enable metrics collection for all of the counters with names like 'Memory Grants Pending', 'Active memory grants count' etc.
MSSQL supports a limited set of regular expressions. For more details, refer to Pattern Matching in Search Conditions.
Dynamic counters will go through some basic ingest pipeline post-processing to make counter names in lowercase and remove special characters and these fields will not have any static field mappings.
The feature merge_results has been introduced in 8.4 beats which creates a single event by combining the metrics in a single event. For more details, refer to SQL module.
Read more in instructions about each performance counter metrics.
The system-level database transaction_log metrics for SQL Server instances are collected by default. Metrics for user-level databases can be collected by specifying a list of user databases or by enabling the Fetch from all databases toggle to collect metrics from all databases on the server.
Read more in instructions and the operations supported by transaction log.
To simplify the process of fetching metrics from all databases on the server, you can enable the Fetch from all databases toggle when configuring the integration. This field overrides manually entered database names in the Databases input and instead fetches the required transaction_log metrics from all databases, including system and user-defined databases.
Keep in mind that this feature is disabled by default and needs to be manually enabled to be activated.
When the password contains special characters, pass these special characters using URL encoding.
Collects metrics related to Always On Availability Groups, including replica status and synchronization health. This dataset queries the following SQL Server tables:
sys.availability_groupssys.dm_hadr_availability_group_states
Always On Availability Groups must be enabled on your SQL Server instance for this dataset to collect metrics. This feature is available in SQL Server Enterprise and Standard editions (with limitations in Standard).
Prerequisites: To collect Availability Groups metrics, ensure the following:
- Always On Availability Groups feature is enabled on the SQL Server instance.
- The user account configured for the integration has
VIEW SERVER STATEandVIEW ANY DEFINITIONpermissions. Additionally look at section Microsoft SQL Server permissions.
Read more in Monitor Availability Groups and Always On Availability Groups overview.
The SQL Server audit dataset provides events from the configured Windows event log channel. All SQL Server audit-specific fields are available in the sqlserver.audit field group.
ECS Field Reference
Please refer to the following document for detailed information on ECS fields.
Exported fields
| Field | Description | Type |
|---|---|---|
| @timestamp | Event timestamp. | date |
| cloud.image.id | Image ID for the cloud instance. | keyword |
| data_stream.dataset | Data stream dataset. | constant_keyword |
| data_stream.namespace | Data stream namespace. | constant_keyword |
| data_stream.type | Data stream type. | constant_keyword |
| host.containerized | If the host is a container. | boolean |
| host.os.build | OS build information. | keyword |
| host.os.codename | OS codename, if any. | keyword |
| sqlserver.audit.action_id | ID of the action | keyword |
| sqlserver.audit.additional_information | Any additional information about the event stored as XML. | text |
| sqlserver.audit.affected_rows | Number of rows affected by the operation. | long |
| sqlserver.audit.application_name | Name of the application that caused the audit event. | keyword |
| sqlserver.audit.audit_schema_version | Audit event schema version. | keyword |
| sqlserver.audit.class_type | Type of auditable entity that the audit occurs on. | keyword |
| sqlserver.audit.client_ip | "Name or IP address of the machine running the application that caused the audit event." | keyword |
| sqlserver.audit.connection_id | Connection ID (unique UUID for the connection) | keyword |
| sqlserver.audit.data_sensitivity_information | Sensitivity information about the operation. | keyword |
| sqlserver.audit.database_name | The database context in which the action occurred. | keyword |
| sqlserver.audit.database_principal_id | ID of the database user context that the action is performed in. | keyword |
| sqlserver.audit.database_principal_name | Current user. | keyword |
| sqlserver.audit.duration_milliseconds | Duration of the operation in milliseconds. | long |
| sqlserver.audit.event_time | Date/time when the auditable action is fired. | date |
| sqlserver.audit.host_name | SQL Server host name. | keyword |
| sqlserver.audit.is_column_permission | Flag indicating a column level permission | boolean |
| sqlserver.audit.object_id | "The primary ID of the entity on which the audit occurred. This ID can be one of server objects, databases, database objects or schema objects." | keyword |
| sqlserver.audit.object_name | "The name of the entity on which the audit occurred. This can be server objects, databases, database objects, schema objects or TSQL statement (if any)." | keyword |
| sqlserver.audit.permission_bitmask | When applicable shows the permissions that were granted, denied or revoked. | keyword |
| sqlserver.audit.response_rows | Number of rows returned. | long |
| sqlserver.audit.schema_name | The schema context in which the action occurred. | keyword |
| sqlserver.audit.sequence_group_id | Sequence group ID (unique UUID). | keyword |
| sqlserver.audit.sequence_number | Tracks the sequence of records within a single audit record that was too large to fit in the write buffer for audits. | integer |
| sqlserver.audit.server_instance_name | "Name of the server instance where the audit occurred. Uses the standard machine\instance format." | keyword |
| sqlserver.audit.server_principal_id | ID of the login context that the action is performed in. | keyword |
| sqlserver.audit.server_principal_name | Current login. | keyword |
| sqlserver.audit.server_principal_sid | Current login SID. | keyword |
| sqlserver.audit.session_id | ID of the session on which the event occurred. | integer |
| sqlserver.audit.session_server_principal_name | Server principal for the session. | keyword |
| sqlserver.audit.statement | TSQL statement (if any) | text |
| sqlserver.audit.succeeded | Indicates whether or not the permission check of the action triggering the audit event succeeded or failed. | boolean |
| sqlserver.audit.target_database_principal_id | Database principal that the auditable action applies to. | keyword |
| sqlserver.audit.target_database_principal_name | Target user of the action. | keyword |
| sqlserver.audit.target_server_principal_id | Server principal that the auditable action applies to. | keyword |
| sqlserver.audit.target_server_principal_name | Target login of the action. | keyword |
| sqlserver.audit.target_server_principal_sid | SID of the target login. | keyword |
| sqlserver.audit.transaction_id | Transaction ID | keyword |
| sqlserver.audit.user_defined_event_id | User defined event ID. | integer |
| sqlserver.audit.user_defined_information | User defined information | text |
| winlog.activity_id | A globally unique identifier that identifies the current activity. The events that are published with this identifier are part of the same activity. | keyword |
| winlog.api | The event log API type used to read the record. The possible values are "wineventlog" for the Windows Event Log API or "eventlogging" for the Event Logging API. The Event Logging API was designed for Windows Server 2003 or Windows 2000 operating systems. In Windows Vista, the event logging infrastructure was redesigned. On Windows Vista or later operating systems, the Windows Event Log API is used. Winlogbeat automatically detects which API to use for reading event logs. | keyword |
| winlog.channel | The name of the channel from which this record was read. This value is one of the names from the event_logs collection in the configuration. |
keyword |
| winlog.computer_name | The name of the computer that generated the record. When using Windows event forwarding, this name can differ from agent.hostname. |
keyword |
| winlog.event_data | The event-specific data. This field is mutually exclusive with user_data. If you are capturing event data on versions prior to Windows Vista, the parameters in event_data are named param1, param2, and so on, because event log parameters are unnamed in earlier versions of Windows. |
object |
| winlog.event_data.param1 | keyword | |
| winlog.event_data.param2 | keyword | |
| winlog.event_data.param3 | keyword | |
| winlog.event_data.param4 | keyword | |
| winlog.event_data.param5 | keyword | |
| winlog.event_data.param6 | keyword | |
| winlog.event_data.param7 | keyword | |
| winlog.event_data.param8 | keyword | |
| winlog.event_id | The event identifier. The value is specific to the source of the event. | keyword |
| winlog.keywords | The keywords are used to classify an event. | keyword |
| winlog.opcode | The opcode defined in the event. Task and opcode are typically used to identify the location in the application from where the event was logged. | keyword |
| winlog.process.pid | The process_id of the Client Server Runtime Process. | long |
| winlog.process.thread.id | long | |
| winlog.provider_guid | A globally unique identifier that identifies the provider that logged the event. | keyword |
| winlog.provider_name | The source of the event log record (the application or service that logged the record). | keyword |