New Relic初心者 logs parsingについて②
1963 ワード
0.はじめに
newrelic infrastructure agentを利用し、各種ログをnewrelicへ転送。logs parsing機能を利用して情報の切り出しが可能。
前回はapacheのアクセスログをnewrelicへ転送しparsing ruleを適用したが、今回は任意の形式のログに対してparsing ruleを適用する。
1.ログ転送
定義ファイル格納用ディレクトリ
ログ転送の定義ファイルが格納されているディレクトリへ移動
cd /etc/newrelic-infra/logging.d/
configuration fileを作成
ログ識別ができるよう、カスタム属性を付加しておく。
logs:
- name: "random"
file: /home/devops/random
attributes:
log_type: random
ログ更新
以下、クーロンにより定期的にrandomファイルを更新
#write date and randomnum
*/2 * * * * devops echo `date '+\%Y \%m \%d'` $RANDOM >> /home/devops/random
ダッシュボード確認
3.log parsing
Manage parsing rules
parsing を実施するログの絞り込みを実施。
今回は転送したファイルに、log_type:randomを付与しているため、この値を利用。
Parsing logic
ログの形式に則り、parsing logicをgrok patternで表現。
結果
Author And Source
この問題について(New Relic初心者 logs parsingについて②), 我々は、より多くの情報をここで見つけました https://qiita.com/say8/items/de2e55fa24a036dc5872著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .