クリーンなシステムの計装
ヒント
Agent Controlはスーパーバイザーサービスであり、それ自体でテレメトリーを収集または送信することはありません。New Relicでデータを確認するには、Agent Controlをインストールした後、Fleet Controlを通じてエージェント(infrastructureエージェントやNRDOTなど)をデプロイする必要があります。
Kubernetes
Fleet ControlでKubernetesクラスタタイプのフリートを作成します。詳細な手順については、「最初のフリートの作成」を参照してください。
Agent Controlをインストールしてください。Kubernetesインストレーションガイドに従い、ステップ1で作成したフリートを選択してください。
各エージェントに対して、Fleet Controlで設定を作成します。Agent ControlがFleet Controlに接続したら、各エージェントの設定を作成します。Fleet Controlはすべてのエージェント設定の信頼できる情報源です。ローカルの
values.yamlにエージェント固有の値を追加しないでください。
カスタム設定でinfrastructureエージェント、Fluent Bit、Prometheus、およびNRDOTを追加する例。これらの各設定は、Fleet Controlで個別のリモート設定として作成する必要があります:
カスタムのtolerationと30秒の収集間隔でNew Relic infrastructureエージェントを有効にします。
chart_values: newrelic-infrastructure: kubelet: tolerations: - operator: "Exists" effect: "NoSchedule" - operator: "Exists" effect: "NoExecute" common: config: interval: 30s制限されたCPUリソースでFluent Bitログフォワーダーをデプロイします。
chart_values: newrelic-logging: resources: limits: cpu: 200m requests: cpu: 200mテレメトリーのボリュームを減らすために、低データモードでPrometheusエージェントをデプロイします。
chart_values: newrelic-prometheus-agent: lowDataMode: true config: kubernetes: integrations_filter: enabled: falseOpenTelemetryコレクターのNew Relicディストリビューションをデプロイします。ここではfilelogレシーバーは無効になっています — ログ収集が必要な場合は有効にしてください。
chart_values: nr-k8s-otel-collector: receivers: filelog: enabled: false作成したばかりのリモート設定をフリートに追加して、新しいデプロイメントを作成します。Agent Controlは、新しい設定をクラスタに自動的に適用します。「最初のデプロイメントの作成と実行」の手順に従ってください。
データが流れていることを確認します。New RelicのUIで、Infrastructure > Kubernetesに移動します。リモート設定が適用されてから1~2分以内にクラスタが表示されます。表示されない場合は、Agent Controlのトラブルシューティングを参照してください。
Linux
Fleet ControlでLinux Hostタイプのフリートを作成します。詳細な手順については、最初のフリートの作成を参照してください。
Agent Controlをインストールしてください。Linuxインストレーションガイドに従い、ステップ1で作成したフリートを選択します。
Fleet Controlで各エージェントの設定を作成します。Agent ControlがFleet Controlに接続した後、各エージェントの設定を作成します。
infrastructureエージェント、nri-mysql、nri-flex、fluentbit、およびnrdotを追加する例。これらの各設定は、Fleet Controlで個別のリモート設定として作成する必要があります:
config_agent 最小限の必須設定が含まれています。license_keyは、nr-env値プロバイダーを使用してNEW_RELIC_LICENSE_KEY環境変数から実行時に解決されます;custom_attributesはオプションですが、フィルタリングのために推奨されます。config_loggingは、システムsyslogをNew Relic Logsに転送します。
config_agent: license_key: '${nr-env:NEW_RELIC_LICENSE_KEY}' custom_attributes: env: productionconfig_logging: logging.yml: logs: - name: syslog file: /var/log/syslog attributes: logtype: linux_sysloglocalhostで実行されているMySQLインスタンスをモニターします。パスワードは、nr-env値プロバイダーを使用してMYSQL_PASSWORD環境変数から実行時に解決されます — 認証情報をハードコードしないでください。
config: integrations: - name: nri-mysql env: HOSTNAME: localhost PORT: 3306 USERNAME: newrelic PASSWORD: ${nr-env:MYSQL_PASSWORD} REMOTE_MONITORING: true interval: 30sdfを使用して、ルートファイルシステムからディスク使用量の統計を収集します。この例では、任意のシェルコマンドを実行し、その出力をNew Relicイベントとして解析する方法を示します。
config: integrations: - name: nri-flex config: name: diskUsage apis: - event_type: DiskUsageSample commands: - run: df -kP / split: horizontal split_by: \s+ set_header: [filesystem, blocks, used, available, usePercent, mountpoint] row_start: 1ホストのメトリクスとシステムログを収集し、APMサービス用のOTLPレシーバーを開きます。ライセンスキーとOTLPエンドポイントは、Agent Controlによって自動的に挿入されます。
config: # Variables set automatically by Agent Control: # - NEW_RELIC_LICENSE_KEY: New Relic ingest license key. # - OTEL_EXPORTER_OTLP_ENDPOINT: OTLP endpoint (see: https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp/).
extensions: health_check:
receivers: otlp: protocols: grpc: http:
hostmetrics: collection_interval: 60s scrapers: cpu: metrics: system.cpu.time: enabled: false system.cpu.utilization: enabled: true load: memory: metrics: system.memory.utilization: enabled: true paging: metrics: system.paging.utilization: enabled: false system.paging.faults: enabled: false filesystem: metrics: system.filesystem.utilization: enabled: true disk: metrics: system.disk.merged: enabled: false system.disk.pending_operations: enabled: false system.disk.weighted_io_time: enabled: false network: metrics: system.network.connections: enabled: false # Uncomment to enable process metrics, which can be noisy but valuable. # processes: # process: # metrics: # process.cpu.utilization: # enabled: true # process.cpu.time: # enabled: false
filelog: include: - /var/log/alternatives.log - /var/log/cloud-init.log - /var/log/auth.log - /var/log/dpkg.log - /var/log/syslog - /var/log/messages - /var/log/secure - /var/log/yum.log
processors: metricstransform: transforms: - include: system.cpu.utilization action: update operations: - action: aggregate_labels label_set: [state] aggregation_type: mean - include: system.paging.operations action: update operations: - action: aggregate_labels label_set: [direction] aggregation_type: sum filter/exclude_cpu_utilization: metrics: datapoint: - 'metric.name == "system.cpu.utilization" and attributes["state"] == "interrupt"' - 'metric.name == "system.cpu.utilization" and attributes["state"] == "nice"' - 'metric.name == "system.cpu.utilization" and attributes["state"] == "softirq"' filter/exclude_memory_utilization: metrics: datapoint: - 'metric.name == "system.memory.utilization" and attributes["state"] == "slab_unreclaimable"' - 'metric.name == "system.memory.utilization" and attributes["state"] == "inactive"' - 'metric.name == "system.memory.utilization" and attributes["state"] == "cached"' - 'metric.name == "system.memory.utilization" and attributes["state"] == "buffered"' - 'metric.name == "system.memory.utilization" and attributes["state"] == "slab_reclaimable"' filter/exclude_memory_usage: metrics: datapoint: - 'metric.name == "system.memory.usage" and attributes["state"] == "slab_unreclaimable"' - 'metric.name == "system.memory.usage" and attributes["state"] == "inactive"' filter/exclude_filesystem_utilization: metrics: datapoint: - 'metric.name == "system.filesystem.utilization" and attributes["type"] == "squashfs"' filter/exclude_filesystem_usage: metrics: datapoint: - 'metric.name == "system.filesystem.usage" and attributes["type"] == "squashfs"' - 'metric.name == "system.filesystem.usage" and attributes["state"] == "reserved"' filter/exclude_filesystem_inodes_usage: metrics: datapoint: - 'metric.name == "system.filesystem.inodes.usage" and attributes["type"] == "squashfs"' - 'metric.name == "system.filesystem.inodes.usage" and attributes["state"] == "reserved"' filter/exclude_system_disk: metrics: datapoint: - 'metric.name == "system.disk.operations" and IsMatch(attributes["device"], "^loop.*") == true' - 'metric.name == "system.disk.merged" and IsMatch(attributes["device"], "^loop.*") == true' - 'metric.name == "system.disk.io" and IsMatch(attributes["device"], "^loop.*") == true' - 'metric.name == "system.disk.io_time" and IsMatch(attributes["device"], "^loop.*") == true' - 'metric.name == "system.disk.operation_time" and IsMatch(attributes["device"], "^loop.*") == true' filter/exclude_system_paging: metrics: datapoint: - 'metric.name == "system.paging.usage" and attributes["state"] == "cached"' - 'metric.name == "system.paging.operations" and attributes["type"] == "cached"' filter/exclude_network: metrics: datapoint: - 'IsMatch(metric.name, "^system.network.*") == true and attributes["device"] == "lo"' attributes/exclude_system_paging: include: match_type: strict metric_names: - system.paging.operations actions: - key: type action: delete cumulativetodelta: transform/host: metric_statements: - context: metric statements: - set(description, "") - set(unit, "") transform: trace_statements: - context: span statements: - truncate_all(attributes, 4095) - truncate_all(resource.attributes, 4095) log_statements: - context: log statements: - truncate_all(attributes, 4095) - truncate_all(resource.attributes, 4095) memory_limiter: check_interval: 1s limit_mib: 100 batch: resourcedetection: detectors: ["system"] system: hostname_sources: ["os"] resource_attributes: host.id: enabled: true resourcedetection/cloud: detectors: ["gcp", "ec2", "azure"] timeout: 2s ec2: resource_attributes: host.name: enabled: false resourcedetection/env: detectors: ["env"] timeout: 2s override: true
exporters: otlphttp: endpoint: ${nr-env:OTEL_EXPORTER_OTLP_ENDPOINT} headers: api-key: ${nr-env:NEW_RELIC_LICENSE_KEY}
service: pipelines: metrics/host: receivers: [hostmetrics] processors: - memory_limiter - metricstransform - filter/exclude_cpu_utilization - filter/exclude_memory_utilization - filter/exclude_memory_usage - filter/exclude_filesystem_utilization - filter/exclude_filesystem_usage - filter/exclude_filesystem_inodes_usage - filter/exclude_system_disk - filter/exclude_network - attributes/exclude_system_paging - transform/host - resourcedetection - resourcedetection/cloud - resourcedetection/env - cumulativetodelta - batch exporters: [otlphttp] logs/host: receivers: [filelog] processors: [memory_limiter, transform, resourcedetection, resourcedetection/cloud, resourcedetection/env, batch] exporters: [otlphttp] traces: receivers: [otlp] processors: [memory_limiter, transform, resourcedetection, resourcedetection/cloud, resourcedetection/env, batch] exporters: [otlphttp] metrics: receivers: [otlp] processors: [memory_limiter, transform, resourcedetection, resourcedetection/cloud, resourcedetection/env, batch] exporters: [otlphttp] logs: receivers: [otlp] processors: [memory_limiter, transform, resourcedetection, resourcedetection/cloud, resourcedetection/env, batch] exporters: [otlphttp] extensions: [health_check]作成したばかりのリモート設定をフリートに追加して、新しいデプロイメントを作成します。Agent Controlは、新しい設定をホストに自動的に適用し、各エージェントのOCIパッケージをダウンロードしてインストールします。「最初のデプロイメントの作成と実行」の手順に従ってください。
データが流れていることを確認します。New RelicのUIで、Infrastructure > Hostsに移動します。1~2分以内にホストが表示されます。表示されない場合は、Agent Controlのトラブルシューティングを参照してください。
ウィンドウズ
Fleet ControlでWindows Hostタイプのフリートを作成します。詳細な手順については、「最初のフリートの作成」を参照してください。
Agent Controlをインストールしてください。Windowsのインストレーションガイドに従って、ステップ1で作成したフリートを選択します。
Fleet Controlで各エージェントの設定を作成します。Agent ControlがFleet Controlに接続した後、各エージェントの設定を作成します。
infrastructureエージェント、nri-mysql、nri-flex、fluentbit、およびnrdotを追加する例。これらの各設定は、Fleet Controlで個別のリモート設定として作成する必要があります:
config_agent 最小限の必須設定が含まれています。license_keyは、nr-env値プロバイダーを使用してNEW_RELIC_LICENSE_KEY環境変数から実行時に解決されます;custom_attributesはオプションですが、フィルタリングのために推奨されます。config_loggingは、WindowsのイベントログをNew Relic Logsに転送します。
config_agent: license_key: '${nr-env:NEW_RELIC_LICENSE_KEY}' custom_attributes: env: productionconfig_logging: windows-event-log.yml: logs: - name: windows-event-log winevtlog: channel: System attributes: logtype: windows_event_loglocalhostで実行されているMySQLインスタンスをモニターします。パスワードは、nr-env値プロバイダーを使用して、実行時にMYSQL_PASSWORD環境変数から解決されます。
config: integrations: - name: nri-mysql env: HOSTNAME: localhost PORT: 3306 USERNAME: newrelic PASSWORD: ${nr-env:MYSQL_PASSWORD} REMOTE_MONITORING: true interval: 30sPowerShell経由でGet-CimInstanceを使用して、論理ディスクのパフォーマンスメトリクスを収集します。この例では、nri-flexが任意のPowerShellコマンドを実行し、そのJSON出力をNew Relicイベントとして解析する方法を示します。PowerShell v3以降が必要です。
config: integrations: - name: nri-flex config: name: winDiskPerf apis: - event_type: WinDiskPerfSample shell: powershell commands: - run: > Get-CimInstance -ClassName Win32_PerfFormattedData_PerfDisk_LogicalDisk | Select-Object -Property Name, PercentFreeSpace, FreeMegabytes | ConvertTo-Jsonホストメトリクスを収集し、APMサービス用のOTLPレシーバーを開きます。ライセンスキーとOTLPエンドポイントは、Agent Controlによって自動的に挿入されます。
config: # Variables set automatically by Agent Control: # - NEW_RELIC_LICENSE_KEY: New Relic ingest license key. # - OTEL_EXPORTER_OTLP_ENDPOINT: OTLP endpoint (see: https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp/).
extensions: health_check:
receivers: otlp: protocols: grpc: http:
hostmetrics: collection_interval: 60s scrapers: cpu: metrics: system.cpu.time: enabled: false system.cpu.utilization: enabled: true load: memory: metrics: system.memory.utilization: enabled: true paging: metrics: system.paging.utilization: enabled: false system.paging.faults: enabled: false filesystem: metrics: system.filesystem.utilization: enabled: true disk: metrics: system.disk.merged: enabled: false system.disk.pending_operations: enabled: false system.disk.weighted_io_time: enabled: false network: metrics: system.network.connections: enabled: false
processors: metricstransform: transforms: - include: system.cpu.utilization action: update operations: - action: aggregate_labels label_set: [state] aggregation_type: mean - include: system.paging.operations action: update operations: - action: aggregate_labels label_set: [direction] aggregation_type: sum filter/exclude_cpu_utilization: metrics: datapoint: - 'metric.name == "system.cpu.utilization" and attributes["state"] == "interrupt"' - 'metric.name == "system.cpu.utilization" and attributes["state"] == "nice"' - 'metric.name == "system.cpu.utilization" and attributes["state"] == "softirq"' filter/exclude_memory_utilization: metrics: datapoint: - 'metric.name == "system.memory.utilization" and attributes["state"] == "slab_unreclaimable"' - 'metric.name == "system.memory.utilization" and attributes["state"] == "inactive"' - 'metric.name == "system.memory.utilization" and attributes["state"] == "cached"' - 'metric.name == "system.memory.utilization" and attributes["state"] == "buffered"' - 'metric.name == "system.memory.utilization" and attributes["state"] == "slab_reclaimable"' filter/exclude_memory_usage: metrics: datapoint: - 'metric.name == "system.memory.usage" and attributes["state"] == "slab_unreclaimable"' - 'metric.name == "system.memory.usage" and attributes["state"] == "inactive"' filter/exclude_filesystem_utilization: metrics: datapoint: - 'metric.name == "system.filesystem.utilization" and attributes["type"] == "squashfs"' filter/exclude_filesystem_usage: metrics: datapoint: - 'metric.name == "system.filesystem.usage" and attributes["type"] == "squashfs"' - 'metric.name == "system.filesystem.usage" and attributes["state"] == "reserved"' filter/exclude_filesystem_inodes_usage: metrics: datapoint: - 'metric.name == "system.filesystem.inodes.usage" and attributes["type"] == "squashfs"' - 'metric.name == "system.filesystem.inodes.usage" and attributes["state"] == "reserved"' filter/exclude_system_disk: metrics: datapoint: - 'metric.name == "system.disk.operations" and IsMatch(attributes["device"], "^loop.*") == true' - 'metric.name == "system.disk.merged" and IsMatch(attributes["device"], "^loop.*") == true' - 'metric.name == "system.disk.io" and IsMatch(attributes["device"], "^loop.*") == true' - 'metric.name == "system.disk.io_time" and IsMatch(attributes["device"], "^loop.*") == true' - 'metric.name == "system.disk.operation_time" and IsMatch(attributes["device"], "^loop.*") == true' filter/exclude_system_paging: metrics: datapoint: - 'metric.name == "system.paging.usage" and attributes["state"] == "cached"' - 'metric.name == "system.paging.operations" and attributes["type"] == "cached"' filter/exclude_network: metrics: datapoint: - 'IsMatch(metric.name, "^system.network.*") == true and attributes["device"] == "lo"' attributes/exclude_system_paging: include: match_type: strict metric_names: - system.paging.operations actions: - key: type action: delete cumulativetodelta: transform/host: metric_statements: - context: metric statements: - set(description, "") - set(unit, "") transform: trace_statements: - context: span statements: - truncate_all(attributes, 4095) - truncate_all(resource.attributes, 4095) log_statements: - context: log statements: - truncate_all(attributes, 4095) - truncate_all(resource.attributes, 4095) memory_limiter: check_interval: 1s limit_mib: 100 batch: resourcedetection: detectors: ["system"] system: hostname_sources: ["os"] resource_attributes: host.id: enabled: true resourcedetection/cloud: detectors: ["gcp", "ec2", "azure"] timeout: 2s ec2: resource_attributes: host.name: enabled: false resourcedetection/env: detectors: ["env"] timeout: 2s override: true
exporters: otlphttp: endpoint: ${nr-env:OTEL_EXPORTER_OTLP_ENDPOINT} headers: api-key: ${nr-env:NEW_RELIC_LICENSE_KEY}
service: pipelines: metrics/host: receivers: [hostmetrics] processors: - memory_limiter - metricstransform - filter/exclude_cpu_utilization - filter/exclude_memory_utilization - filter/exclude_memory_usage - filter/exclude_filesystem_utilization - filter/exclude_filesystem_usage - filter/exclude_filesystem_inodes_usage - filter/exclude_system_disk - filter/exclude_network - attributes/exclude_system_paging - transform/host - resourcedetection - resourcedetection/cloud - resourcedetection/env - cumulativetodelta - batch exporters: [otlphttp] traces: receivers: [otlp] processors: [memory_limiter, transform, resourcedetection, resourcedetection/cloud, resourcedetection/env, batch] exporters: [otlphttp] metrics: receivers: [otlp] processors: [memory_limiter, transform, resourcedetection, resourcedetection/cloud, resourcedetection/env, batch] exporters: [otlphttp] logs: receivers: [otlp] processors: [memory_limiter, transform, resourcedetection, resourcedetection/cloud, resourcedetection/env, batch] exporters: [otlphttp] extensions: [health_check]作成したばかりのリモート設定をフリートに追加して、新しいデプロイメントを作成します。Agent Controlは、新しい設定をホストに自動的に適用し、各エージェントのOCIパッケージをダウンロードしてインストールします。「最初のデプロイメントの作成と実行」の手順に従ってください。
データが流れていることを確認します。New RelicのUIで、Infrastructure > Hostsに移動します。1~2分以内にホストが表示されます。表示されない場合は、Agent Controlのトラブルシューティングを参照してください。
すでにエージェントをインストールしている場合は、代わりにAgent Controlへの移行を参照してください。