Automation Suite
2022.4
バナーの背景画像
Automation Suite インストール ガイド
最終更新日 2024年4月24日

監査ログのクエリ

前提条件

Automation Suite のセットアップで Apps の監査ログをダウンロードする前に、以下の要件を満たす必要があります。

  • UiPath® サービスがホストされているマシンまたは仮想マシン (VM) へのアクセス権があること。

必要に応じて、以下の情報を把握しておく必要があります。

  • 監査ログが必要な組織名 (<orgName>)
  • 監査ログをエクスポートまたは削除する必要のあるユーザー メール (<userEmail>)
  • 現在から監査ログを取得または削除する日までの日数 (<numDays>)

監査ログのクエリを取得する

db.getCollection("audit-logs").find({
    __tenantId: '<orgName>',
    'userInfo.userEmail': '<userEmail>',
    timestamp: {
        $lte: (new Date().getTime() - 86400000 * <numDays>)
    }
});db.getCollection("audit-logs").find({
    __tenantId: '<orgName>',
    'userInfo.userEmail': '<userEmail>',
    timestamp: {
        $lte: (new Date().getTime() - 86400000 * <numDays>)
    }
});
たとえば、sampleOrg という名前の組織の sampleOrg.admin@org.com というユーザー メールで、180 days より前の監査ログを取得するには、以下のクエリを実行します。
db.getCollection("audit-logs").find({
    __tenantId: 'sampleOrg',
    'userInfo.userEmail': 'sampleOrg.admin@org.com',
    timestamp: {
        $lt: (new Date().getTime() - 86400000 * 180)
    }
});db.getCollection("audit-logs").find({
    __tenantId: 'sampleOrg',
    'userInfo.userEmail': 'sampleOrg.admin@org.com',
    timestamp: {
        $lt: (new Date().getTime() - 86400000 * 180)
    }
});

監査ログを削除する

db.getCollection("audit-logs").deleteMany({
    __tenantId: '<orgName>',
    'userInfo.userEmail': '<userEmail>',
    timestamp: {
        $lte: (new Date().getTime() - 86400000 * <numDays>)
    }
});db.getCollection("audit-logs").deleteMany({
    __tenantId: '<orgName>',
    'userInfo.userEmail': '<userEmail>',
    timestamp: {
        $lte: (new Date().getTime() - 86400000 * <numDays>)
    }
});
たとえば、sampleOrg という名前の組織の sampleOrg.admin@org.com というユーザー メールで、180 days より前の監査ログを削除するには、以下のクエリを実行します。
db.getCollection("audit-logs").deleteMany({
    __tenantId: 'sampleOrg',
    'userInfo.userEmail': 'sampleOrg.admin@org.com',
    timestamp: {
        $lt: (new Date().getTime() - 86400000 * 180)
    }
});db.getCollection("audit-logs").deleteMany({
    __tenantId: 'sampleOrg',
    'userInfo.userEmail': 'sampleOrg.admin@org.com',
    timestamp: {
        $lt: (new Date().getTime() - 86400000 * 180)
    }
});

