Skip to content
5 changes: 5 additions & 0 deletions packages/microsoft_sqlserver/_dev/build/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ See: [SQL Server Audit page](https://docs.microsoft.com/en-us/sql/relational-dat

Microsoft SQL Server has a feature that allows running multiple databases on the same host (or clustered hosts) with separate settings. Establish named instance connection by using the instance name along with the host name (Ex: `host/instance_name` or `host:named_instance_port`) to collect metrics. Details of the host configuration is provided below.

### Query by Instance Name or Server Name in Kibana

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 server name by `mssql.metrics.server_name` fields.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.


## Host Configuration

Integration supports collecting metrics from single host. For multi host metrics, each host can be run as a new integration.
Expand Down
7 changes: 6 additions & 1 deletion packages/microsoft_sqlserver/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# newer versions go on top
- version: "1.10.0"
changes:
- description: Ingest instance name and server names.
type: enhancement
link: https://github.com/elastic/integrations/pull/4698
- version: "1.9.0"
changes:
- description: Support list of dynamic counter name.
Expand All @@ -11,7 +16,7 @@
link: https://github.com/elastic/integrations/pull/4485
- version: "1.7.0"
changes:
- description: Merge results introuduced in performance.
- description: Merge results introduced in performance.
type: enhancement
link: https://github.com/elastic/integrations/pull/4561
- description: Allow text encoding configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ merge_results: true
dynamic_counter_name: "{{dynamic_counter_name}}"
driver: "mssql"
sql_queries:
- query: "SELECT @@servername AS server_name, @@servicename AS instance_name;"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a section to the documentation, how the server_name and instance_name populated with an example?

response_format: table
- query: "SELECT cntr_value As 'user_connections' FROM sys.dm_os_performance_counters WHERE counter_name= 'User Connections'"
response_format: table
- query: "SELECT cntr_value As 'active_temp_tables' FROM sys.dm_os_performance_counters WHERE counter_name = 'Active Temp Tables' AND object_name like '%General Statistics%'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
- name: metrics
type: group
fields:
- name: server_name
type: keyword
description: Name of the mssql server.
- name: instance_name
type: keyword
description: Name of the mssql connected instance.
- name: page_splits_per_sec
type: float
metric_type: gauge
Expand Down Expand Up @@ -64,4 +70,4 @@
description: Ideal number of pages in the buffer pool.
- name: memory_grants_pending
type: long
description: This is generated from the default pattern given for Dynamic Counter Name variable. This counter tells us how many processes are waiting for the memory to be assigned to them so they can get started.
description: This is generated from the default pattern given for Dynamic Counter Name variable. This counter tells us how many processes are waiting for the memory to be assigned to them so they can get started.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"@timestamp": "2022-11-15T10:59:06.048Z",
"@timestamp": "2022-11-23T05:03:28.987Z",
"agent": {
"ephemeral_id": "c15c314e-c8ef-41f0-8697-eefd3aa8d0a1",
"id": "c305f9fa-07c8-41b9-b950-fa4652b743bb",
"ephemeral_id": "70f5c0c1-37b1-486b-9806-8105b2cdcd20",
"id": "6d444a4a-2158-445e-8953-dc6eef720a34",
"name": "docker-fleet-agent",
"type": "metricbeat",
"version": "8.5.0"
Expand Down Expand Up @@ -31,15 +31,15 @@
"version": "8.0.0"
},
"elastic_agent": {
"id": "c305f9fa-07c8-41b9-b950-fa4652b743bb",
"id": "6d444a4a-2158-445e-8953-dc6eef720a34",
"snapshot": false,
"version": "8.5.0"
},
"event": {
"agent_id_status": "verified",
"dataset": "microsoft_sqlserver.performance",
"duration": 40261000,
"ingested": "2022-11-15T10:59:07Z",
"duration": 41134100,
"ingested": "2022-11-23T05:03:30Z",
"module": "sql"
},
"host": {
Expand All @@ -48,10 +48,10 @@
"hostname": "docker-fleet-agent",
"id": "66392b0697b84641af8006d87aeb89f1",
"ip": [
"172.31.0.7"
"172.18.0.5"
],
"mac": [
"02-42-AC-1F-00-07"
"02-42-AC-12-00-05"
],
"name": "docker-fleet-agent",
"os": {
Expand All @@ -71,19 +71,21 @@
"mssql": {
"metrics": {
"active_temp_tables": 0,
"batch_requests_per_sec": 65,
"buffer_cache_hit_ratio": 74,
"buffer_checkpoint_pages_per_sec": 274,
"batch_requests_per_sec": 54,
"buffer_cache_hit_ratio": 24,
"buffer_checkpoint_pages_per_sec": 105,
"buffer_database_pages": 2215,
"buffer_page_life_expectancy": 30,
"buffer_page_life_expectancy": 16,
"buffer_target_pages": 2408448,
"compilations_per_sec": 83,
"lock_waits_per_sec": 3,
"logins_per_sec": 20,
"logouts_per_sec": 19,
"compilations_per_sec": 80,
"instance_name": "MSSQLSERVER",
"lock_waits_per_sec": 4,
"logins_per_sec": 16,
"logouts_per_sec": 15,
"memory_grants_pending": 0,
"page_splits_per_sec": 9,
"re_compilations_per_sec": 0,
"server_name": "d10aad520431",
"transactions": 0,
"user_connections": 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,13 @@ driver: mssql
raw_data.enabled: true
# Collect the transaction logs from the system database
sql_queries:
- query: "SELECT name As 'database_name', database_id FROM sys.databases WHERE database_id=1;"
{{#if databases}}
{{#each databases as |database_name i|}}
- query: "SELECT @@servername AS server_name, @@servicename AS instance_name, name As 'database_name', database_id FROM sys.databases WHERE name='{{database_name}}';"
response_format: table
- query: "SELECT 'master' As database_name, database_id,total_log_size_mb,active_log_size_mb,log_backup_time,log_since_last_log_backup_mb,log_since_last_checkpoint_mb,log_recovery_size_mb FROM sys.dm_db_log_stats(1) master"
- query: "SELECT @@servername AS server_name, @@servicename AS instance_name, name As 'database_name', l.database_id, l.total_log_size_mb, l.active_log_size_mb,l.log_backup_time,l.log_since_last_log_backup_mb,l.log_since_last_checkpoint_mb,l.log_recovery_size_mb from sys.dm_db_log_stats(DB_ID('{{database_name}}')) l INNER JOIN sys.databases s ON l.database_id = s.database_id WHERE s.database_id = DB_ID('{{database_name}}') ;"
response_format: table
- query: "SELECT 'master' As 'database_name', total_log_size_in_bytes As total_log_size_bytes, used_log_space_in_bytes As used_log_space_bytes, used_log_space_in_percent As used_log_space_pct, log_space_in_bytes_since_last_backup FROM sys.dm_db_log_space_usage master"
response_format: table
- query: "SELECT name As 'database_name', database_id FROM sys.databases WHERE database_id=2;"
response_format: table
- query: "SELECT 'tempdb' As 'database_name', database_id,total_log_size_mb,active_log_size_mb As active_log_size,log_backup_time,log_since_last_log_backup_mb, log_since_last_checkpoint_mb,log_recovery_size_mb FROM sys.dm_db_log_stats(2) tempdb"
response_format: table
- query: "SELECT 'tempdb' As 'database_name', total_log_size_in_bytes As total_log_size_bytes, used_log_space_in_bytes As used_log_space_bytes, used_log_space_in_percent As used_log_space_pct, log_space_in_bytes_since_last_backup FROM sys.dm_db_log_space_usage tempdb"
response_format: table
- query: "SELECT name As 'database_name', database_id FROM sys.databases WHERE database_id=3;"
response_format: table
- query: "SELECT 'model' As 'database_name', database_id,total_log_size_mb,active_log_size_mb As active_log_size,log_backup_time,log_since_last_log_backup_mb, log_since_last_checkpoint_mb,log_recovery_size_mb FROM sys.dm_db_log_stats(3) model"
response_format: table
- query: "SELECT 'model' As 'database_name', total_log_size_in_bytes As total_log_size_bytes, used_log_space_in_bytes As used_log_space_bytes, used_log_space_in_percent As used_log_space_pct, log_space_in_bytes_since_last_backup FROM sys.dm_db_log_space_usage model"
response_format: table
- query: "SELECT name As 'database_name', database_id FROM sys.databases WHERE database_id=4;"
response_format: table
- query: "SELECT 'msdb' As 'database_name', database_id,total_log_size_mb,active_log_size_mb As active_log_size,log_backup_time,log_since_last_log_backup_mb, log_since_last_checkpoint_mb,log_recovery_size_mb FROM sys.dm_db_log_stats(4) msdb"
response_format: table
- query: "SELECT 'msdb' As 'database_name', total_log_size_in_bytes As total_log_size_bytes, used_log_space_in_bytes As used_log_space_bytes, used_log_space_in_percent As used_log_space_pct, log_space_in_bytes_since_last_backup FROM sys.dm_db_log_space_usage msdb"
- query: "SELECT @@servername AS server_name, @@servicename AS instance_name, name As 'database_name', l.database_id, l.total_log_size_in_bytes As total_log_size_bytes, l.used_log_space_in_bytes As used_log_space_bytes, l.used_log_space_in_percent As used_log_space_pct, l.log_space_in_bytes_since_last_backup from sys.dm_db_log_space_usage l INNER JOIN sys.databases s ON l.database_id = s.database_id WHERE s.database_id = DB_ID('{{database_name}}') ;"
response_format: table
{{/each}}
{{/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
- name: metrics
type: group
fields:
- name: server_name
type: keyword
description: Name of the mssql server.
- name: instance_name
type: keyword
description: Name of the mssql connected instance.
- name: database_id
type: long
dimension: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,13 @@ streams:
required: true
show_user: true
default: 60s
- name: databases
type: text
title: Databases
multi: true
required: true
show_user: false
description: Default system databases are preloaded. For custom database please add additional rows and enter the database name.
default: ["master", "model", "tempdb", "msdb"]
title: Microsoft SQL Server transaction_log metrics
description: Collect Microsoft SQL Server transaction_log metrics
Original file line number Diff line number Diff line change
@@ -1,47 +1,87 @@
{
"@timestamp": "2022-06-08T10:20:14.787809Z",
"mssql": {
"metrics": {
"database_name": "msdb",
"database_id": 1,
"used_log_space_bytes": 41.17647171020508,
"log_space_in_bytes_since_last_backup": 397312,
"total_log_size_bytes": 2088960,
"used_log_space_pct": 860160
}
},
"metricset": {
"period": 10000,
"name": "query"
},
"@timestamp": "2022-11-23T10:53:05.080Z",
"agent": {
"id": "e7b17c22-4223-46c3-b982-ff0d570b5fa6",
"ephemeral_id": "d1a76cf4-2463-478a-a474-36e771218467",
"ephemeral_id": "70f5c0c1-37b1-486b-9806-8105b2cdcd20",
"id": "6d444a4a-2158-445e-8953-dc6eef720a34",
"name": "docker-fleet-agent",
"type": "metricbeat",
"version": "8.3.0"
"version": "8.5.0"
},
"service": {
"address": "54.90.251.237:1433",
"type": "sql"
"cloud": {
"account": {},
"instance": {
"id": "b30e45e6-7900-4900-8d67-e37cb13374bc",
"name": "obs-int-windows-dev"
},
"machine": {
"type": "Standard_D16ds_v5"
},
"provider": "azure",
"region": "CentralIndia",
"service": {
"name": "Virtual Machines"
}
},
"data_stream": {
"dataset": "microsoft_sqlserver.transaction_log",
"namespace": "ep",
"type": "metrics"
},
"ecs": {
"version": "8.0.0"
},
"elastic_agent": {
"id": "e7b17c22-4223-46c3-b982-ff0d570b5fa6",
"version": "8.3.0",
"snapshot": true
"id": "6d444a4a-2158-445e-8953-dc6eef720a34",
"snapshot": false,
"version": "8.5.0"
},
"event": {
"duration": 5595352584,
"agent_id_status": "verified",
"ingested": "2022-05-23T10:20:21Z",
"module": "sql",
"dataset": "microsoft_sqlserver.transaction_log"
"dataset": "microsoft_sqlserver.transaction_log",
"duration": 1449739900,
"ingested": "2022-11-23T10:53:07Z",
"module": "sql"
},
"data_stream": {
"namespace": "default",
"type": "metrics",
"dataset": "microsoft_sqlserver.transaction_log"
"host": {
"architecture": "x86_64",
"containerized": false,
"hostname": "docker-fleet-agent",
"id": "66392b0697b84641af8006d87aeb89f1",
"ip": [
"172.18.0.5"
],
"mac": [
"02-42-AC-12-00-05"
],
"name": "docker-fleet-agent",
"os": {
"codename": "focal",
"family": "debian",
"kernel": "5.10.104-linuxkit",
"name": "Ubuntu",
"platform": "ubuntu",
"type": "linux",
"version": "20.04.5 LTS (Focal Fossa)"
}
},
"ecs": {
"version": "8.0.0"
"metricset": {
"name": "query",
"period": 60000
},
"mssql": {
"metrics": {
"database_id": 1,
"database_name": "master",
"instance_name": "MSSQLSERVER",
"log_space_in_bytes_since_last_backup": 139264,
"server_name": "obs-service-int",
"total_log_size_bytes": 2088960,
"used_log_space_bytes": 626688,
"used_log_space_pct": 30
}
},
"service": {
"address": "20.121.218.233",
"type": "sql"
}
}
Loading