Kubesense

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:

  1. A Microsoft SQL Server instance (on Windows, Linux, or Azure SQL Managed Instance) reachable from the KubeSense OTEL collector
  2. KubeSense deployed with an OTEL Collector that can access the SQL Server endpoint
  3. A SQL Server login with permissions to query performance views (for example, a login mapped to the VIEW SERVER STATE privilege)
  4. Access to the SQL Server error/audit log files if you plan to ingest logs through filelog
  5. 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:
        - sqlserver

Note: 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 kubesense

Collecting 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_logs

Note: 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 kubesense

SQL Server Metrics Collected

KubeSense ingests the following key SQL Server metrics:

Metric NameTypeUnitDescription
sqlserver.cpu.countgaugenumberSQL Server CPU usage count
sqlserver.database.backup_or_restore.ratesumoperations/sBackup or restore operations per second
sqlserver.database.countgaugenumberNumber of databases on the instance
sqlserver.database.tempdb.spacegaugebytesTempDB space utilization
sqlserver.database.iogaugebytes/sDatabase I/O throughput
sqlserver.database.latencygaugemillisecondsDatabase read/write latency

For a complete list of available metrics, see the SQL Server receiver documentation in the OpenTelemetry Collector.

SQL Server Log Attributes

NamePathTypeDescription
TimestamptimestamptimestampTime the log entry was recorded
Severity Textseverity_textstringParsed log severity (INFO, WARN, ERROR, etc.)
MessagebodystringLog message content
Sourceattributes.sourcestringSet 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

ParameterTypeRequiredDescription
datasourcestringYesSQL Server connection string (Server=...;User Id=...;Password=...;Database=...)
collection_intervalstringNoFrequency of metric collection (default 60s)
metrics.*.enabledbooleanNoEnable or disable specific SQL Server metrics
include (logs)arrayYes (if using filelog)Absolute paths to SQL Server log files
regex_parser.regexstringNoRegular 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 sqlserver receiver only captures expensive queries—use filelog for 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.cluster and kubesense.env_type to 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.