LoginSignup
15
10

More than 5 years have passed since last update.

DatadogのLog Managementにて特定の項目でフィルタをかけたい

Last updated at Posted at 2019-04-17

Datadog の Log Management にて項目(以下 Attribute)を検索として利用できるものと利用できないものがあることに気づきました。
検索可能な Attribute にする方法がわからず詰まったのでメモしておきます。

今回は Datadog-Log-Forwarder を使って CloudFront のログを上げたあとの状態から開始しています。

事前知識 : Attribute とは

ログを選択したときに右からにゅっと出てくる部分に表示されている json の項目のことを指します。

datadog_attributes.png

Standard Attributes - Datadog

Attribute はデフォルトでいくつか規定されており、Log Management へデータ投入後の Pipeline でログ上の項目を Attribute にマッピングしたりするのですが、それはまた別の話。

Log > Configuration > Pipelines | Standard Attrbutes で現在の設定が確認できます。

特定の Attribute を選択して値が合致するものを除外する

例としてスパイダーからのアクセスを除外してみます。

適当なスパイダーからのアクセスログを選択して、@http.useragent_details.browser.family をクリックするとメニューが出てきます。

datadog_log_exclude_attribute.png

  • Search
  • Exclude
  • Add Column
  • Edit facet

この Exclude を選べば Log Explorer から @http.useragent_details.browser.family:Baiduspider に合致するものがなくなります。
超便利な UI ですね。

これだと特定のスパイダーしか除去できていないので、別の Attribute を除外項目にしてみます。

@http.useragent_details.device.brandSpider のものを Exclude しようと思ったらメニューに出てきません。

datadog_log_attribute_menu.png

  • Add Column
  • Create facet

なにかログ投入時に設定が必要だったのか?
Pipeline でなにかしないといけないのかと思ったのか?
とも思いましたが、そんなことはなかったです。

検索可能な Attribute になっていない場合は、 Create facet を選択します。
Group だけ似たようなところがいいので選んで(あとからでも変更できます)、あとはデフォルトのまま Create します。

datadog_create_facet.png

Log Explorer の左カラムにある Filters の WEB ACCESS グループの下に Device Brand が出てきました。
これで Filter の項目として@http.useragent_details.device.brandを使うことができます。

datadog_facet_filter.png

作成直後は開いてもチェックボックスがひとつもないですが、数分すればアクセスログの @http.useragent_details.device.brand に入っている値を表示してくれます。
facet 作成前のデータにはこの Filter は適用されないのでご注意ください。

facet とは

Search - Datadog
Log Explorer - Datadog

ちゃんとマニュアルに書いてありました。

A facet displays all the distinct members of an attribute or a tag as well as provides some basic analytics, such as the number of logs represented. This is also a switch to easily filter your data.
Facets allow you to pivot or filter your datasets based on a given attribute. Examples facets may include users, services, etc…

ログに入っている値をチェックボックスとして一覧にしてくれたり、その件数を表示してくれたり、フィルタ処理もしてくれるのが facet です。

聞き慣れない単語だったのでググりづらく解決方法見つけられなかったです。。
まずマニュアルを読めという話ですが。

facet を作らずに検索条件にしたい

Live Tail にするとなぜかどの Attribute でも Filter として利用可能になっています。
とりあえず grep したいんだ!というときに使えますね。

datadog_live_tail.png

15
10
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
15
10