手順

  1. コマンド プロンプトまたは Powershell を開きます。
  2. 次のコマンドを使用して仮想マシンに SSH 接続します。
    ssh <user>@<host>
    user@host's password: <password>ssh <user>@<host>
    user@host's password: <password>
  3. 次のコマンドを使用して root ユーザーに切り替えます。
    sudo susudo su
  4. 次のコマンドを使用して root フォルダーに移動します。
    cd /cd /
  5. 次のコマンドを使用して KUBECONFIG をエクスポートします。
    export KUBECONFIG=/etc/rancher/rke2/rke2.yaml PATH=$PATH:/var/lib/rancher/rke2/binexport KUBECONFIG=/etc/rancher/rke2/rke2.yaml PATH=$PATH:/var/lib/rancher/rke2/bin
  6. 次のコマンドを使用して MongoDB URI を取得します。
    kubectl -n mongodb get secrets/mongo-admin-user --template={{.data.MONGODB_URI}} | base64 -d
    // copy and store the output till '/admin' (as highlighted in screenshot) for further use in next commandskubectl -n mongodb get secrets/mongo-admin-user --template={{.data.MONGODB_URI}} | base64 -d
    // copy and store the output till '/admin' (as highlighted in screenshot) for further use in next commands


  7. 次のコマンドを使用して Mongo レプリカ セットのシェルに移動します。
    kubectl -n mongodb exec -it mongodb-replica-set-0 bashkubectl -n mongodb exec -it mongodb-replica-set-0 bash
  8. 以下のコマンドを使用して監査レコードを取得します。
    mongo '<mongodb-uri>' --tls --tlsCAFile /var/lib/tls/ca/ca.crt --quiet << EOF > /data/audit-fetch-query.json
    use appstudio
    db.getCollection("audit-logs").find({"__tenantId": "<orgName>", "userInfo.userEmail": "<userEmail>", "timestamp": {\$lte: (new Date().getTime() - 86400000 * <numDays>)}}).toArray()
    EOFmongo '<mongodb-uri>' --tls --tlsCAFile /var/lib/tls/ca/ca.crt --quiet << EOF > /data/audit-fetch-query.json
    use appstudio
    db.getCollection("audit-logs").find({"__tenantId": "<orgName>", "userInfo.userEmail": "<userEmail>", "timestamp": {\$lte: (new Date().getTime() - 86400000 * <numDays>)}}).toArray()
    EOF
  9. 次のコマンドを使用して監査レコードを削除します。
    mongo '<mongodb-uri>' --tls --tlsCAFile /var/lib/tls/ca/ca.crt --quiet << EOF > /data/audit-delete-query.json
    use appstudio
    db.getCollection("audit-logs").deleteMany({"__tenantId": "<orgName>", "userInfo.userEmail": "<userEmail>", "timestamp": {\$lte: (new Date().getTime() - 86400000 * <numDays>)}})          
    EOFmongo '<mongodb-uri>' --tls --tlsCAFile /var/lib/tls/ca/ca.crt --quiet << EOF > /data/audit-delete-query.json
    use appstudio
    db.getCollection("audit-logs").deleteMany({"__tenantId": "<orgName>", "userInfo.userEmail": "<userEmail>", "timestamp": {\$lte: (new Date().getTime() - 86400000 * <numDays>)}})          
    EOF
  10. 次のコマンドを使用してポッド シェルを終了します。
    exitexit
  11. 以下のコマンドを使用してポッドから仮想マシンにファイルを移動します。
    kubectl -n mongodb exec -i mongodb-replica-set-0 -- sh -c 'cat /data/audit-fetch-query.json' > audit-fetch-query.json
    kubectl -n mongodb exec -i mongodb-replica-set-0 -- sh -c 'cat /data/audit-delete-query.json' > audit-delete-query.jsonkubectl -n mongodb exec -i mongodb-replica-set-0 -- sh -c 'cat /data/audit-fetch-query.json' > audit-fetch-query.json
    kubectl -n mongodb exec -i mongodb-replica-set-0 -- sh -c 'cat /data/audit-delete-query.json' > audit-delete-query.json
  12. 次のコマンドを使用して仮想マシンを終了します。
    // exit the root user
    exit
    // exit the vm
    exit// exit the root user
    exit
    // exit the vm
    exit
  13. 以下のコマンドを使用して仮想マシンから個人のマシンにファイルを移動します。
    : SCP は一部の PowerShell では実行されず、インストールが必要になることがあります。
    scp <user>@<host>:/audit-fetch-query.json .
    user@host's password: <password>
    
    scp <user>@<host>:/audit-delete-query.json .
    user@host's password: <password>scp <user>@<host>:/audit-fetch-query.json .
    user@host's password: <password>
    
    scp <user>@<host>:/audit-delete-query.json .
    user@host's password: <password>

Was this page helpful?

サポートを受ける
RPA について学ぶ - オートメーション コース
UiPath コミュニティ フォーラム
UiPath ロゴ (白)
信頼とセキュリティ
© 2005-2024 UiPath. All rights reserved.