Microsoft SQL Server receiver

The Microsoft SQL server receiver grabs metrics from a Microsoft SQL Server instance.

The Microsoft SQL Server receiver, a component of the Splunk Distribution of the OpenTelemetry Collector, queries and retrieves metrics from Microsoft SQL Server instances. The receiver works either by using the Windows Performance Counters, or by directly connecting to an instance and querying it. The supported pipeline type is metrics. See Process your data with pipelines for more information.

The following applies:

  • Windows Performance Counters are only available when running on Windows.

  • Make sure to run the Collector as an administrator in order to collect all performance counters for metrics.

Prerequisites

  1. Create the following permissions:

    • VIEW SERVER PERFORMANCE STATE if you're using Microsoft SQL Server 2022 or later versions.

    • VIEW SERVER STATE if you're using previous versions.

    Depending on the tasks you want to perform you also need at least one of the following permissions:

    • CREATE DATABASE

    • ALTER ANY DATABASE

    • VIEW ANY DEFINITION

    Check with your database provider's documentation for details.

  2. Create a non-admin user:

    This is a basic example of how to create a non-admin, read-only Microsoft SQL Server user:

    CREATE LOGIN [splunk-otel-collector] WITH PASSWORD = '<SECURE_PASSWORD>'; 
    CREATE USER [splunk-otel-collector] FOR LOGIN [splunk-otel-collector]; 
    GRANT VIEW SERVER STATE TO [splunk-otel-collector]; 
    GRANT VIEW ANY DEFINITION TO [splunk-otel-collector];

Get started

Follow these steps to configure and activate the receiver:

  1. Deploy the collector.

  2. Configure the receiver.

  3. Restart the collector.

Deploy the collector

Deploy the Splunk Distribution of the OpenTelemetry Collector on your host or container platform:

Configure the receiver

Configure the Microsoft SQL Server receiver, sqlserver, in the Splunk Distribution of the OpenTelemetry Collector that you deployed on your host or container platform:

  1. Add sqlserver to the receivers section of your Splunk Distribution of the OpenTelemetry Collector configuration file. For details on sqlserver parameters, see the OpenTelemetry Microsoft SQL Server receiver README.

    Tip: You are responsible for keeping your sqlserver configuration compatible with any updates to this receiver. Updates are typically announced on its README page, so the best practice is to monitor this page for updates you might need to make to your configuration.
    Tip: The example below shows a password as clear text, but you can store your password securely through your choice of secret management software and simply reference it through an environment variable or an external file.
    Sample configuration
    receivers:
      sqlserver:
        collection_interval: 10s
        username: sa
        password: password123
        server: mssql-server.mssqltest.svc.cluster.local
        port: 1433
        resource_attributes:
          sqlserver.computer.name:
            enabled: true
          sqlserver.instance.name:
            enabled: true
    Sample configuration for Windows (configure a named instance)

    If you’re using a named instance on Windows, specify a computer and instance name:

    receivers:
      sqlserver:
        collection_interval: 10s
        computer_name: CustomServer
        instance_name: CustomInstance
        resource_attributes:
          sqlserver.computer.name:
            enabled: true
          sqlserver.instance.name:
            enabled: true
  2. Enable built-in content.

    Splunk Observability Cloud provides built-in dashboards with charts that give you immediate visibility into the technologies and services being used in your environment. Learn more at Monitor the Collector with Splunk Observability Cloud’s built-in dashboards.

    CAUTION: For the Microsoft SQL Server receiver out-of-the-box content to work properly, you need to explicitly activate and deactivate specific metrics and resource attributes in your configuration file:
    Enable metrics and resource attributes

    Some resource attributes, such as sqlserver.instance.name, are deactivated by default.

    To activate them, specify the option in your configuration file:

    receivers:
        sqlserver:
          collection_interval: 10s
          username: sa
          password: securepassword
          server: 0.0.0.0
          port: 1433
          resource_attributes:
            sqlserver.instance.name:
              enabled: true
    Use datasource to specify your connection string

    Use this option to define the connection string used when connecting to the database:

    receivers:
        sqlserver:
          datasource: sqlserver://username:password@host/instance?param1=value&param2=value
          server: 127.0.0.1
          trusted_connection: true
    

    For more information:

  3. Configure advanced settings.

  4. Add sqlserver to the collector's metrics pipeline, which is within the service section of the collector's configuration file:

    service:
      pipelines:
        metrics:
          receivers:
            - sqlserver
  5. Restart the collector.

Restart the collector

The command to restart the Splunk Distribution of the OpenTelemetry Collector varies depending on what platform you deployed it on and what tool you used to deploy it, but here are general examples of the restart command:

Settings

General optional settings:

  • collection_interval: The interval at which the receiver emits metrics. Default: 10s.

  • instance_name: The name of the specific SQL Server instance to monitor. If unspecified, metrics are scraped from all instances. If configured, you must also set computer_name when running on Windows.

Direct connection optional settings:

  • username: The username used to connect to the SQL Server instance.

  • password: The password used to connect to the SQL Server instance.

  • server: IP address or hostname of the SQL Server instance to connect to.

  • port: Port of the SQL Server instance to connect to.

  • datasource: Use this option to specify the direct connection using a string. It can't be used in conjunction with the username, password, server and port options. For more information refer to the example and to Microsoft's connection string descriptions in the Microsoft SQL documentation.

Windows-specific optional settings:

  • computer_name: The computer name identifies the SQL Server name or IP address of the computer being monitored. If specified, instance_name is also required. This option is ignored in non-Windows environments.

The following table describes all configuration settings for the Microsoft SQL Server receiver:

included

https://raw.githubusercontent.com/splunk/collector-config-tools/main/cfg-metadata/receiver/sqlserver.yaml

Metrics

The following metrics, resource attributes, and attributes, are available.

included

https://raw.githubusercontent.com/splunk/collector-config-tools/main/metric-metadata/sqlserverreceiver.yaml

Activate or deactivate specific metrics

You can activate or deactivate specific metrics by setting the enabled field in the metrics section for each metric. For example:

receivers:
  samplereceiver:
    metrics:
      metric-one:
        enabled: true
      metric-two:
        enabled: false

The following is an example of host metrics receiver configuration with activated metrics:

receivers:
  hostmetrics:
    scrapers:
      process:
        metrics:
          process.cpu.utilization:
            enabled: true
Note: Deactivated metrics aren’t sent to Splunk Observability Cloud.
Billing
  • If you’re in a MTS-based subscription, all metrics count towards metrics usage.

  • If you’re in a host-based plan, metrics listed as active (Active: Yes) on this document are considered default and are included free of charge.

Learn more at Infrastructure Monitoring subscription usage (Host and metric plans).

Troubleshooting

If you are a Splunk Observability Cloud customer and are not able to see your data in Splunk Observability Cloud, you can get help in the following ways.

Available to Splunk Observability Cloud customers

Available to prospective customers and free trial users

  • Ask a question and get answers through community support at Splunk Answers.

  • Join the Splunk #observability user group Slack channel to communicate with customers, partners, and Splunk employees worldwide. To join, see Chat groups.