NetCrunch における Telegraf を使用した Azure Resource の監視
このドキュメントでは、Telegraf を構成してさまざまな Azure Resource(Virtual Machines、Storage Accounts、Databases など)からメトリックを収集し、Telemetry Node endpoint を介して NetCrunch に送信する方法について説明します。
概要
Telegraf は Azure Monitor input plugin を使用して Azure Resource のメトリックを収集できます。これにより、NetCrunch から Azure への直接的なネットワークアクセスを必要とせずに、Azure Resource を監視できます。
このドキュメントの構成例では、Azure Virtual Machines を参照対象として使用していますが、この plugin は Azure Monitor API を通じてメトリックを公開する任意の Azure resource type をサポートします。
NetCrunch による Azure VM Telemetry のサポート方法
NetCrunch は、Telemetry Node REST endpoint を介して Telegraf からデータを受信します。Telemetry Nodes は JSON 形式のデータを受け入れ、受信した値を counters または alert statuses として保存します。
endpoint、その URL 形式、および認証方法については、 Monitoring with Telegraf で説明しています。以下では、Telemetry Node がすでに存在していることを前提とします — テレメトリノード を参照してください。
データフロー
Telegraf を介した Azure VM の監視は、次のプロセスに従います。
- Azure Monitor API Query - Telegraf は service principal credentials を使用して Azure Monitor API に VM metrics を問い合わせます。
- Metric Collection - Azure Monitor は、指定された resource に対して要求された metrics を返します。
- Data Forwarding - Telegraf は、収集した metrics を HTTP POST 経由で NetCrunch Telemetry Node に転送します。
- NetCrunch Processing - Telemetry Node は受信した metrics をアンカーし、counters または alert statuses として保存します。
監視方法
Azure Monitor input plugin は、次の 3 つの収集方法をサポートします。
Resource Target
resource ID を使用して、特定の resources から metrics を収集します。この方法は、個々の resources の監視に適しています。
[[inputs.azure_monitor.resource_target]] resource_id = "resourceGroups/<group>/providers/Microsoft.Compute/virtualMachines/<vm-name>" metrics = ["Percentage CPU", "Available Memory Bytes"] aggregations = ["Average", "Maximum"]
Resource Group Target
resource group 内にある特定の type のすべての resources から metrics を収集します。
[[inputs.azure_monitor.resource_group_target]] resource_group = "production-rg"[[inputs.azure_monitor.resource_group_target.resource]] resource_type = "Microsoft.Compute/virtualMachines" metrics = ["Percentage CPU", "Available Memory Bytes"] aggregations = ["Average"]
Subscription Target
subscription 全体にわたって、特定の type のすべての resources から metrics を収集します。
[[inputs.azure_monitor.subscription_target]] resource_type = "Microsoft.Compute/virtualMachines" metrics = ["Percentage CPU"] aggregations = ["Average"]
サポートされる Azure Resources
Azure Monitor plugin は、Azure Monitor API を通じて metrics を公開する任意の Azure resource type から metrics を収集できます。一般的な resource types には、次のものがあります。
Compute Resources
- Virtual Machines:
Microsoft.Compute/virtualMachines - Virtual Machine Scale Sets:
Microsoft.Compute/virtualMachineScaleSets - App Services:
Microsoft.Web/sites - Azure Functions:
Microsoft.Web/sites - Container Instances:
Microsoft.ContainerInstance/containerGroups - Kubernetes Service:
Microsoft.ContainerService/managedClusters
Storage Resources
- Storage Accounts:
Microsoft.Storage/storageAccounts - Blob Storage:
Microsoft.Storage/storageAccounts/blobServices - File Storage:
Microsoft.Storage/storageAccounts/fileServices - Queue Storage:
Microsoft.Storage/storageAccounts/queueServices - Table Storage:
Microsoft.Storage/StorageAccounts/tableServices
Database Resources
- SQL Database:
Microsoft.Sql/servers/databases - SQL Managed Instance:
Microsoft.Sql/managedInstances - Cosmos DB:
Microsoft.DocumentDB/databaseAccounts - MySQL Database:
Microsoft.DBforMySQL/servers - PostgreSQL Database:
Microsoft.DBforPostgreSQL/servers - Redis Cache:
Microsoft.Cache/redis
Network Resources
- Load Balancer:
Microsoft.Network/loadBalancers - Application Gateway:
Microsoft.Network/applicationGateways - Virtual Network Gateway:
Microsoft.Network/virtualNetworkGateways - ExpressRoute Circuit:
Microsoft.Network/expressRouteCircuits - Public IP Address:
Microsoft.Network/publicIPAddresses - Network Interface:
Microsoft.Network/networkInterfaces
Integration Resources
- Service Bus:
Microsoft.ServiceBus/namespaces - Event Hub:
Microsoft.EventHub/namespaces - Event Grid:
Microsoft.EventGrid/topics - Logic Apps:
Microsoft.Logic/workflows
Analytics Resources
- Data Factory:
Microsoft.DataFactory/factories - Stream Analytics:
Microsoft.StreamAnalytics/streamingjobs - Synapse Analytics:
Microsoft.Synapse/workspaces
Monitoring Resources
- Application Insights:
Microsoft.Insights/components - Log Analytics Workspace:
Microsoft.OperationalInsights/workspaces
サポートされる resources と利用可能な metrics の完全な一覧については、Azure Monitor supported metrics documentation を参照してください。
Azure の構成
Service Principal の作成
Azure Monitor input plugin では、service principal による認証が必要です。
- Azure Active Directory に application を登録します
- client secret を作成します
- subscription または resource group レベルで、application に Monitoring Reader role を割り当てます
必要な情報: - Tenant ID - Client ID - Client Secret - Subscription ID
Telegraf の構成
主要な構成ファイルは /etc/telegraf/telegraf.conf です。
基本構成
[agent] interval = "10m" flush_interval = "10m" metric_buffer_limit = 10000 debug = false quiet = true[[inputs.azure_monitor]] tenant_id = "<your-tenant-id>" client_id = "<your-client-id>" client_secret = "<your-client-secret>" subscription_id = "<your-subscription-id>"
[[inputs.azure_monitor.resource_target]] resource_id = "resourceGroups/<resource-group>/providers/Microsoft.Compute/virtualMachines/<vm-name>"
metrics = [ "Percentage CPU", "Available Memory Bytes", "Network In Total", "Network Out Total", "Disk Read Bytes", "Disk Write Bytes", "Disk Read Operations/Sec", "Disk Write Operations/Sec", "OS Disk Queue Depth", "Data Disk Queue Depth" ] aggregations = ["Average", "Maximum", "Minimum"][[outputs.http]] url = "https://gw.netcrunch.io/tm/v1/SRV-001@sensor01@node100/update" method = "POST" data_format = "json" content_encoding = "identity" [outputs.http.headers] Content-Type = "application/json" timeout = "30s"
構成パラメーター
Agent Section:
interval- メトリックを収集する頻度flush_interval- outputs にデータを送信する頻度metric_buffer_limit- output ごとの未書き込み metrics の最大数debug- 詳細な logging を有効にしますquiet- error 以外のメッセージを抑制します
Azure Monitor Input:
tenant_id- Azure tenant identifierclient_id- service principal client identifierclient_secret- service principal secretsubscription_id- Azure subscription identifierresource_id- 完全な Azure resource identifiermetrics- 収集する metrics の一覧aggregations- データ集計方法(Average、Maximum、Minimum、Total、Count)
HTTP Output:
url- NetCrunch Telemetry Node endpointmethod- HTTP method(POST)data_format- output format(JSON)content_encoding- encoding typetimeout- request timeoutheaders- content type を含む HTTP headers
収集される Metrics
Azure Monitor input plugin は、次の VM metrics を収集します。
CPU Metrics
Percentage CPU- CPU 使用率
Memory Metrics
Available Memory Bytes- bytes 単位の利用可能な物理メモリ
Network Metrics
Network In Total- すべての network interfaces で受信した合計 bytesNetwork Out Total- すべての network interfaces で送信した合計 bytes
Disk I/O Metrics
Disk Read Bytes- 1 秒あたりに disk から読み取られた bytesDisk Write Bytes- 1 秒あたりに disk に書き込まれた bytesDisk Read Operations/Sec- Read IOPSDisk Write Operations/Sec- Write IOPS
Disk Queue Metrics
OS Disk Queue Depth- operating system disk queue depthData Disk Queue Depth- data disk queue depth
その他の Azure Resources の構成例
Azure Storage Account
[[inputs.azure_monitor]] tenant_id = "<your-tenant-id>" client_id = "<your-client-id>" client_secret = "<your-client-secret>" subscription_id = "<your-subscription-id>"[[inputs.azure_monitor.resource_target]] resource_id = "resourceGroups/<rg-name>/providers/Microsoft.Storage/storageAccounts/<storage-account>" metrics = [ "UsedCapacity", "Transactions", "Ingress", "Egress", "SuccessServerLatency", "SuccessE2ELatency", "Availability" ] aggregations = ["Average", "Total"]
[[outputs.http]] url = "https://gw.netcrunch.io/tm/v1/SRV-001@sensor02@node101/update" method = "POST" data_format = "json" content_encoding = "identity" [outputs.http.headers] Content-Type = "application/json"
Azure SQL Database
[[inputs.azure_monitor]] tenant_id = "<your-tenant-id>" client_id = "<your-client-id>" client_secret = "<your-client-secret>" subscription_id = "<your-subscription-id>"[[inputs.azure_monitor.resource_target]] resource_id = "resourceGroups/<rg-name>/providers/Microsoft.Sql/servers/<server>/databases/<database>" metrics = [ "cpu_percent", "physical_data_read_percent", "log_write_percent", "dtu_consumption_percent", "storage_percent", "connection_successful", "connection_failed", "blocked_by_firewall" ] aggregations = ["Average", "Maximum"]
[[outputs.http]] url = "https://gw.netcrunch.io/tm/v1/SRV-001@sensor03@node102/update" method = "POST" data_format = "json" content_encoding = "identity" [outputs.http.headers] Content-Type = "application/json"
Azure Kubernetes Service
[[inputs.azure_monitor]] tenant_id = "<your-tenant-id>" client_id = "<your-client-id>" client_secret = "<your-client-secret>" subscription_id = "<your-subscription-id>"[[inputs.azure_monitor.resource_target]] resource_id = "resourceGroups/<rg-name>/providers/Microsoft.ContainerService/managedClusters/<cluster-name>" metrics = [ "node_cpu_usage_percentage", "node_memory_working_set_percentage", "node_disk_usage_percentage", "node_network_in_bytes", "node_network_out_bytes" ] aggregations = ["Average"]
[[outputs.http]] url = "https://gw.netcrunch.io/tm/v1/SRV-001@sensor04@node103/update" method = "POST" data_format = "json" content_encoding = "identity" [outputs.http.headers] Content-Type = "application/json"
Resource Group 内のすべての VM の監視
[[inputs.azure_monitor]] tenant_id = "<your-tenant-id>" client_id = "<your-client-id>" client_secret = "<your-client-secret>" subscription_id = "<your-subscription-id>"[[inputs.azure_monitor.resource_group_target]] resource_group = "production-rg"
[[inputs.azure_monitor.resource_group_target.resource]] resource_type = "Microsoft.Compute/virtualMachines" metrics = ["Percentage CPU", "Available Memory Bytes", "Network In Total", "Network Out Total"] aggregations = ["Average", "Maximum"][[outputs.http]] url = "https://gw.netcrunch.io/tm/v1/SRV-001@sensor05@node104/update" method = "POST" data_format = "json" content_encoding = "identity" [outputs.http.headers] Content-Type = "application/json"
高度な構成
複数の Virtual Machines
複数の Azure VMs を監視します。
[[inputs.azure_monitor]] tenant_id = "<your-tenant-id>" client_id = "<your-client-id>" client_secret = "<your-client-secret>" subscription_id = "<your-subscription-id>"[[inputs.azure_monitor.resource_target]] resource_id = "resourceGroups/rg-prod/providers/Microsoft.Compute/virtualMachines/vm-web-01" metrics = ["Percentage CPU", "Available Memory Bytes"] aggregations = ["Average"]
[[inputs.azure_monitor.resource_target]] resource_id = "resourceGroups/rg-prod/providers/Microsoft.Compute/virtualMachines/vm-db-01" metrics = ["Percentage CPU", "Available Memory Bytes", "Disk Read Bytes", "Disk Write Bytes"] aggregations = ["Average", "Maximum"]
複数の Output Targets
複数の NetCrunch instances にデータを送信します。
[[outputs.http]] url = "https://gw.netcrunch.io/tm/v1/SRV-001@sensor01@node100/update" method = "POST" data_format = "json" content_encoding = "identity" [outputs.http.headers] Content-Type = "application/json" timeout = "30s"[[outputs.http]] url = "https://gw.netcrunch.io/tm/v1/SRV-002@sensor02@node200/update" method = "POST" data_format = "json" content_encoding = "identity" [outputs.http.headers] Content-Type = "application/json" timeout = "30s"
Resource Usage の最適化
大規模な deployment の場合:
[agent] interval = "15m" flush_interval = "15m" metric_buffer_limit = 5000 debug = false
間隔を長くすると、Azure API への呼び出しと network traffic を削減できます。
Local System Metrics
Telegraf は、agent を実行している host から local system metrics も同時に収集できます。
統合構成例
[agent] interval = "60s" flush_interval = "60s"
# Azure VM metrics[[inputs.azure_monitor]] tenant_id = "<your-tenant-id>" client_id = "<your-client-id>" client_secret = "<your-client-secret>" subscription_id = "<your-subscription-id>"[[inputs.azure_monitor.resource_target]] resource_id = "resourceGroups/rg-prod/providers/Microsoft.Compute/virtualMachines/vm-01" metrics = ["Percentage CPU", "Available Memory Bytes"] aggregations = ["Average"]
# Local system metrics[[inputs.cpu]] percpu = true totalcpu = true[[inputs.mem]]
[[inputs.disk]] ignore_fs = ["tmpfs", "devtmpfs", "devfs"]
[[inputs.diskio]]
[[inputs.net]]
# Send to NetCrunch[[outputs.http]] url = "https://gw.netcrunch.io/tm/v1/SRV-001@sensor01@node100/update" method = "POST" data_format = "json" content_encoding = "identity" [outputs.http.headers] Content-Type = "application/json"
この構成では、Azure VM metrics と Telegraf host の local system metrics の両方を収集します。
ユースケース
Cloud Infrastructure Monitoring
- オンプレミスの NetCrunch servers から Azure への直接的な network connectivity を必要とせずに、compute、storage、database、network services にわたる Azure resources を監視します。
Hybrid Cloud Environments
- hybrid network に配置された単一の Telegraf instance を使用して、Azure resources とオンプレミス systems の両方から metrics を収集します。
Multi-Subscription Monitoring
- 適切な permissions を持つ異なる service principals を使用して、複数の Azure subscriptions にわたる resources を監視するよう Telegraf agents を配置します。
Resource Group Monitoring
- resource group 内の特定の type のすべての resources を監視し、新しい resources が作成されると自動的に追加します。
Multi-Resource Type Monitoring
- 異なる Azure resource types(VMs、databases、storage、networking)の監視を単一の Telegraf 構成に統合し、一元的な可視性を実現します。
Cost-Effective Monitoring
- 収集間隔を制御し、必要な metrics のみを選択することで、Azure API costs を削減します。Azure Monitor API には、1 時間あたり 12,000 requests の read limit があります。
まとめ
Telegraf は Azure Monitor とネイティブに統合され、任意の Azure resource type から metrics を収集できます。この plugin は、resource target、resource group target、subscription target の 3 つの収集方法をサポートします。データは NetCrunch Telemetry Nodes に転送され、一元的な監視と alerting に使用されます。
この方法により、VPN connections や NetCrunch から Azure への直接的な network access を必要とせずに、包括的な cloud monitoring を実現できます。この plugin は、統合された構成を通じて、compute resources、storage accounts、databases、network services、その他の Azure resources を監視できます。
主な機能: - ネイティブな Azure Monitor API integration - metrics を公開するすべての Azure resource types のサポート - 3 つの収集方法: resource、resource group、subscription level - API rate limits を管理するための収集間隔の構成 - NetCrunch Telemetry Nodes による一元的な monitoring
- テレメトリノード
テレメトリノードは、RESTまたは OTLP経由で外部システムからメトリック、ステータス、イベントを受信するためのNetCrunchノードタイプです。クラウド、IoT、カスタムシステムのテレメトリデータをアンカーし、イベント対応設計に置き換えられたノードです。
- Monitoring with Telegraf
Use Telegraf, the open-source metrics agent, to collect from systems NetCrunch does not poll directly and push the results into NetCrunch as ordinary counters and statuses.
- NetCrunch における Telegraf 経由の Linux Sysctl Filesystem 監視
このトピックでは、Telegraf を使用して Linux カーネルのファイルシステムパラメーターを監視し、収集したメトリクスを NetCrunch Telemetry Nodes に送信する方法について説明します。Linux Sysctl Filesystem input plugin は proc sys fs ディレクトリから値を読み取り、HTTP output plugin を使用して NetCrunch に転送します。
- NetCrunch で Telegraf を介して MQTT Telemetry を使用する
このトピックでは、MQTT を介して公開されたシステムメトリックを収集し、Telegraf を使用して処理した後、JSON ベースのテレメトリデータとして NetCrunch Telemetry Node エンドポイントに転送する方法について説明します。
- NetCrunch における Telegraf 経由の SQL Server Monitoring
このトピックでは、Telegraf を構成して Microsoft SQL Server のメトリックを収集し、JSON ベースのテレメトリデータを使用して NetCrunch Telemetry Node エンドポイントに転送する方法について説明します。SQL Server のログイン設定、接続文字列、Telegraf の入力構成、およびサポートされるメトリックタイプについて説明します。