ラボ 12 - 関連するログ メッセージの分析
transaction operator を使用すると、一意のトランザクション識別子 (セッション ID や IP アドレスなど) に基づいて、関連する一連のメッセージを分析できます。transaction は、指定された一意の識別子を使用して、関連するメッセージをグループ化し、定義された状態に基づいて整理します。このラボでは、transaction を使用して、ecommark という電子商取引のウェブサイトでユーザが遭遇する状態を追跡します。これにより、ユーザが電子商取引のウェブサイトでどのような操作を行っているのかを分析できます。
-
過去 24 時間の ecommark のすべてのログ メッセージ (_sourceCategory=Labs/ecommark) を検索します。
-
各メッセージには、IP アドレスとトリガ時の状態を示す情報があります。たとえば、「Order Shipped」や「GET /checkout/confirmation」などの状態があります。
-
次の例では、transaction operator で IP アドレスを一意の識別子として使用して、いくつかの発生しうる状態を取得しています。このクエリを自分のログ検索ウィンドウにコピーし、タイムフレームとして [Last 1 hour (過去 1 時間)] を使用します。
_sourceCategory=Labs/ecommark
| parse regex "(?<ip>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})" nodrop
| transaction on ip
with "*/confirmation*" as confirmation,
with "*Order shipped*" as ordershipped,
with "*/cart*" as cart,
with "*/shippingInfo*" as shippinginfo,
with "*/billinginfo*" as billinginfo
results by flow
-
次に count operator を使用して、各状態の頻度を調べます。count by fromstate, tostate を追加します。
_sourceCategory=Labs/ecommark
| parse regex "(?<ip>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})" nodrop
| transaction on ip
with "*/confirmation*" as confirmation,
with "*Order shipped*" as ordershipped,
with "*/cart*" as cart,
with "*/shippingInfo*" as shippinginfo,
with "*/billinginfo*" as billinginfo
results by flow
| count by fromstate, tostate
-
これらの集計結果をグラフ化するには、フローチャートを選択して、トランザクション フローのサンキー図を表示します。
おまけ:
クエリの最後の 2 行を削除またはコメントアウトします。これにより、transaction operator はイベントの発生順序を無視して、状態のトリガ順序に関係なく、特定の IP アドレスに対して各状態がトリガされた回数のみをカウントするようになります。