0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【IBM Application Gateway】IBM Cloud Log Analysisからリクエストログをエクスポートする方法について

Last updated at Posted at 2022-05-25

はじめに

以前の記事でIBM Cloud Log Analysisに、IBM Application Gatewayリクエストログ、監査ログを取り込みました。
【IBM Application Gateway】IBM Cloud Log Analysisへリクエストログ/監査ログを出力する

今回は、取り込んだリクエストログをIBM Cloud Log Analysisからエクスポートしてみます。

1.IBM Cloud Log Analysisでのログ検索

Podの名称で絞り込みや、アプリケーション名で絞り込みして表示できました。

Pod名で絞り込みする例
qiita (1).png

アプリケーション名で絞り込みする例
qiita (2).png

iagというアプリケーション名に該当するログのみ表示できます。
qiita (4).png

監査ログは<>で括られています。

例)
<event rev="1.3">
<date>2022-05-24-21:40:07.004+00:00I-----</date>
<outcome status="0">0</outcome>
<originator blade="iag"><component rev="1.4">authn</component>
<event_id>103</event_id>
<location>iag-1-lx2w6</location>
</originator>
<accessor name="7510009QHV">
<principal auth="oidc">7510009QHV</principal>
<user_location>172.xx.xx.xx</user_location><user_location_type>IPV4</user_location_type></accessor><target resource="7"><object></object></target>
<authntype>oidc</authntype><terminateinfo><terminatereason>idleTimeout</terminatereason></terminateinfo></event>

ログの中から監査ログを除くたデータを絞り込み表示する場合は、以下のキーワードで検索できました。

-"<"

qiita (3).png

青枠のエラーのデータが不要なので、もう少し絞り込み検索します。

  • WARNINGデータを除く
  • DPWIV1212Wというキーワードを含むデータを除く
-"<" -level:WARNING -DPWIV1212W

こちらで、見た目上はリクエストログのみを含むデータを抽出できました。
本当は正規表現を使ってIPアドレスから始まるデータのみ抽出したいところです。
qiita (5).png

2.ログのエクスポート

メニューからExport Linesを選択します。
qiita (6).png

条件と時間枠を確認してRequest Exportをクリックします。
qiita (7).png

LogDNA noreply@logdna.comからメールが届きます。本文のhereのリンクからログをダウンロードします。
qiita (8).png

「export_2022-05-25-01-22-19-762_f0c01124-e3aa-4983-8dd8-2ae38a5033b7.jsonl.gz」という名前のファイルがダウンロードできました。

3. エクスポートしたログの確認

ダウンロードしたログを解凍します。
ログは、jsonlというjsonが1レコードになっているデータ形式となっていました。

データは以下のようになります。

sample.json
{"_tag":["k8s"],"_account":"4exxxxxxxce","_cluster":"ld81","_host":"iag-1-lx2w6","_ingester":"logdna-agent/1.6.5 (Ubuntu/16.04,k8s)","_logtype":"customapp","_mac":"00:00:00:00:84:78","_file":"/var/log/containers/iag-1-lx2w6_iag-xxxishikawa-logging_iag-9615a5a0bc216f15c3d6656933499b3c34ddc9d7fbd346ff567636c992948696.log","_line":"172.xxx.xxx.xxx 7510009QHV 172.xxx.xxx.xxx24/May/2022:21:29:33 +0000 GET GET /home/ HTTP/1.1 200 11881","_rawline":null,"_ts":1653427774068,"_app":"iag","_ip":"172.xxx.xxx.xxx","__key":"logline:4e246b32ce:iag:iag-1-lx2w6:ld81","pod":"iag-1-lx2w6","namespace":"iag-ishikawa-logging","container":"iag","containerid":"9615a5a0bc216f15c3d6656933499b3c34ddc9d7fbd346ff567636c992948696","node":"kube-c2e120vt0neoku866gig-myclusterse-default-000001dc","_ipremote":"165.xxx.xxx.xxx","_bid":"6a3ec618-7fc0-4805-9df8-aaf3359e18ae:42502:ld81","_id":"1482383530955874331"}

最後に

IBM Cloud Log Analysisに取り込んだリクエストログをエクスポートする方法についてご紹介しました。

IBM Application Gatewayの監査ログ(XML形式)は、以下のキーワードで絞り込み検索できませんでした。代替案がないか調べてみたいと思います。

"<"
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?