Microsoft SQL Server
Integrating Microsoft SQL Server Metrics and Logs to KubeSense
KubeSense can ingest Microsoft SQL Server (MSSQL) telemetry through the OpenTelemetry (OTEL) Collector so that you can observe database performance, resource utilization, and operational logs inside the KubeSense platform.
Prerequisites
Before you begin, ensure you have:
- A Microsoft SQL Server instance (on Windows, Linux, or Azure SQL Managed Instance) reachable from the KubeSense OTEL collector
- KubeSense deployed with an OTEL Collector that can access the SQL Server endpoint
- A SQL Server login with permissions to query performance views (for example, a login mapped to the
VIEW SERVER STATEprivilege) - Access to the SQL Server error/audit log files if you plan to ingest logs through
filelog - Privileges to modify the KubeSense Helm values file and redeploy the chart
Collecting SQL Server Metrics
Step 1: Update KubeSense Helm Values File
Add the SQL Server receiver configuration to your KubeSense Helm values file (under the kubesensor section):
otel-collector:
config:
receivers:
sqlserver:
collection_interval: 60s
datasource: "Server=<SERVER_NAME>;User Id=<USER_ID>;Password=<PASSWORD>;Database=<DATABASE_NAME>"
metrics:
sqlserver.cpu.count:
enabled: true
sqlserver.database.backup_or_restore.rate:
enabled: true
sqlserver.database.count:
enabled: true
sqlserver.database.tempdb.space:
enabled: true
sqlserver.database.io:
enabled: true
sqlserver.database.latency:
enabled: true
appendToPipelines:
metrics:
receivers:
- sqlserverNote: Replace the placeholder connection string values with your environment details. The login should have read access to performance DMVs. For Azure SQL or managed instances, supply the fully qualified server name and ensure outbound ports are open.
Step 2: Apply the Configuration
Upgrade KubeSense with the updated values file:
helm upgrade kubesense kubesense/kubesense \
-f values.yaml \
--namespace kubesenseCollecting SQL Server Logs
The native sqlserver receiver only emits expensive query events. To ship error, audit, or custom logs, configure the filelog receiver to tail SQL Server log files.
Step 1: Configure FileLog Receiver
Extend your Helm values file to capture SQL Server log files:
otel-collector:
config:
receivers:
filelog/sqlserver:
include:
# Replace with the log path for your deployment (Windows or Linux)
- "C:/Program Files/Microsoft SQL Server/MSSQL15.MSSQLSERVER/MSSQL/Log/ERRORLOG"
# - "/var/opt/mssql/log/errorlog"
start_at: beginning
operators:
- type: regex_parser
regex: '^(?P<timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+)\s+(?P<severity>[A-Z]+)\s+(?P<message>.*)$'
timestamp:
parse_from: attributes.timestamp
layout: '%Y-%m-%d %H:%M:%S.%L'
severity:
parse_from: attributes.severity
- type: add
field: attributes.source
value: sqlserver
processors:
batch/sqlserver:
send_batch_size: 10000
send_batch_max_size: 11000
timeout: 10s
service:
pipelines:
logs/sqlserver:
receivers:
- filelog/sqlserver
processors:
- batch
- resource
exporters:
- otlphttp/kubesense_logsNote: Update the include paths and parsing expressions to match your SQL Server deployment (Windows paths vs. Linux /var/opt/mssql/log paths). Ensure the OTEL collector pod has permissions to read the log files.
Step 2: Apply the Configuration
Redeploy KubeSense to activate the new log pipeline:
helm upgrade kubesense kubesense/kubesense \
-f values.yaml \
--namespace kubesenseSQL Server Metrics Collected
KubeSense ingests the following key SQL Server metrics:
| Metric Name | Type | Unit | Description |
|---|---|---|---|
| sqlserver.cpu.count | gauge | number | SQL Server CPU usage count |
| sqlserver.database.backup_or_restore.rate | sum | operations/s | Backup or restore operations per second |
| sqlserver.database.count | gauge | number | Number of databases on the instance |
| sqlserver.database.tempdb.space | gauge | bytes | TempDB space utilization |
| sqlserver.database.io | gauge | bytes/s | Database I/O throughput |
| sqlserver.database.latency | gauge | milliseconds | Database read/write latency |
For a complete list of available metrics, see the SQL Server receiver documentation in the OpenTelemetry Collector.
SQL Server Log Attributes
| Name | Path | Type | Description |
|---|---|---|---|
| Timestamp | timestamp | timestamp | Time the log entry was recorded |
| Severity Text | severity_text | string | Parsed log severity (INFO, WARN, ERROR, etc.) |
| Message | body | string | Log message content |
| Source | attributes.source | string | Set to sqlserver for log identification |
Visualization in KubeSense
Once the pipelines are active, SQL Server metrics and logs surface in KubeSense dashboards and log explorer, allowing you to:
- Track CPU consumption, TempDB usage, and database I/O trends
- Monitor backup/restore throughput and latency across databases
- Investigate expensive query events as well as error/audit logs
- Build alerts on critical SQL Server health indicators
Configuration Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
datasource | string | Yes | SQL Server connection string (Server=...;User Id=...;Password=...;Database=...) |
collection_interval | string | No | Frequency of metric collection (default 60s) |
metrics.*.enabled | boolean | No | Enable or disable specific SQL Server metrics |
include (logs) | array | Yes (if using filelog) | Absolute paths to SQL Server log files |
regex_parser.regex | string | No | Regular expression used to parse log lines |
Troubleshooting
Metrics are missing or zeroed out
- Confirm the login has adequate permissions (for example,
VIEW SERVER STATE) - Verify network connectivity from the OTEL collector pod to the SQL Server endpoint
- Check collector logs for authentication or connection errors
Log ingestion fails
- Ensure the collector pod can read the log file path (use hostPath or sidecar if necessary)
- Update the regex pattern to match your SQL Server log format
- Remember that the
sqlserverreceiver only captures expensive queries—usefilelogfor general error logs
Linux deployments show limited metrics
- Some performance counters are Windows-only. For full coverage, deploy the receiver against a Windows-based SQL Server host, as noted by the SQL Server receiver documentation.
Best Practices
- Use dedicated read-only accounts for monitoring and rotate credentials regularly
- Keep log files accessible via host mounts and rotate them to prevent disk growth
- Tag telemetry with
kubesense.clusterandkubesense.env_typeto simplify filtering in dashboards - Monitor collector logs for throttling or parsing warnings
Conclusion
By integrating Microsoft SQL Server with KubeSense, you gain comprehensive visibility into database performance and operational events, enabling proactive monitoring and faster incident response.