ヒント
このチュートリアルは、 Kubernetes integration v3 Helmを使ってインストールした場合に適用されます。 。v2でHelmを使って行う方法については、 このセクション を確認してください。プレーンなマニフェストの上でサービスを構成する方法を確認するには、 この別のページ をチェックしてください。
Kubernetes上で動作しているサービスがあり、それが当社がサポートしている のサービスである場合、Kubernetesインテグレーションのconfigにそのインテグレーション用の設定セクションを追加することで、そのサービスのモニタリングを有効にすることができます。
このチュートリアルでは、KubernetesのPHP Guestbook上で動作するRedisサービスのモニタリングを有効にする方法を紹介します。一般的な手順については、 Monitor a Kubernetes-running service を参照してください。
何が必要
- この機能の 一般的な要件 、サポートされているサービスなどを参照してください。
- クラスタと通信するには、
kubectl
コマンドライン ツールを構成する必要があります。クラスターがない場合は、 Minikubeを使用して作成できます。
ステップ1:Redisアプリケーションの例を設定する
このチュートリアルは、Kubernetesのチュートリアル Deploying a PHP Guestbook application with Redis をベースにしています。Kubernetesのチュートリアルを飛ばして、以下のコマンドを実行して、チュートリアルに必要なアプリケーションを設定します。
$kubectl create -f https://raw.githubusercontent.com/kubernetes/examples/master/guestbook/all-in-one/guestbook-all-in-one.yaml
Kubernetesチュートリアルを最初に完了したい場合は、チュートリアルの指示に従いますが、「クリーンアップ」セクションの指示には従わないでください。
ステップ2:Redisインスタンスの監視を有効にする
PHP ゲストブック アプリケーションには、1 つのマスター インスタンスと 2 つのレプリカ インスタンスの 3 つの Redis インスタンスがあります。各インスタンスは、 app=redis
のラベルでタグ付けされます。この例では、 Redis モニタリング統合を使用しています。Redis のマスター インスタンスとレプリカ インスタンスの両方を監視できるため、それらを区別する必要はありません。
Helm チャートの
values-newrelic.yaml
YAML ファイルで、newrelic-infrastructure.integrations
セクションを更新する必要があります。統合構成のリストから、Redis 統合 YAML を取得し、それを Kubernetes 構成に追加します。Redis 固有の構成は、redis-config.yml:
キーの下に含まれています。newrelic-infrastructure:integrations:redis-config.yml:# Run auto discovery to find pods with label "app=redis"# https://docs.newrelic.com/docs/integrations/host-integrations/installation/container-auto-discoverydiscovery:command:# Run discovery for Kubernetes. Use the following optional arguments:# --namespaces: Comma separated list of namespaces to discover pods on# --tls: Use secure (TLS) connection# --port: Port used to connect to the kubelet. Default is 10255exec: /var/db/newrelic-infra/nri-discovery-kubernetes --tls --port 10250match:label.app: redisintegrations:- name: nri-redisenv:# using the discovered IP as the hostname addressHOSTNAME: ${discovery.ip}PORT: 6379KEYS: '{"0":["<KEY_1>"],"1":["<KEY_2>"]}'labels:env: production更新したサービスをデプロイする。
bash$helm upgrade --install newrelic newrelic/nri-bundle \>--namespace newrelic --create-namespace \>-f values-newrelic.yaml \>--devel監視するサービスと同じノードでスケジュールされている
nrk8s-kubelet
Pod のログで、次を確認できるはずです。bash$kubectl logs -n newrelic newrelic-nrk8s-kubelet-xxxxx agenttime="2019-12-23T17:37:07Z" level=info msg="Integration health check starting" instance=redis-metrics integration=com.newrelic.redis prefix=integration/com.newrelic.redis working-dir=/var/db/newrelic-infra/newrelic-integrationstime="2019-12-23T17:37:07Z" level=info msg="Integration health check finished with success" instance=redis-metrics integration=com.newrelic.redis prefix=integration/com.newrelic.redis working-dir=/var/db/newrelic-infra/newrelic-integrations
エラーがない場合は、インフラストラクチャ UI に Redis データが表示されるはずです。Redis ダッシュボードを見つけるには、 one.newrelic.com > All capabilities > Infrastructure > Third party servicesに移動し、 Redis ダッシュボードを選択します。
Kubernetes上で動作するサービスを監視する一般的な手順については、設定方法の詳細を含め、 Monitor a Kubernetes-running service を参照してください。