tencent cloud

Feedback

SQL Server Exporter Integration

Last updated: 2024-12-13 11:51:07

    Overview

    The Microsoft SQL Server Exporter is a community-developed tool designed specifically for collecting monitoring metrics from Microsoft SQL Server (MSSQL) databases. It reports performance, health, and other metric data through the MSSQL Exporter, which can be used for monitoring dashboards and anomaly alarms. Tencent Cloud Observability Platform (TCOP) Prometheus offers integration with MSSQL Exporter along with pre-configured Grafana monitoring dashboards.
    Note:
    If the MSSQL to be monitored is Tencent Cloud TencentDB for SQL Server, it is recommended to use Cloud Monitoring in the Integration Center, which supports one-click collection of cloud product metrics.

    Connection Method

    Method 1: One-Click Installation (Recommended)

    Operation Steps

    1. Log in to the TMP console.
    2. Select the corresponding Prometheus instance from the instance list.
    3. Go to the instance details page, select Data Collection > Integration Center.
    4. In the Integration Center, locate and click MSSQL to open an installation window. On the installation page, enter details such as the metric collection name and address, then click save.
    
    
    

    Configuration Instructions

    Parameters
    Description
    name
    Exporter name, which should meet the following requirements:
    The name should be unique.
    The name should conform to the following regular expression: '^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$'.
    user
    The username of MSSQL.
    password
    The password of MSSQL.
    Host
    The service domain name of MSSQL.
    Port
    The service port of MSSQL.
    tag
    Custom labels for metrics.

    Method 2: Custom Installation

    Description
    TKE is recommended for convenient installation and management of the Exporter.

    Prerequisites

    A TKE cluster has been created in the region and VPC of the corresponding Prometheus instance, and a namespace has been created for the cluster.
    In the TMP console, select the corresponding Prometheus instance, and in Data Collection > Integration with TKE, locate the corresponding container cluster to complete the cluster association. For details, see the guide on Integration with TKE.

    Operation Steps

    Step 1: Deploying the Exporter
    1. Log in to the TKE console.
    2. Click Cluster in the left sidebar.
    3. Click the ID/name of the cluster whose access credential is required to go to the management page of the cluster.
    4. Follow these steps to complete the Exporter deployment: Deploy MSSQL Exporter > Verification.
    Step 2: Deploying MSSQL Exporter
    1. In the left menu, choose Workload > Deployment to access the Deployment management page.
    2. Click Create YAML in the upper right corner of the page to create a YAML file, and select the corresponding namespace for server deployment. The following part shows how to deploy the Exporter by using a YAML file. Sample configurations are as follows:
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    labels:
    k8s-app: mssql-exporter # Adjust to the corresponding name based on business requirements. It is recommended to include information about the MSSQL instance.
    name: mssql-exporter # Adjust to the corresponding name based on business requirements. It is recommended to include information about the MSSQL instance.
    namespace: mssql-demo # Adjust to the corresponding namespace based on business requirements.
    spec:
    replicas: 1
    selector:
    matchLabels:
    k8s-app: mssql-exporter # Adjust to the corresponding name based on business requirements. It is recommended to include information about the MSSQL instance.
    template:
    metadata:
    labels:
    k8s-app: mssql-exporter # Adjust to the corresponding name based on business requirements. It is recommended to include information about the MSSQL instance.
    spec:
    containers:
    - env:
    - name: SERVER
    value: "127.0.0.1" # Adjust to the corresponding MSSQL domain name based on business requirements.
    - name: PORT
    value: "1433" # Adjust to the corresponding MSSQL port based on business requirements.
    - name: USERNAME
    value: user # Adjust to the corresponding MSSQL username based on business requirements.
    - name: PASSWORD
    value: "123456" # Adjust to the corresponding MSSQL password based on business requirements.
    - name: EXPOSE
    value: "4000" # Metrics export port. Adjust to the corresponding port based on business requirements.
    image: ccr.ccs.tencentyun.com/rig-agent/common-image:mssql-exporter-v1.3.0
    imagePullPolicy: IfNotPresent
    name: mssql-exporter
    ports:
    - containerPort: 4000 # Open the port corresponding to the EXPOSE environment variable specified above.
    name: metric-port
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    dnsPolicy: ClusterFirst
    imagePullSecrets:
    - name: qcloudregistrykey
    restartPolicy: Always
    schedulerName: default-scheduler
    securityContext: {}
    terminationGracePeriodSeconds: 30
    
    Step 3: Verification
    1. Click the Deployment created in the previous step on the Deployment page to go to the Deployment management page.
    2. Click the Log tab. If no error messages are displayed, the setup is successful, as shown below:
    
    
    
    3. Click the Pod tab to enter the Pod page.
    4. Click Remote login under the operation bar on the right to log in to the Pod. In the command-line window, execute the following wget command for the address exposed by the Exporter to retrieve the corresponding MSSQL metrics. If no data is retrieved, check whether the connection string is correct. Details are as follows:
    wget -qO- http://localhost:4000/metrics
    The successful outcome is shown in the following figure:
    
    
    
    Step 4: Adding a Collection Task
    1. Log in to the TMP console and select the corresponding Prometheus instance to go to the management page.
    2. In Data Collection > Integrate with TKE, select the associated cluster, and select Data Collection Configuration > Customize Monitoring Configuration > Via YAML to add a collection task.
    3. Add a PodMonitor via service discovery to define the collection task. The YAML example is as follows:
    apiVersion: monitoring.coreos.com/v1
    kind: PodMonitor
    metadata:
    name: mssql-exporter # Enter a unique name.
    namespace: cm-prometheus # Pay-as-you-go instance: Use the namespace of the cluster. Monthly subscription instance (no longer available): The namespace is fixed. Do not change it.
    spec:
    podMetricsEndpoints:
    - interval: 30s
    port: metric-port # Enter the port of the Prometheus Exporter in the Pod YAML file.
    path: /metrics # Enter the path of the Prometheus Exporter. Default value: /metrics.
    relabelings:
    - action: replace
    sourceLabels:
    - instance
    regex: (.*)
    targetLabel: instance
    replacement: 'crs-xxxxxx' # Replace with the corresponding MSSQL instance ID.
    namespaceSelector: # Select the namespace where the MSSQL Exporter pod to be monitored is located.
    matchNames:
    - mssql-demo
    selector: # Enter the labels of the Pod to be monitored to locate the target Pod.
    matchLabels:
    k8s-app: mssql-exporter
    

    Viewing Monitoring Information

    Prerequisites

    The Prometheus instance has been bound to a Grafana instance.

    Operation Steps

    1. Log in to the TMP console and select the corresponding Prometheus instance to go to the management page.
    2. On the Basic Information page of the instance, locate the bound Grafana address. Open and log in, then navigate to the database folder to find the monitoring dashboard for the MSSQL instance. View the relevant monitoring data for the instance, as shown below:
    
    
    

    Configuring Alarm

    TMP supports configuring alarm rules based on the actual business situation. For details, see Creating Alarm Rules.

    Appendix: MSSQL Exporter Environment Variable Configuration

    Name
    Description
    SERVER
    Required. The service IP or domain name of MSSQL.
    PORT
    MSSQL service port. The default port is 1433.
    USERNAME
    Required. The service username of MSSQL.
    PASSWORD
    Required. The service password of MSSQL.
    ENCRYPT
    Enforced encryption setting. The default value is true.
    TRUST_SERVER_CERTIFICATE
    Indicates whether to trust the server’s certificate. The default value is true.
    DEBUG
    A comma-separated list of enabled logs. Currently supports app and metrics.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support