[Cortex XDR/XSIAM]XQLの集計機能(Compコマンド) - count, avg

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
告知
重要なadvisoryがございます。Customer Advisoryエリアにサインインし、advisoryに添付の日本語PDFファイルをご確認ください。
L4 Transporter
評価なし

Compコマンドは集計するための機能で、以下のような機能を提供しています。

 

approx_count, approx_quantiles, approx_top,avg, count, count_district,

earliest, first, last, latest, list, max, min, sum, values

 

この記事では、count、avgという集計機能についてご紹介します。

XQLを簡単に理解したい場合は、こちらの記事も合わせてお読みください。

 

Count

指定したフィールドをキーにして検索結果のレコードを集計します。

 

ここではサンプルデータとして、3つのホスト("www.spotify.com ","www.google.cp.jp ","edge.microsoft.com")に

アクセスしたエージェントの名前、アクセス先ホスト名、プロセスのイメージ名、宛先IPアドレスを抽出し、

そのデータに対してcount機能を使ってみようと思います。

 

まず以下のXQLでサンプルデータを抽出します。

config timeframe between "2022-12-12 10:00:00 +0900" and "2022-12-12 11:00:00 +0900"

| preset = xdr_agent_network
| fields agent_hostname, action_external_hostname , actor_process_image_name , action_remote_ip
| filter action_external_hostname in ("www.spotify.com "," www.google.co.jp ","edge.microsoft.com")

 

15件見つかりました。

massaito_0-1670890764742.png

 

次にcount機能を使って、上の15レコードをaction_external_hostname毎にレコード数を集計します。

上のXQLに1行追加(青字のところ)したのが以下のXQLになります。

 

config timeframe between "2022-12-12 10:00:00 +0900" and "2022-12-12 11:00:00 +0900"

| preset = xdr_agent_network
| fields agent_hostname, action_external_hostname , actor_process_image_name , action_remote_ip
| filter action_external_hostname in ("www.spotify.com ","www.google.co.jp ","edge.microsoft.com")

| comp count(action_external_hostname) as number_of_count by action_external_hostname

 

XQLを実行すると15件のレコードがアクセス先のホスト(action_external_hostname)毎に集計されたことが

分かります。

massaito_1-1670891025439.png

 

 

 

さらに、集計のフィールドにagent_hostnameを加える(青字のところ)と、

15件のレコードが、action_external_hostnameとagent_hostnameが集計のキーとして使用されます。

config timeframe between "2022-12-12 10:00:00 +0900" and "2022-12-12 11:00:00 +0900"

preset = xdr_agent_network

| fields agent_hostname, action_external_hostname , actor_process_image_name , action_remote_ip
| filter action_external_hostname in ("www.spotify.com ","www.google.co.jp ","edge.microsoft.com")
| comp count(action_external_hostname) as number_of_count by action_external_hostname ,agent_hostname

 

実際に実行すると、agent_hostnameフィールドがキーとして追加され集計されていることがわかります。

massaito_2-1670891208640.png

 

 

AVG

avgはinteger型(整数)のフィールドの値を集計し、平均値を求めることができます。

ここではサンプルデータとして、指定した時間帯に発生したファイルアクティビティのログから、

ある端末のファイルサイズが0以上のログを5件抽出します。

 

config timeframe between "2022-12-09 10:00:00 +0900" and "2022-12-09 10:30:00 +0900"
| preset = xdr_file
| fields agent_hostname, action_file_name, action_file_size ,action_file_name
| filter action_file_size > 0 and agent_hostname = "WIN-0TNTTQOMGDR"
| limit 5

 

実際に実行すると、ファイル名と、そのサイズを抽出します。

2つのファイルとそれぞれにファイルサイズがあることがわかります。

massaito_1-1670903388166.png

 

 

avgを追加して、ファイル名(action_file_name)毎に平均値を求めるXQLを追加します。

(青字のところ)

 

config timeframe between "2022-12-09 10:00:00 +0900" and "2022-12-09 10:30:00 +0900"
| preset = xdr_file
| fields agent_hostname, action_file_name, action_file_size ,action_file_name
| filter action_file_size > 0 and agent_hostname = "WIN-0TNTTQOMGDR"
| limit 5
| comp avg(action_file_size) as avg_action_file_size by action_file_name

 

XQLを実行すると、ファイル毎の平均値が表示されていることがわかります。

massaito_0-1670903311786.png

 

 

このようにCompコマンドには様々な集計用の機能が用意されています。

他の集計機能については別の記事でご紹介していきたいと思います。

 

Tech Doc

countについてはこちら

avgについてはこちら

 

 

 

この記事を評価:
  • 1018 閲覧回数
  • 0 コメント
  • 0 賞賛
Register or Sign-in
寄稿者
記事ダッシュボード
バージョン履歴
最終更新日:
‎11-02-2023 02:46 AM
更新者: