LoginSignup
0
0

More than 3 years have passed since last update.

CloudWatch Logs のメトリクスフィルターで複雑な条件の設定方法

Posted at

AWS CloudWatch Logsのメトリクスフィルターの基本操作

  1. ANDパターンマッチング
    スペース区切りでキーワードを入力する。
    ちなみに、大文字小文字の区別があるので両方フィルタリングしたい場合は、大文字小文字表記を両方のせる。
    ex)
    フィルター: ERROR request
    フィルタリング結果:
    [ERROR] Unable to continue: Failed to process the request

  2. ORパターンマッチング
    スペース区切りでキーワードの頭に?を入力する。
    ex)
    フィルター: ?ERROR ?WARN ?message
    フィルタリング結果:
    [ERROR] Unable to continue: Failed to process the request
    [WARN] Failed to process the request

  3. NOTパターンマッチング
    スペース区切りでキーワードの頭に-を入力する。
    ex)
    フィルター: ERROR -WARN
    フィルタリング結果:
    [ERROR] Unable to continue: Failed to process the request

⇒しかし、JSON形式のlogなどでの複雑なパターンはこの組み合わせでは表現できない。

複雑な条件の設定方法

[( a="*error*" || a="*fail*" ) && ( a!="*hoge*" && a!="*fuga*" )]

のような形で複雑なフィルタパターンを表現できる。
JSON形式の場合は、$.{変数名} = "Content"
のような形にすることで、要素ごとのフィルタリングも可能。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0