NRDOT コレクター (推奨) またはOpenTelemetryコレクター contrib を使用してKubernetesで実行されている NGINX サーバーを監視し、メトリクスとテレメトリーデータをNew Relicに送信します。
このKubernetes固有の統合は、クラスタ内の NGINX ポッドを自動的に検出し、インスタンスごとに手動で設定することなくメトリクスを収集します。 OpenTelemetry nginxreceiverとReceivercreatorを利用して、コンテナ化された環境全体で NGINX パフォーマンス メトリクス、接続統計、サーバーの健全性を動的に監視します。
NGINXの監視を設定する
お好みのコレクターを選択し、以下の手順に従ってください。
あなたが始める前に
以下のものを用意してください:
有効なNew Relicライセンスキー
監視する必要がある NGINX ポッド上のHTTP スタブ ステータスモジュールを有効にします
監視する必要がある各 NGINX ポッドにラベル
appとroleを追加します。基本的なKubernetes OpenTelemetryマニフェストのインストールを完了する
NRDOT コレクターを構成する
Kubernetesマニフェストを使用して NRDOT コレクターをインストールします。 Helmのチャートサポートは近日中に提供開始予定です。
基本的なKubernetes OpenTelemetryマニフェストのインストールが完了したら、次の手順に従って NGINX 監視を構成します。
NRDOT コレクターを使用するようにコレクター イメージを更新します。
ローカルの
renderedディレクトリにあるdeployment.yamlファイルとdaemonset.yamlファイルの両方で、イメージを次のように更新します。image: newrelic/nrdot-collector:latestNGINX 監視の
deployment-configmap.yamlを更新します。監視要件に基づいて、次の設定オプションのいずれかを選択します。
重要
このオプションは NGINX のみを監視し、他のKubernetesメトリクス コレクションを削除します。 不要なメトリクスの取り込みを防ぐために、後で追加のコレクターを削除します。
deployment-config.yaml: |の下の内容を、以下の NGINX 固有の設定に置き換えてください。extensions:health_check:endpoint: 0.0.0.0:13133k8s_observer:auth_type: serviceAccountobserve_pods: trueobserve_nodes: truereceivers:receiver_creator/nginx:watch_observers: [k8s_observer]receivers:nginx:rule: type == "pod" && labels["app"] == "nginx" && labels["role"] == "reverse-proxy" # Update with your labelsconfig:endpoint: 'http://`endpoint`:<YOUR_STUB_STATUS_PORT>/<YOUR_STUB_STATUS_PATH>' # Update port and path as neededmetrics:nginx.requests:enabled: truenginx.connections_accepted:enabled: truenginx.connections_handled:enabled: truenginx.connections_current:enabled: truecollection_interval: 30sresource_attributes:nginx.server.endpoint: 'http://`endpoint`:<YOUR_STUB_STATUS_PORT>/<YOUR_STUB_STATUS_PATH>' # Update port and path as needednginx.port: '<YOUR_STUB_STATUS_PORT>' # Update to match your configurationprocessors:batch:send_batch_max_size: 1000timeout: 30ssend_batch_size: 800memory_limiter:check_interval: 1slimit_percentage: 80spike_limit_percentage: 25resource/cluster:attributes:- key: k8s.cluster.namevalue: "<CLUSTER_NAME>" # Replace with your cluster nameaction: inserttransform/nginx:metric_statements:- context: resourcestatements:- set(attributes["nginx.display.name"], Concat(["server","k8s",attributes["k8s.cluster.name"],attributes["k8s.namespace.name"],"pod",attributes["k8s.pod.name"],"nginx",attributes["nginx.port"]], ":"))- set(attributes["nginx.deployment.name"], attributes["k8s.pod.name"])transform/metadata_nullify:metric_statements:- context: metricstatements:- set(description, "")- set(unit, "")exporters:otlp_http/newrelic:endpoint: "<YOUR_NEWRELIC_OTLP_ENDPOINT>"headers:api-key: ${env:NR_LICENSE_KEY}service:extensions: [health_check, k8s_observer]pipelines:metrics/nginx:receivers: [receiver_creator/nginx]processors: [batch, resource/cluster, transform/nginx, transform/metadata_nullify, memory_limiter]exporters: [otlp_http/newrelic]設定パラメーター
次の表では、キー設定について説明します。
パラメータ
説明
<YOUR_STUB_STATUS_PORT>NGINXのスタブステータスポート(例:80、8080)に置き換えてください。
<YOUR_STUB_STATUS_PATH>NGINXのスタブステータスパス(例:basic_status)に置き換えてください。
<CLUSTER_NAME>New Relicで識別するためのKubernetesクラスター名に置き換えてください。
<YOUR_NEWRELIC_OTLP_ENDPOINT>お住まいの地域の OTLP エンドポイントを更新してください。
を参照してください。
appおよび
roleラベル
NGINX ポッドを識別するために使用されるポッド ラベル (ラベルと一致するようにルールを更新します)
collection_intervalメトリクスを収集する間隔 (秒単位)。 デフォルト値は
30ssend_batch_max_size送信前にバッチ処理するメトリクスの最大数。デフォルト値は
1000timeoutバッチ処理されたメトリクスを送信する前に待機するタイムアウト時間(秒)。デフォルト値は
30s既存の
deployment-configmap.yamlに以下のセクションを追加してください。追加する拡張機能:
extensions:health_check:endpoint: 0.0.0.0:13133k8s_observer:auth_type: serviceAccountobserve_pods: trueobserve_nodes: true追加予定のレシーバー:
receivers:receiver_creator/nginx:watch_observers: [k8s_observer]receivers:nginx:rule: type == "pod" && labels["app"] == "nginx" && labels["role"] == "reverse-proxy" # Update with your labelsconfig:endpoint: 'http://`endpoint`:<YOUR_STUB_STATUS_PORT>/<YOUR_STUB_STATUS_PATH>' # Update port and path as neededmetrics:nginx.requests:enabled: truenginx.connections_accepted:enabled: truenginx.connections_handled:enabled: truenginx.connections_current:enabled: truecollection_interval: 30sresource_attributes:nginx.server.endpoint: 'http://`endpoint`:<YOUR_STUB_STATUS_PORT>/<YOUR_STUB_STATUS_PATH>' # Update port and path as needednginx.port: '<YOUR_STUB_STATUS_PORT>' # Update to match your configuration追加するプロセッサ:
processors:resource/cluster:attributes:- key: k8s.cluster.namevalue: "<CLUSTER_NAME>" # Replace with your cluster nameaction: inserttransform/nginx:metric_statements:- context: resourcestatements:- set(attributes["nginx.display.name"], Concat(["server","k8s",attributes["k8s.cluster.name"],attributes["k8s.namespace.name"],"pod",attributes["k8s.pod.name"],"nginx",attributes["nginx.port"]], ":"))- set(attributes["nginx.deployment.name"], attributes["k8s.pod.name"])transform/metadata_nullify:metric_statements:- context: metricstatements:- set(description, "")- set(unit, "")追加するサービスパイプライン:
service:extensions: [health_check, k8s_observer] # Add to existing extensionspipelines:metrics/nginx:receivers: [receiver_creator/nginx]processors: [batch, resource/cluster, transform/nginx, transform/metadata_nullify, memory_limiter]exporters: [otlphttp/newrelic]設定パラメーター
次の表では、キー設定について説明します。
パラメータ
説明
<YOUR_STUB_STATUS_PORT>NGINXのスタブステータスポート(例:80、8080)に置き換えてください。
<YOUR_STUB_STATUS_PATH>NGINXのスタブステータスパス(例:basic_status)に置き換えてください。
<CLUSTER_NAME>New Relicで識別するためのKubernetesクラスター名に置き換えてください。
appおよび
roleラベル
NGINX ポッドを識別するために使用されるポッド ラベル (ラベルと一致するようにルールを更新します)
collection_intervalメトリクスを収集する間隔 (秒単位)。 デフォルト値は
30smemory_limiter既存のKubernetes設定でメモリ使用量を制限するために使用されているプロセッサ
更新されたマニフェストを適用し、デプロイメントを再起動します。
- NGINXのみを監視するには、以下のコマンドを実行してください。
bash$kubectl apply -n newrelic -R -f rendered$kubectl delete daemonset nr-k8s-otel-collector-daemonset -n newrelic$kubectl delete deployment nr-k8s-otel-collector-kube-state-metrics -n newrelic$kubectl rollout restart deployment nr-k8s-otel-collector-deployment -n newrelic- K8s + NGINXの監視を行うには、以下のコマンドを実行してください。
bash$kubectl apply -n newrelic -R -f rendered$kubectl rollout restart deployment nr-k8s-otel-collector-deployment -n newrelic
NGINX 監視による NRDOT コレクターのHelmチャートのサポートは近日中に提供される予定です。
あなたが始める前に
以下のものを用意してください:
有効なNew Relicライセンスキー
監視する必要がある NGINX ポッド上のHTTP スタブ ステータスモジュールを有効にします
監視する必要がある各 NGINX ポッドにラベル
appとroleを追加します。Helm installed
OpenTelemetryコレクターを構成する
Helmを使用してOpenTelemetry CollectorをKubernetesクラスタにデプロイします。 コレクターは、NGINX ポッドからメトリクスを自動的に検出して収集します。
OpenTelemetry Collector values.yamlに基づいてカスタム
values.yamlファイルをダウンロードまたは作成します。values.yamlファイルの以下のセクションを更新してください。モードをデプロイメントに設定します。
mode: deployment画像リポジトリを置き換える:
image:repository: otel/opentelemetry-collector-contribクラスタロールの設定:
clusterRole:create: truerules:- apiGroups: [""]resources: ["pods", "nodes", "nodes/stats", "nodes/proxy"]verbs: ["get", "list", "watch"]- apiGroups: ["apps"]resources: ["replicasets"]verbs: ["get", "list", "watch"]リソース制限を設定する:
resources:limits:cpu: 250mmemory: 512Miconfig セクション全体を NGINX 監視設定に置き換えます。
config:extensions:health_check:endpoint: 0.0.0.0:13133k8s_observer:auth_type: serviceAccountobserve_pods: trueobserve_nodes: truereceivers:receiver_creator/nginx:watch_observers: [k8s_observer]receivers:nginx:rule: type == "pod" && labels["app"] == "nginx" && labels["role"] == "reverse-proxy" # Update with your labelsconfig:endpoint: 'http://`endpoint`:<YOUR_STUB_STATUS_PORT>/<YOUR_STUB_STATUS_PATH>' # Update port and path as neededmetrics:nginx.requests:enabled: truenginx.connections_accepted:enabled: truenginx.connections_handled:enabled: truenginx.connections_current:enabled: truecollection_interval: 30sresource_attributes:nginx.server.endpoint: 'http://`endpoint`:<YOUR_STUB_STATUS_PORT>/<YOUR_STUB_STATUS_PATH>' # Update port and path as needednginx.port: '<YOUR_STUB_STATUS_PORT>' # Update to match your configurationprocessors:batch:send_batch_size: 1024timeout: 30sresource/cluster:attributes:- key: k8s.cluster.namevalue: "<CLUSTER_NAME>" # Replace with your cluster nameaction: inserttransform/nginx:metric_statements:- context: resourcestatements:- set(attributes["nginx.display.name"], Concat(["server","k8s",attributes["k8s.cluster.name"],attributes["k8s.namespace.name"],"pod",attributes["k8s.pod.name"],"nginx",attributes["nginx.port"]], ":"))- set(attributes["nginx.deployment.name"], attributes["k8s.pod.name"])transform/metadata_nullify:metric_statements:- context: metricstatements:- set(description, "")- set(unit, "")exporters:otlp_http/newrelic:endpoint: "<YOUR_NEWRELIC_OTLP_ENDPOINT>" # Update for your regionheaders:api-key: "<YOUR_NEW_RELIC_LICENSE_KEY>" # Replace with your New Relic license keyservice:extensions: [health_check, k8s_observer]pipelines:metrics/nginx:receivers: [receiver_creator/nginx]processors: [batch, resource/cluster, transform/nginx, transform/metadata_nullify]exporters: [otlp_http/newrelic]設定パラメーター
次の表では、キー設定について説明します。
パラメータ
説明
<YOUR_STUB_STATUS_PORT>NGINXのスタブステータスポート(例:80、8080)に置き換えてください。
<YOUR_STUB_STATUS_PATH>NGINXのスタブステータスパス(例:basic_status)に置き換えてください。
<CLUSTER_NAME>New Relicで識別するためのKubernetesクラスター名に置き換えてください。
<YOUR_NEWRELIC_OTLP_ENDPOINT>お住まいの地域の OTLP エンドポイントを更新してください。
を参照してください。
<YOUR_NEW_RELIC_LICENSE_KEY>New Relicのライセンスキーに置き換えてください。
appおよび
roleラベル
NGINX ポッドを識別するために使用されるポッド ラベル (ラベルと一致するようにルールを更新します)
basic_statusNGINXスタブステータスエンドポイントパス(別のパスを使用している場合は更新してください)
collection_intervalメトリクスを収集する間隔 (秒単位)。 デフォルト値は
30ssend_batch_size送信前にバッチ処理するメトリクスの数。デフォルト値は
1024timeoutバッチ処理されたメトリクスを送信する前に待機するタイムアウト時間(秒)。デフォルト値は
30s
OpenTelemetry Collector Helm chart インストレーション ガイドに従って、カスタム
values.yamlファイルを使用してコレクターをインストールします。コマンド例:
bash$helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts$helm repo update$helm upgrade my-opentelemetry-collector open-telemetry/opentelemetry-collector -f your-custom-values.yaml -n newrelic --create-namespace --installポッドが実行されていることを確認します。
bash$kubectl get pods -n newrelic --watchOpenTelemetry Collectorが
newrelicネームスペースにRunning状態で表示されるはずです。New RelicでNRQLを実行してデータ収集を確認します。 クラスター名を実際のクラスター名に置き換えてください。
FROM MetricSELECT *WHERE metricName LIKE 'nginx.%'AND instrumentation.provider = 'opentelemetry'AND k8s.cluster.name = 'your-cluster-name'SINCE 10 minutes ago
New Relic でデータを表示する
セットアップが完了し、データが流れるようになると、 New Relicダッシュボードで NGINX メトリクスにアクセスし、カスタム アラートを作成できます。
ダッシュボードへのアクセス、NRQL を使用したデータのクエリ、アラートの作成に関する詳細な手順については、 「NGINX データの検索とクエリ」を参照してください。
メトリクスとプロパティのリファレンス
この統合は、オンホスト デプロイメントと同じコア NGINX メトリクスを収集し、クラスタ、ネームスペース、およびポッド識別用の追加のKubernetes固有のリソース プロパティを収集します。
メトリクスとプロパティの完全なリファレンスについては、 Kubernetesデプロイメントのすべてのメトリクス、タイプ、リソース プロパティの詳細な説明については、 「NGINX OpenTelemetryメトリクスとプロパティ リファレンス」を参照してください。
次のステップ
関連する監視を調べます:
- OpenTelemetryを使用した NGINX Plus のモニター- 商用 NGINX Plus デプロイメント用
- OpenTelemetryを使用したセルフホスト型 NGINX の監視- 従来のサーバー展開の場合
Kubernetes 固有のリソース:
- Kubernetes上のOpenTelemetry Collector - Advanced Collector 設定