Monitor MSSQL using OpenTelemetry receivers
This document demonstrate the steps to scrape MSSQL metrics as well as logs to KloudMate using various receivers.
The sqlserver receiver grabs metrics about a Microsoft SQL Server instance. The receiver works by either using the Windows Performance Counters, or by directly connecting to the instance and querying it. Windows Performance Counters are only available when running on Windows.
To get the MSSQL logs the SQL Query Receiver used. It uses custom SQL queries to generate metrics or logs from a database connection.
Here hostmetrics receiver, SQL server receiver, and SQL query receiver are configured.
Prerequisite:
- MSSQL server must be installed and running.
- Install the OpenTelemetry collector on the server. See Installing and Configuring OpenTelemetry Collector.
Make sure to run the collector as administrator in order to collect all performance counters for metrics.
Step-1: Configure the Microsoft SQL Server Receiver along with the hostmetrics receiver scrape the MSSQL metrics and SQL Query Receiver along with the filelog receiver to pull required logs.
- Linux Users: Open the file located at /etc/otelcol-contrib/config.yaml using your preferred text editor.
- Windows Users: Create a new file called config.yaml in the C:\Program Files\OpenTelemetry Collector folder. You can use Notepad or any text editor to do this.
Step 2: Configure the processor part to detect resource information from the host and append or override the resource value in telemetry data with this information.
- On-premise, non-cloud, or cloud
- AWS EC2:
Optional: To retrieve AWS EC2 instance tags along with logs and metrics, you need to associate an IAM role with the EC2 instance that includes the EC2:DescribeTags policy. The processor below needs to be added:
- Azure Virtual Machines:
Step 3:
Set up the KloudMate Backend on the exporter part with the correct extensions of the OpenTelemetry configuration file and configure the pipeline.
Change the pipeline as per your correct configuration.
Step 4: Restart the Opentelemetry collector service
Linux:
Windows:
- Go to the Windows service. You can directly search and open otherwise can go to Run ➝ type services.msc ➝ ok
- On service search for OpenTelemetry collector service and restart it.
Metrics | Description | Type | Unit |
---|---|---|---|
sqlserver_user_connection_count | Number of users connected to the SQL Server. | Gauge | number |
sqlserver_lock_wait_time_avg | Average wait time for all lock requests that had to wait. | Gauge | milliseconds |
sqlserver_lock_wait_rate | Number of lock requests resulting in a wait. | Gauge | number |
sqlserver_batch_request_rate | Number of batch requests received by SQL Server. | Gauge | number |
sqlserver_batch_sql_compilation_rate | Number of SQL compilations needed. | Gauge | number |
sqlserver_batch_sql_recompilation_rate | Number of SQL recompilations needed. | Gauge | number |
sqlserver_page_buffer_cache_hit_ratio | Pages found in the buffer pool without having to read from disk. | Gauge | number |
sqlserver_page_life_expectancy | Time a page will stay in the buffer pool. | Gauge | seconds |
sqlserver_page_split_rate | Number of pages split as a result of overflowing index pages. | Gauge | number |
sqlserver_page_lazy_write_rate | Number of lazy writes moving dirty pages to disk. | Gauge | number |
sqlserver_page_checkpoint_flush_rate | Number of pages flushed by operations requiring dirty pages to be flushed. | Gauge | number |
sqlserver_page_operation_rate | Number of physical database page operations issued. | Gauge | number |
sqlserver_transaction_log_growth_count | Total number of transaction log expansions for a database. | Sum | number |
sqlserver_transaction_log_shrink_count | Total number of transaction logs shrinks for a database. | Sum | number |
sqlserver_transaction_log_usage | Percent of transaction log space used. | Gauge | number |
sqlserver_transaction_log_flush_wait_rate | Number of commits waiting for a transaction log flush. | Gauge | number |
sqlserver_transaction_log_flush_rate | Number of log flushes. | Gauge | number |
sqlserver_transaction_log_flush_data_rate | Total number of log bytes flushed. | Gauge | bytes |
sqlserver_transaction_rate | Number of transactions started for the database (not including XTP-only transactions). | Gauge | number |
sqlserver_transaction_write_rate | Number of transactions that were written to the database and committed. | Gauge | number |
sqlserver_database_latency | Total time that the users waited for I/O issued on this file. | Sum | seconds |
sqlserver_database_operations | The number of operations issued on the file. | Sum | number |
sqlserver_database_io | The number of bytes of I/O on this file. | Sum | bytes |
sqlserver_resource_pool_disk_throttled_read_rate | The number of read operations that were throttled in the last second | Gauge | number |
sqlserver_resource_pool_disk_throttled_write_rate | The number of write operations that were throttled in the last second | Gauge | number |
sqlserver_processes_blocked | The number of processes that are currently blocked. | Gauge | number |
sqlserver_database_count | The number of databases. | Gauge | number |