• EnglishEspañol日本語한국어Português
  • ログイン今すぐ開始

この機械翻訳は、参考として提供されています。

In the event of any inconsistency between the English version and the translated version, the English versionwill take priority. Please visit this page for more information.

問題を作成する

ログフォワーディングのためのFluentdプラグイン

ログデータを既に Fluentd で監視している場合、弊社の Fluentd インテグレーションを使用して、New Relic でログデータを転送し、リッチ化することが可能です。

Fluentd ログをNew Relicに転送すると、ログ データの収集、処理、探索、書き込み、集計の機能が強化されます。

基本的なプロセス

ログ管理機能を有効にするには

  1. あなたが持っていることを確認してください:

    • New Relic

    • Fluentd 1.0以上

  2. Fluentdプラグインをインストールします。

  3. Fluentdプラグインの設定を行います。

  4. 該当する場合は、 EUエンドポイントの設定

  5. テスト Fluentd プラグインを使用しています。

  6. トラフィックを生成して数分待ってから、アカウントのデータを確認してください

Fluentdプラグインのインストール

Fluentdプラグインをインストールするには

Fluentdプラグインの設定

ヒント

Fluentd を初めて構成する場合は、一般的な使用例に対処する事前に構築された 構成ファイル のコレクションを確認すると役立つ場合があります。

Fluentdプラグインの設定を行う。

  1. fluent.confファイル、または td-エージェントを使用している場合はtd-agent.confに次のデータ ブロックを追加し、プレースホルダーのテキストをに置き換えます。

    #Tail one or more log files
    <source>
    @type tail
    <parse>
    @type none
    </parse>
    path /path/to/file
    tag example.service
    </source>
    #Add hostname and service_name to all events with "example.service" tag
    <filter example.service>
    @type record_transformer
    <record>
    service_name ${tag}
    hostname "#{Socket.gethostname}"
    </record>
    </filter>
    #Forward all events to New Relic
    <match <DoNotTranslate>**>
    @type newrelic
    license_key YOUR_LICENSE_KEY
    </match>
  2. 変更が適用されたことを確認するために、Fluentdサービスを再起動します。

このドキュメントはインストールの役に立ちましたか?

EUアカウント用Fluentdプラグインの設定

デフォルトでは、Fluentd プラグインはログを米国のエンドポイント https://log-api.newrelic.com/log/v1に転送します。New Relic 組織が EU データ センターにある場合は、 base_uri プロパティを EU エンドポイントに手動で設定する必要があります。例えば:

#Tail one or more log files
<source>
@type tail
<parse>
@type none
</parse>
path /path/to/file
tag example.service
</source>
#Add hostname and service_name to all events with "example.service" tag
<filter example.service>
@type record_transformer
<record>
service_name ${tag}
hostname "#{Socket.gethostname}"
</record>
</filter>
#Forward all events to New Relic EU Endpoint
<match **</DoNotTranslate>>
@type newrelic
license_key YOUR_LICENSE_KEY
base_uri https://log-api.eu.newrelic.com/log/v1
</match>

Fluentdプラグインのテスト

Fluentdプラグインがログファイルからの入力を受けているかどうかをテストする。

  1. 次のコマンドを実行して、テストログメッセージをログファイルに追加します。

    echo "test message" >> /PATH/TO/YOUR/LOG/FILE
  2. ログ UItest messageを検索します。

ログデータを表示する

すべてが正しく構成され、データが収集されている場合は、次の両方の場所にログが表示されます。

  • ログUI
  • NRQL クエリを実行するためのツール。たとえば、次のようなクエリを実行できます。
SELECT * FROM Log

ログ管理機能を有効にしてもデータが表示されない場合は、標準のログトラブルシューティング手順に従ってください。

チューンナップログ Fluentd バッファ

デフォルトでは、プラグインは5秒ごとにログをNewRelicに送信します。このタイミングを変更する場合は、次の例に従って、構成に<buffer>ブロックを追加します。

[...]
# Forward all events to New Relic EU Endpoint
<match <DoNotTranslate>**>
@type newrelic
license_key YOUR_LICENSE_KEY
<buffer time>
timekey 60s
</buffer>
</match>

詳細については、バッファ構成についての Fluentd のドキュメントを参照してください

UTF-16LE から UTF-8 への変換を構成する

この Microsoft SQL Server エラー ログの例では、Fluentd を使用して、取り込みに 必要な UTF-8 エンコード を使用して、UTF -16LE でエンコードされたログを New Relic に送信します。この例を他のエンコーディングに採用することもできます。

ヒント

これらのログに適切なlogtypeも追加します。

#Tail one or more log files
<source>
@type tail
<parse>
@type none
</parse>
path "D:/sqlserver/error.log"
tag example.service
encoding UTF-8
from_encoding UTF-16LE
</source>
#Add hostname and service_name to all events with "example.service" tag
<filter example.service>
@type record_transformer
<record>
service_name ${tag}
hostname "#{Socket.gethostname}"
logtype MSSQL
</record>
</filter>
#Forward all events to New Relic
<match **</DoNotTranslate>>
@type newrelic
license_key YOUR_LICENSE_KEY
</match>

次は何ですか?

ログ UIを使用して、プラットフォーム全体のログ データを調べます。

ログ転送を無効にする

ログ転送機能を無効にするには、 Fluentd documentation に記載されている標準的な手順に従ってください。New Relic では、他に何もする必要はありません。

Copyright © 2024 New Relic株式会社。

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.