Integrate a SQL Server instance
This topic describes how to connect a self-managed SQL Server to Cloud Monitor 2.0. The integration component uses the SQL (sql_exporter) adapter of aio-exporter to collect metrics such as connections, transactions, buffers, I/O waits, memory, and database status. You can deploy this integration in an ACK cluster or on an ECS instance in a VPC. After the connection is established, a SQL Server instance entity and a built-in dashboard are automatically created.
Requirements
Before you connect, confirm that the target instance meets the following prerequisites. If these prerequisites are not met, data collection may fail or metrics may be missing.
|
Condition |
Requirement |
|
Deployment type |
Self-managed SQL Server. Managed instances can also be connected if they meet the account and network requirements. |
|
Monitoring account |
The account must have |
|
Connection method |
Data is collected over a SQL connection. The default port is 1433. |
|
Network connectivity |
In an ACK environment, the target SQL Server must be accessible from the selected ACK cluster network. In an ECS (VPC) environment, the target ECS instance must be accessible from the vSwitch CIDR block of the managed agent. |
Prerequisites
-
Managed Service for Prometheus is activated.
-
For CS environments: The target ACK cluster must be connected to Cloud Monitor 2.0 and be in the running state. The target SQL Server service must be accessible from the cluster network.
-
For ECS (VPC) environments: The target SQL Server must be hosted on an ECS instance. This instance must be accessible from the vSwitch CIDR block of the managed agent.
Billing
-
Billing is based solely on the volume of metric data generated in Billing overview.
Integration methods
Step 1: Create a monitoring account
Create a dedicated, read-only monitoring account. Avoid using the sa account directly.
CREATE LOGIN [exporter] WITH PASSWORD = '<password>';
CREATE USER [exporter] FOR LOGIN [exporter];
GRANT VIEW ANY DEFINITION, VIEW SERVER STATE TO [exporter];
|
Permission |
Purpose |
|
VIEW ANY DEFINITION |
Read object definitions and metadata |
|
VIEW SERVER STATE |
Read server status and performance counters |
Step 2: Select an integration environment
This plugin supports two integration environments: CS and ECS (VPC). These environments work differently. Select an environment based on where your SQL Server is deployed.
CS
-
This method installs the Exporter on a target ACK cluster that you specify. The Exporter reuses the existing data collector in the cluster to collect metrics.
-
The monitored object is the ACK cluster.
-
Network requirements: The target SQL Server service must be accessible from within the cluster network. Examples include a Service within the cluster or a private IP address in a VPC that the cluster can access.
ECS (VPC)
-
You select the ECS instance where the target SQL Server service is deployed. The system then deploys a fully managed data collector based on the VPC information of the selected ECS instance.
-
No processes are installed on the ECS instance.
-
The monitored object is the ECS instance.
-
Network requirements: The target ECS instance must be accessible from the vSwitch CIDR block of the fully managed data collector. You must configure security groups and access control lists (ACLs) to permit this access.
|
Environment |
Exporter deployment location |
Process installed on business server? |
Monitored object |
Network accessibility requirements |
|
CS |
A user-specified ACK cluster |
No. The Exporter is deployed in the cluster and does not run on the host of the business pod. |
ACK cluster |
SQL Server is accessible from within the cluster's network. |
|
ECS (VPC) |
A fully managed data collector deployed by the system based on the VPC. |
No. No processes are installed on the ECS instance. |
ECS instance |
The vSwitch CIDR block of the managed agent can access the target ECS instance. |
Step 3: Configure the integration
-
Log on to the Cloud Monitor 2.0 console and select the target workspace. In the navigation pane on the left, click Integration Center, and then click SQL Server to start the integration.
-
Select an integration environment, either CS or ECS (VPC). From the Monitored Object drop-down list, select an object.
-
Configure the integration settings. When you are finished, click OK.
Configuration item
Required
Description
SQL Server service endpoint
Yes
For a CS environment, enter the endpoint that is accessible from within the cluster. For an ECS (VPC) environment, enter the private or public endpoint.
SQL Server service port
Yes
The default is 1433.
Cloud vendor / Deployment source
No
This value is written to the
providerlabel. For self-hosted deployments, the value isself-hosted/sqlserver.SQL Server account
Yes
The account must have the VIEW ANY DEFINITION and VIEW SERVER STATE permissions.
SQL Server password
Yes
The password for the monitoring account.
Metric collection interval (seconds)
Yes
The default is 15.
Custom tags
No
Additional labels to add to the metrics.
Use public registry address
No
This is disabled by default. Enable this option if the private image repository cannot be accessed.
-
After the integration is successful, you can view the integrated entities and their observable data in Entity Explorer.
Data usage
Entities
After integration, Cloud Monitor periodically discovers SQL Server instances from the labels of metrics such as mssql_up and generates middleware entities.
|
Dimension |
Description |
|
Domain |
middleware |
|
Entity type |
middleware.sqlserver |
|
Entity filter condition |
|
|
Observed object (bound entity) |
For CS environments, the value is |
Entity fields are derived from collected labels and are not related to the number of installations.
|
Field |
Description |
|
instance_id |
Instance identity. This field is derived from the |
|
provider |
Deployment source, such as |
|
port |
Service port. |
|
region_id |
Region. |
|
env_type |
Deployment environment type (CS or ECS). |
|
cluster_id |
The ID of the cluster to which the instance belongs. |
You can retrieve instances using these fields in the Entity Explorer or Middleware Insight application.
Built-in dashboards
|
Dashboard name |
Access point |
Description |
|
SQL Server Overview (Instance Overview) |
The Instance Overview tab on the entity details page. |
A UModel dashboard. Variables are automatically bound based on the instance context. |
|
SQL Server overview |
Grafana dashboard list. |
Provides a Grafana dashboard in both Chinese and English. |
Core metrics
The middleware.metric.sqlserver entity dataset contains 28 metrics. You can use these metrics on the entity details page, in dashboards, and for alerts.
|
Metric name |
Type |
Unit |
Display name |
Description |
|
mssql_up |
gauge |
- |
SQL Server Status |
Indicates whether the SQL Server instance is reachable and data is collected successfully. A value of 1 indicates that the instance is active. A value of 0 indicates that the instance is unavailable. |
|
mssql_product_version |
gauge |
- |
Edition |
The instance version number in `major.minor` format. |
|
mssql_instance_local_time |
gauge |
Time |
Instance Local Time |
The local clock of the instance, expressed in seconds since the epoch. |
|
mssql_connections |
gauge |
- |
Connections |
The number of active connections, counted per database. |
|
mssql_client_connections |
gauge |
- |
Client Connections |
The number of active client connections, counted per client and database. |
|
mssql_deadlocks |
counter |
/s |
Deadlocks per Second |
The number of lock requests per second that result in a deadlock. This value is calculated from the cumulative deadlock counter. |
|
mssql_user_errors |
counter |
/s |
User Errors per Second |
The number of user errors per second. This value is calculated from the cumulative user error counter. |
|
mssql_kill_connection_errors |
counter |
/s |
Kill Connection Errors per Second |
The number of errors per second from killing connections. This value is calculated from a cumulative counter. |
|
mssql_database_state |
gauge |
- |
Database State |
The state of the database: 0=ONLINE, 1=RESTORING, 2=RECOVERING, 3=RECOVERY_PENDING, 4=SUSPECT, 5=EMERGENCY, 6=OFFLINE, 7=COPYING, 10=OFFLINE_SECONDARY. |
|
mssql_log_growths |
counter |
/s |
Log Growths per Second |
The number of times per second that the transaction log for the database has expanded. This value is calculated from a cumulative counter. |
|
mssql_database_filesize |
gauge |
Bytes |
Database File Size |
The physical size of the files used by the database. Type: 0=data, 1=log, 2=filestream, 4=full-text. |
|
mssql_page_read_total |
counter |
times/s |
Page Reads per Second |
The number of physical page reads per second initiated by the buffer manager. |
|
mssql_page_write_total |
counter |
times/s |
Page Writes per Second |
The number of physical page writes per second initiated by the buffer manager. |
|
mssql_page_life_expectancy |
gauge |
Seconds |
Page Life Expectancy |
The minimum number of seconds a page can stay in the buffer pool without references. This is also known as Page Life Expectancy (PLE). |
|
mssql_lazy_write_total |
counter |
times/s |
Lazy Writes per Second |
The number of buffers written per second by the lazy writer. |
|
mssql_page_checkpoint_total |
counter |
times/s |
Checkpoint Pages per Second |
The number of pages flushed to disk per second by operations that require flushing dirty pages, such as checkpoints. |
|
mssql_io_stall_total |
counter |
ms/s |
IO Stall Rate |
The cumulative IO stall time per second, counted per database (ms/s). |
|
mssql_io_stall |
counter |
ms/s |
IO Stall Rate by Type |
The cumulative IO stall time per second, counted per database and IO type (ms/s). |
|
mssql_batch_requests |
counter |
times/s |
Batch Requests per Second |
The number of Transact-SQL command batches received by the instance per second. |
|
mssql_transactions |
counter |
times/s |
Transactions per Second |
The number of transactions started per second, counted per database. |
|
mssql_page_fault_count |
counter |
/s |
Page Faults per Second |
The number of page faults per second that occur in the SQL Server process. |
|
mssql_memory_usage_percentage |
gauge |
% |
Memory Usage |
The physical memory usage of the host where the SQL Server instance is located. This value is calculated from the total and available physical memory. |
|
mssql_physical_memory_in_use_kb |
gauge |
Bytes |
Process Memory Usage |
The physical memory (working set) currently used by the SQL Server process. |
|
mssql_memory_utilization_percentage |
gauge |
% |
Committed Memory in Working Set |
The percentage of committed memory that remains in the working set. This value is 100% when no swapping occurs. A value below 100% indicates that the operating system is reclaiming memory from SQL Server. This metric does not represent the memory usage of the instance. |
|
mssql_total_physical_memory_kb |
gauge |
Bytes |
Total Physical Memory |
The total physical memory of the host where the instance is located. |
|
mssql_available_physical_memory_kb |
gauge |
Bytes |
Available Physical Memory |
The available physical memory of the host where the instance is located. |
|
mssql_total_page_file_kb |
gauge |
Bytes |
Total Page File |
The total size of the paging file on the host where the instance is located. |
|
mssql_available_page_file_kb |
gauge |
Bytes |
Available Page File |
The available size of the paging file on the host where the instance is located. |
In addition to the aggregated metrics from the MetricSet, all raw metrics (mssql_*) collected by the exporter are written to Prometheus storage. You can query these metrics directly using Prometheus Query Language (PromQL).
Example queries
# Status
mssql_up
# Batch requests per second
rate(mssql_batch_requests[5m])
# Page life expectancy (seconds)
mssql_page_life_expectancy
# Process memory usage
mssql_physical_memory_in_use_kb
Alert templates
This integration component does not have built-in alert rules. In the Alert Center, you can configure alerts based on the metrics. For example, you can set an alert for when the mssql_up status metric is not equal to 1, or when the number of connections or the amount of message accumulation exceeds a threshold.
Storage policies
After you integrate SQL Server, Cloud Monitor creates a corresponding storage instance to store observable data.
|
Data type |
Default storage location |
Notes |
|
Metrics |
Prometheus instance: RegionShare:{{workspaceName}}:{{regionId}} |
Associated dataset: |
Manage or remove the integration
To modify or cancel the integration, go to the Integration Management page of Integration Center, find the corresponding integration policy, and then click Edit or Delete. When you delete the integration policy, the Exporter and the collection configuration are removed together. Historical metrics that have already been written are retained based on the lifecycle policy of the storage.