- 重要な情報
- はじめに
- 用語集
- ガイド
- エージェント
- インテグレーション
- OpenTelemetry
- 開発者
- API
- CoScreen
- アプリ内
- Service Management
- インフラストラクチャー
- アプリケーションパフォーマンス
- 継続的インテグレーション
- ログ管理
- セキュリティ
- UX モニタリング
- 管理
データベースモニタリングは、クエリメトリクス、クエリサンプル、実行計画、データベースの状態、フェイルオーバー、イベントを公開することで、Microsoft SQL Server データベースを詳細に可視化します。
データベースでデータベースモニタリングを有効にするには、以下の手順を実行します。
Datadog Agent が統計やクエリを収集するためには、データベースサーバーへの読み取り専用のアクセスが必要となります。
Cloud SQL インスタンスに datadog
ユーザーを作成します。
Agent の読み取り専用アクセスを維持するために、デフォルトの CustomerDbRootRole
から datadog
ユーザーを削除してください。その代わりに、Agent が必要とする明示的な権限のみを付与します。
GRANT VIEW SERVER STATE to datadog as CustomerDbRootRole;
GRANT VIEW ANY DEFINITION to datadog as CustomerDbRootRole;
ALTER SERVER ROLE CustomerDbRootRole DROP member datadog;
追加した各アプリケーションデータベースに datadog
ユーザーを作成します。
USE [database_name];
CREATE USER datadog FOR LOGIN datadog;
これは、Google Cloud SQL が CONNECT ANY DATABASE
の付与を許可していないため、必要です。Datadog Agent は、データベース固有のファイル I/O 統計情報を収集するために、各データベースに接続する必要があります。
Google Cloud はホストへの直接アクセスを許可しません。つまり、Datadog Agent は SQL Server ホストと通信可能な別のホストにインストールする必要があります。Agent のインストールと実行には、いくつかのオプションがあります。
SQL Server テレメトリーの収集を開始するには、まず Datadog Agent をインストールします。
SQL Server Agent のコンフィギュレーションファイル C:\ProgramData\Datadog\conf.d\sqlserver.d\conf.yaml
を作成します。使用可能なすべての構成オプションは、サンプルコンフィギュレーションファイルを参照してください。
init_config:
instances:
- dbm: true
host: '<HOSTNAME>,<SQL_PORT>'
username: datadog
password: '<PASSWORD>'
connector: adodbapi
provider: MSOLEDBSQL
tags: # オプション
- 'service:<CUSTOM_SERVICE>'
- 'env:<CUSTOM_ENV>'
# プロジェクトとインスタンスを追加した後、CPU、メモリなどの追加のクラウドデータをプルするために Datadog Google Cloud (GCP) インテグレーションを構成します。
gcp:
project_id: '<PROJECT_ID>'
instance_id: '<INSTANCE_ID>'
project_id
と instance_id
フィールドの設定に関する追加情報は、SQL Server インテグレーション仕様を参照してください。
Windows 認証を利用する場合は、connection_string: "Trusted_Connection=yes"
と設定し、username
と password
フィールドを省略します。
service
と env
タグを使用して、共通のタグ付けスキームでデータベースのテレメトリーを他のテレメトリーにリンクします。これらのタグが Datadog 全体でどのように使用されるかについては、統合サービスタグ付けを参照してください。
推奨する ADO プロバイダーは、Microsoft OLE DB Driver です。Agent が動作しているホストにドライバーがインストールされていることを確認してください。
connector: adodbapi
adoprovider: MSOLEDBSQL19 # バージョン 18 以下の MSOLEDBSQL に置き換えます
他の 2 つのプロバイダー、SQLOLEDB
と SQLNCLI
は、Microsoft によって非推奨とされており、もはや使用するべきではありません。
推奨する ODBC ドライバーは、Microsoft ODBC Driver です。Agent が動作しているホストにドライバーがインストールされていることを確認してください。
connector: odbc
driver: '{ODBC Driver 17 for SQL Server}'
すべての Agent の構成が完了したら、Datadog Agent を再起動します。
Agent の status サブコマンドを実行し、Checks セクションで sqlserver
を探します。Datadog のデータベースのページへ移動して開始します。
SQL Server テレメトリーの収集を開始するには、まず Datadog Agent をインストールします。
Linux では、Datadog Agent の他に、ODBC SQL Server ドライバー (例えば、Microsoft ODBC ドライバー) がインストールされていることが必須となります。ODBC SQL Server がインストールされたら、odbc.ini
と odbcinst.ini
ファイルを /opt/datadog-agent/embedded/etc
フォルダーにコピーします。
odbc
コネクターを使用し、odbcinst.ini
ファイルに示されているように、適切なドライバーを指定します。
SQL Server Agent のコンフィギュレーションファイル /etc/datadog-agent/conf.d/sqlserver.d/conf.yaml
を作成します。使用可能なすべての構成オプションは、サンプルコンフィギュレーションファイルを参照してください。
init_config:
instances:
- dbm: true
host: '<HOSTNAME>,<SQL_PORT>'
username: datadog
password: '<PASSWORD>'
connector: odbc
driver: '<Driver from the `odbcinst.ini` file>'
tags: # オプション
- 'service:<CUSTOM_SERVICE>'
- 'env:<CUSTOM_ENV>'
# プロジェクトとインスタンスを追加した後、CPU、メモリなどの追加のクラウドデータをプルするために Datadog Google Cloud (GCP) インテグレーションを構成します。
gcp:
project_id: '<PROJECT_ID>'
instance_id: '<INSTANCE_ID>'
project_id
と instance_id
フィールドの設定に関する追加情報は、SQL Server インテグレーション仕様を参照してください。
service
と env
タグを使用して、共通のタグ付けスキームでデータベースのテレメトリーを他のテレメトリーにリンクします。これらのタグが Datadog 全体でどのように使用されるかについては、統合サービスタグ付けを参照してください。
すべての Agent の構成が完了したら、Datadog Agent を再起動します。
Agent の status サブコマンドを実行し、Checks セクションで sqlserver
を探します。Datadog のデータベースのページへ移動して開始します。
Docker コンテナで動作するデータベースモニタリング Agent を設定するには、Agent コンテナの Docker ラベルとしてオートディスカバリーのインテグレーションテンプレートを設定します。
注: ラベルのオートディスカバリーを機能させるためには、Agent にDocker ソケットに対する読み取り権限が与えられている必要があります。
アカウントや環境に合わせて、値を置き換えます。利用可能なすべての構成オプションについては、サンプルコンフィギュレーションファイルを参照してください。
export DD_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
export DD_AGENT_VERSION=7.35.0
docker run -e "DD_API_KEY=${DD_API_KEY}" \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-l com.datadoghq.ad.check_names='["sqlserver"]' \
-l com.datadoghq.ad.init_configs='[{}]' \
-l com.datadoghq.ad.instances='[{
"dbm": true,
"host": "<HOSTNAME>",
"port": <SQL_PORT>,
"connector": "odbc",
"driver": "FreeTDS",
"username": "datadog",
"password": "<PASSWORD>",
"tags": [
"service:<CUSTOM_SERVICE>"
"env:<CUSTOM_ENV>"
],
"gcp": {
"project_id": "<PROJECT_ID>",
"instance_id": "<INSTANCE_ID>"
}
}]' \
gcr.io/datadoghq/agent:${DD_AGENT_VERSION}
project_id
と instance_id
フィールドの設定に関する追加情報は、SQL Server インテグレーション仕様を参照してください。
service
と env
タグを使用して、共通のタグ付けスキームでデータベースのテレメトリーを他のテレメトリーにリンクします。これらのタグが Datadog 全体でどのように使用されるかについては、統合サービスタグ付けを参照してください。
Agent の status サブコマンドを実行し、Checks セクションで sqlserver
を探します。または、Datadog のデータベースのページへ移動して開始します。
Kubernetes クラスターをお使いの場合は、データベースモニタリング用の Datadog Cluster Agent をご利用ください。
Kubernetes クラスターでクラスターチェックがまだ有効になっていない場合は、指示に従ってクラスターチェックを有効化します。Cluster Agent の構成は、Cluster Agent コンテナにマウントされた静的ファイル、または Kubernetes サービスアノテーションのいずれかを使用することができます。
以下の Helm コマンドを実行して、Kubernetes クラスターに Datadog Cluster Agent をインストールします。お使いのアカウントや環境に合わせて値を変更してください。
helm repo add datadog https://helm.datadoghq.com
helm repo update
helm install <RELEASE_NAME> \
--set 'datadog.apiKey=<DATADOG_API_KEY>' \
--set 'clusterAgent.enabled=true' \
--set 'clusterAgent.confd.sqlserver\.yaml=cluster_check: true
init_config:
instances:
- dbm: true
host: <HOSTNAME>
port: 1433
username: datadog
password: "<PASSWORD>"
connector: "odbc"
driver: "FreeTDS"
tags: # オプション
- "service:<CUSTOM_SERVICE>"
- "env:<CUSTOM_ENV>"
gcp:
project_id: "<PROJECT_ID>"
instance_id: "<INSTANCE_ID>"' \
datadog/datadog
マウントされたコンフィギュレーションファイルを使ってクラスターチェックを構成するには、コンフィギュレーションファイルを Cluster Agent コンテナのパス /conf.d/sqlserver.yaml
にマウントします。
cluster_check: true # このフラグを必ず入れてください
init_config:
instances:
- dbm: true
host: '<HOSTNAME>'
port: <SQL_PORT>
username: datadog
password: '<PASSWORD>'
connector: "odbc"
driver: "FreeTDS"
tags: # オプション
- 'service:<CUSTOM_SERVICE>'
- 'env:<CUSTOM_ENV>'
# プロジェクトとインスタンスを追加した後、CPU、メモリなどの追加のクラウドデータをプルするために Datadog Google Cloud (GCP) インテグレーションを構成します。
gcp:
project_id: '<PROJECT_ID>'
instance_id: '<INSTANCE_ID>'
ファイルをマウントせずに、インスタンスのコンフィギュレーションを Kubernetes サービスとして宣言することができます。Kubernetes 上で動作する Agent にこのチェックを設定するには、Datadog Cluster Agent と同じネームスペースにサービスを作成します。
apiVersion: v1
kind: Service
metadata:
name: sqlserver-datadog-check-instances
annotations:
ad.datadoghq.com/service.check_names: '["sqlserver"]'
ad.datadoghq.com/service.init_configs: '[{}]'
ad.datadoghq.com/service.instances: |
[
{
"dbm": true,
"host": "<HOSTNAME>",
"port": <SQL_PORT>,
"username": "datadog",
"password": "<PASSWORD>",
"connector": "odbc",
"driver": "FreeTDS",
"tags": ["service:<CUSTOM_SERVICE>", "env:<CUSTOM_ENV>"], # オプション
"gcp": {
"project_id": "<PROJECT_ID>",
"instance_id": "<INSTANCE_ID>"
}
}
]
spec:
ports:
- port: 1433
protocol: TCP
targetPort: 1433
name: sqlserver
project_id
と instance_id
フィールドの設定に関する追加情報は、SQL Server インテグレーション仕様を参照してください。
Cluster Agent は自動的にこのコンフィギュレーションを登録し、SQL Server チェックを開始します。
datadog
ユーザーのパスワードをプレーンテキストで公開しないよう、Agent のシークレット管理パッケージを使用し、ENC[]
構文を使ってパスワードを宣言します。
Configure the odbc.ini
file based on your DSN settings.
Example:
[DATADOG]
Driver=/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.1.so.1.1
Server=127.0.0.1
Port=1433
User=datadog
Password=Password
Copy the odbc.ini
and odbcinst.ini
files into the /opt/datadog-agent/embedded/etc
folder.
Configure the SQL Server integration config to include the DSN.
Example:
instances:
- dbm: true
host: 'localhost,1433'
username: datadog
password: '<PASSWORD>'
connector: 'odbc'
driver: '{ODBC Driver 18 for SQL Server}'
dsn: 'DATADOG'
Restart the Agent.
When monitoring Always On clusters, the Agent must be installed on a separate server from the SQL Servers and connect to the cluster through the listener endpoint.
instances:
- dbm: true
host: 'shopist-prod,1433'
username: datadog
password: '<PASSWORD>'
connector: adodbapi
adoprovider: MSOLEDBSQL
include_ao_metrics: true # If Availability Groups is enabled
include_fci_metrics: true # If Failover Clustering is enabled
It is common to configure a single Agent host to connect to multiple remote database instances (see Agent installation architectures for DBM). To connect to multiple hosts, create an entry for each host in the SQL Server integration config. In these cases, Datadog recommends limiting the number of instances per Agent to a maximum of 10 database instances to guarantee reliable performance.
init_config:
instances:
- dbm: true
host: 'products-primary.123456789012.us-east-1.rds.amazonaws.com,1433'
username: datadog
connector: adodbapi
adoprovider: MSOLEDBSQL
password: '<PASSWORD>'
tags:
- 'env:prod'
- 'team:team-discovery'
- 'service:product-recommendation'
- dbm: true
host: 'products–replica-1.us-east-1.rds.amazonaws.com,1433'
connector: adodbapi
adoprovider: MSOLEDBSQL
username: datadog
password: '<PASSWORD>'
tags:
- 'env:prod'
- 'team:team-discovery'
- 'service:product-recommendation'
- dbm: true
host: 'products–replica-2.us-east-1.rds.amazonaws.com,1433'
connector: adodbapi
adoprovider: MSOLEDBSQL
username: datadog
password: '<PASSWORD>'
tags:
- 'env:prod'
- 'team:team-discovery'
- 'service:product-recommendation'
[...]
While it is possible to declare passwords directly in the Agent configuration files, it is a more secure practice to encrypt and store database credentials elsewhere using secret management software such as Vault. The Agent is able to read these credentials using the ENC[]
syntax. Review the secrets management documentation for the required setup to store these credentials. The following example shows how to declare and use those credentials:
init_config:
instances:
- dbm: true
host: 'localhost,1433'
connector: adodbapi
adoprovider: MSOLEDBSQL
username: datadog
password: 'ENC[datadog_user_database_password]'
To collect custom metrics, use the custom_queries
option. See the sample sqlserver.d/conf.yaml for more details.
init_config:
instances:
- dbm: true
host: 'localhost,1433'
connector: adodbapi
adoprovider: MSOLEDBSQL
username: datadog
password: '<PASSWORD>'
custom_queries:
- query: SELECT age, salary, hours_worked, name FROM hr.employees;
columns:
- name: custom.employee_age
type: gauge
- name: custom.employee_salary
type: gauge
- name: custom.employee_hours
type: count
- name: name
type: tag
tags:
- 'table:employees'
If the Agent must connect to a database host through a remote proxy, all telemetry is tagged with the hostname of the proxy rather than the database instance. Use the reported_hostname
option to set a custom override of the hostname detected by the Agent.
init_config:
instances:
- dbm: true
host: 'localhost,1433'
connector: adodbapi
adoprovider: MSOLEDBSQL
username: datadog
password: '<PASSWORD>'
reported_hostname: products-primary
- dbm: true
host: 'localhost,1433'
connector: adodbapi
adoprovider: MSOLEDBSQL
username: datadog
password: '<PASSWORD>'
reported_hostname: products-replica-1
SQL Server Browser Service, Named Instances, and other services can automatically detect port numbers. You can use this instead of hardcoding port numbers in connection strings. To use the Agent with one of these services, set the port
field to 0
.
For example, a Named Instance config:
init_config:
instances:
- host: <hostname\instance name>
port: 0
Google Cloud SQL からより包括的なデータベースメトリクスを収集するには、Google Cloud SQL インテグレーションをインストールします。
お役に立つドキュメント、リンクや記事: