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.

Object Storageに保存した監査ログをLogging Analyticsで可視化する

Posted at

はじめに

こちらでOCIのComputeインスタンスの監査ログをObjectStorageに保存したのですが、このような感じで保存されていて、このままだと確認するのが大変です。

スクリーンショット 2024-08-30 16.28.00.png

なので、この監査ログをLogging Analyticsに取り込んで可視化したいと思います。

準備

ObjectStorageからLogを取り込むにはAPIまたはCLIが必要なので、設定に必要な値やリソースを確認、作成します。

ポリシーの設定

必要に応じてマニュアルを参考にポリシーを設定します

ロググループの作成

Logging Analyticsの管理から、ログ・グループの作成をクリックします。

スクリーンショット 2024-08-30 11.28.25.png

任意の名前で作成して、OCIDを確認します。

ログソースの確認

同じ管理のソースの数字をクリックします

Auditで検索して、OCI Audit Logsをクリック

スクリーンショット 2024-08-30 15.40.00.png

識別子を確認します

スクリーンショット 2024-08-30 15.43.16.png

ObjectCollectionRuleの作成

CLIで作成します。

設定に必要なパラメータをJSONファイルで作成します。

create.json
{
    "name": "<Rule_Name>",
    "compartmentId": "<Compartment_OCID>",
    "osNamespace": "<Namespace>",
    "osBucketName": "<Bucket_Name>",
    "logGroupId": "<Log_Group_OCID>",
    "logSourceName": "<Log_Source>"
    "collectionType": "HISTORIC",
    "poll-since": "2024-08-30T00:00:00.000Z",
    "poll-till": "2024-08-30T04:00:00.000Z"
}

nameからlogSourceNameまでが必須です。
collectionTypeのデフォルトはLIVEで、ログが継続的に収集されます。
今回はテスト用途なので、HISTORICにして、とりあえず4時間分だけログを取り込んでいます。
poll-sincepoll-tillは、HISTORICの場合必須です。

作成したJSONファイルを指定して、ObjectCollectionRuleを作成します。

% oci log-analytics object-collection-rule create --from-json file://create.json --namespace-name <namespace_name>
{
  "data": {
    "char-encoding": null,
    "collection-type": "HISTORIC",
    "compartment-id": "ocid1.tenancy.oc1..aaaaaaaaltz5yo7vxxxxxx",
    "defined-tags": {
      "Oracle-Tags": {
        "CreatedBy": "default/aa@bb.jp",
        "CreatedOn": "2024-08-30T06:27:54.902Z"
      }
    },
    "description": null,
    "entity-id": null,
    "freeform-tags": {},
    "id": "ocid1.loganalyticsobjectcollectionrule.oc1.ap-tokyo-1.amaaaaaaxxxxxxxxxxxxxxxxxxx",
    "is-enabled": true,
    "lifecycle-details": null,
    "lifecycle-state": "ACTIVE",
    "log-group-id": "ocid1.loganalyticsloggroup.oc1.ap-tokyo-1.amaaaaaaejei3xxxxxxxxxxxxxxxxxx",
    "log-set": null,
    "log-set-ext-regex": null,
    "log-set-key": null,
    "log-source-name": "omc_ociAuditLogSource",
    "name": "instanceAuditLog",
    "object-name-filters": null,
    "os-bucket-name": "instance-audit-log",
    "os-namespace": "xxxxxxxxxxx",
    "overrides": null,
    "poll-since": "2024-08-30T00:00:00.000Z",
    "poll-till": "2024-08-30T04:00:00.000Z",
    "time-created": "2024-08-30T06:27:54.931000+00:00",
    "time-updated": "2024-08-30T06:27:54.931000+00:00",
    "timezone": null
  },
  "etag": "518415a4991688c2b5c63e94a8acaa739069089915b2edb984a2e8c83d673591"
}

namespace-nameはLogging Analyticsのnamespaceのようなのですが、以下で確認したら、ObjectStorage namespaceと同じでした

% oci log-analytics namespace list --compartment-id $C
{
  "data": {
    "items": [
      {
        "compartment-id": "ocid1.tenancy.oc1..aaaaaaaaltz5yxxxxxxxxxxxxxxx",
        "is-data-ever-ingested": true,
        "is-log-set-enabled": false,
        "is-onboarded": true,
        "namespace-name": "xxxxxxxxxxx"
      }
    ]
  }
}

確認

ログエクスプローラーを開くとこのような画面が確認できます

スクリーンショット 2024-08-30 16.56.38.png

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?