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】リクエストログ/監査ログをJSON形式に変更する

Last updated at Posted at 2022-05-26

はじめに

過去の記事で、IBM Cloud Log Analysisに保管された監査ログをうまく検索できなかったため、IBM Application Gatewayのコンテナコンソールに出力されるリクエストログ、監査ログの形式をJSON形式に変更してみました。

過去の記事

1.IBM Application Gateway設定変更について

ログのフォーマットを変更するに、JSON Logging を参考に設定を追加します。

logging:
  request_log:
    format: "%h %u %a %t %m %r %s %b"
  tracing:
    - file_name: /var/iag/trace.log
      component: pdweb.debug
      level: 9
    - file_name: /var/iag/trace.log
      component: pdweb.http.transformation
      level: 5
    - file_name: /var/iag/snoop.log
      component: pdweb.snoop
      level: 9
  transaction:
    file_name: trans.log
    max_file_size: 1024
    max_files: 5
    compress: false
  ###追加###
  json_logging: true
  ########
  components:
    - audit.authn
    - audit.azn

2.IBM Cloud Log Analysisでのログ出力確認

IBM Cloud Log Analysisで出力結果を確認したところ、リクエストログ、監査ログがJSON形式で出力されました。

qiita (3).png

リクエストログはINFOレベルで出力されていました。

May 25 18:17:47 iag-1-m6xz7 iag INFO {"instant":{"epochSecond":1653470267},"threadId":"0x582e7700","level":"INFO","loggerName":"request-log","content":"172.xxx.xxx.xxx unauthenticated 172.xxx.xxx.xxx  25/May/2022:09:17:47 +0000 GET GET \/home HTTP\/1.1 302 4359"}

監査ログはAUDITレベルで出力されました。

May 25 18:17:47 iag-1-m6xz7 iag AUDIT {"instant":{"epochSecond":1653470267},"level":"AUDIT","outcome":"0","originator":{"blade":"iag","component":"authn","event_id":"101","location":"iag-1-m6xz7"},"target":{"resource":"7","object":"","url":""},"authntype":"oidc"}

レベルで絞り込み表示できます。

infoレベルを絞り込み表示
> level:info

auditnfoレベルを絞り込み表示
> level:audit

qiita (7).png

3.Traceログのフォーマット確認

Trace.logはJSON形式に変換されてはいませんでした。

利用したコマンド
> oc get pods
> oc rsh pod名
> cat /var/iag/trace.log

qiita (10).png

最後に

IBM Application GatewayのログをJSON形式に変更する方法についてご紹介いたしました。
IBM Cloud Log Analysisにログ保管する場合は、JSON形式のほうが検索など利便性が高いと感じました。

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?