# PEDMレポートコマンド

### 概要

ここでは、PEDMの監査レポートと分析を生成するKeeperコマンダーのコマンドを扱います。これらのコマンドで、ポリシー利用状況・監査イベント・サマリーレポートなどPEDM活動の詳細な把握が行えます。管理者は特権昇格イベントの分析、ポリシー効果の追跡、コンプライアンス向けレポートの生成が行えます。

このセクションで扱うコマンドは以下のとおりです。

* [**ポリシー利用状況レポートコマンド**](#report-policy-usage-command)
* [**レポート列定義コマンド**](#report-column-command)
* [**監査イベントレポートコマンド**](#report-event-command)
* [**サマリーレポートコマンド**](#report-summary-command)

### 使い方

`pedm report command [--options]`

***

### ポリシー利用状況レポートコマンド <a href="#report-policy-usage-command" id="report-policy-usage-command"></a>

指定したポリシーの影響を受けるエージェントを表示します。ポリシーとエージェントの対応関係を示し、ポリシー適用状況の分析向けに件数サマリーも取得できます。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm report policy-usage <policy> [policy...]`

**エイリアス:** `pedm report pu`

**フラグ:**

| フラグ         | 説明                               |
| ----------- | -------------------------------- |
| `--summary` | エージェント件数のみ表示する                   |
| `--format`  | 出力形式 - json、csv、tableのいずれか       |
| `--output`  | 指定ファイルに保存する                      |
| `policy`    | ポリシーUID、または全ポリシーを示す\* (必須、複数指定可) |

**例:**

```
My Vault> pedm report policy-usage policy_xyz789

Policy UID: policy_xyz789
Agent UID: agent_abc123

Policy UID: policy_xyz789
Agent UID: agent_def456
```

```
My Vault> pedm report policy-usage * --summary

Policy UID: ['policy_xyz789']
Agent Count: 15
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
from keepersdk.plugins.pedm import admin_plugin

plugin = admin_plugin.PedmPlugin(enterprise_loader)

rq = pedm_pb2.PolicyAgentRequest()
rq.summaryOnly = True ##or False
policies = ['policy UIDs']
if not isinstance(policies, list):
            policies = [str(policies)]
if '*' in policies:
            rq.policyUid.append(plugin.all_agents)
policy_agent = auth.execute_router(
            'pedm/get_policy_agents', rq, response_type=pedm_pb2.PolicyAgentResponse)
```

</details>

### レポート列定義コマンド <a href="#report-column-command" id="report-column-command"></a>

監査レポートの各フィールドについて、ユニークな値とメタデータを表示します。レポートで利用できる列とそのデータ型の把握に役立ちます。カスタムクエリの作成や監査データ構造の理解にも使えます。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm report column <column_name>`

**エイリアス:** `pedm report c`

**フラグ:**

| フラグ             | 説明                         |
| --------------- | -------------------------- |
| `--syntax-help` | 列に関する詳細ヘルプを表示する            |
| `--format`      | 出力形式 - json、csv、tableのいずれか |
| `--output`      | 指定ファイルに保存する                |
| `column`        | 列名 (必須)                    |

**例:**

```
My Vault> pedm report column report_field

Name: event_time
Type: filter
Protection: none

Name: audit_event_type
Type: group
Protection: none

Name: agent_uid
Type: group
Protection: none
```

```
My Vault> pedm report column audit_event_type

Name: agent_registered
ID: 1
Is Client: True
Syslog: Agent registered: ${agent_uid}

Name: policy_evaluated
ID: 2
Is Client: True
Syslog: Policy evaluated: ${policy_uid} - ${evaluation_status}
```

</details>

<details>

<summary>Python SDK</summary>

**関数:** 非対応

</details>

### 監査イベントレポートコマンド <a href="#report-event-command" id="report-event-command"></a>

カスタマイズ可能なフィルターを用いた詳細な監査イベントレポートを生成します。時刻、エージェント、イベントタイプ、その他の条件で任意に絞り込み、個別のPEDMイベントを取得します。複数の出力形式や定義済みの日付範囲に対応します。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm report event [filter...]`

**エイリアス:** `pedm report e`

**フラグ:**

| フラグ               | 説明                                    |
| ----------------- | ------------------------------------- |
| `--syntax-help`   | フィルター構文のヘルプを表示する                      |
| `--report-format` | 出力形式 - messageまたはfields (既定: message) |
| `--timezone`      | 結果のタイムゾーン                             |
| `--limit`         | 返す最大行数 (最大1000)                       |
| `--order`         | 並び順 (choices: desc, asc)              |
| `--format`        | 出力形式 - json、csv、tableのいずれか            |
| `--output`        | 指定ファイルに保存する                           |
| `filter`          | レポートフィルター (任意、複数指定可)                  |

**例:**

```
My Vault> pedm report event event_time=today audit_event_type=policy_evaluated

Event Time: 2024-11-05 14:32:15
Audit Event Type: policy_evaluated
Message: Policy evaluated: policy_xyz789 - Allowed
```

```
My Vault> pedm report event event_time=last_7_days agent_uid=agent_abc123 --limit 10 --order desc

Event Time: 2024-11-05 14:32:15
Audit Event Type: privilege_elevation_request
Message: User john.doe requested elevation for powershell.exe
```

**フィルター構文の例:**

* 単一値: `agent_uid=NJvK0I5RpuF0UFMwRKY_Dw`
* 複数値: `agent_uid=IN(NJvK0I5RpuF0UFMwRKY_Dw, VYLhwqhRvhIpma9e1HoDFw)`
* 範囲: `event_time=BETWEEN 2024-01-01 AND 2024-02-01`
* 定義済み日付: `event_time=today`, `event_time=yesterday`, `event_time=last_7_days`, `event_time=last_30_days`, `event_time=month_to_date`, `event_time=last_month`, `event_time=year_to_date`, `event_time=last_year`

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
rq: Dict[str, Any] = {
    'timezone': datetime.datetime.now().astimezone().tzname()
}
report_filter = ['filters']
if len(report_filter) > 0:
    rq['filter'] = report_filter
limit = int ##max rows to be return
if limit is not None:
    rq['limit'] = limit
order = 'desc' ##or 'asc'
if order:
    rq['order'] = order
rs = auth.execute_router_json('pedm/get_audit_events', rq)
events = rs.get('audit_event_overview_report_rows')
```

</details>

### サマリーレポートコマンド <a href="#report-summary-command" id="report-summary-command"></a>

指定した次元でグループ化した集計監査レポートを生成します。イベント件数、日付範囲、カスタム集計などのサマリー統計が得られます。傾向分析やコンプライアンスレポートに役立ちます。

<details>

<summary>DotNet CLI</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>DotNet SDK</summary>

**関数:** 近日公開

</details>

<details>

<summary>Power Commander</summary>

**コマンド:** 近日公開

</details>

<details>

<summary>Python CLI</summary>

**コマンド:** `pedm report summary [filter...]`

**エイリアス:** `pedm report s`

**フラグ:**

| フラグ             | 説明                                                            |
| --------------- | ------------------------------------------------------------- |
| `--syntax-help` | 構文ヘルプを表示する                                                    |
| `--report-type` | レポートの集計タイプ (choices: hour, day, month, span) - 既定: span       |
| `--group-by`    | グループ化するフィールド。繰り返し指定可                                          |
| `--aggregate`   | 集計の種類 (choices: occurrences, first\_date, last\_date)。繰り返し指定可 |
| `--timezone`    | 結果のタイムゾーン                                                     |
| `--limit`       | 返す最大行数 (最大2000、既定50)                                          |
| `--order`       | 並び順 (choices: desc, asc)                                      |
| `--format`      | 出力形式 - json、csv、tableのいずれか                                    |
| `--output`      | 指定ファイルに保存する                                                   |
| `filter`        | レポートフィルター (任意、複数指定可)                                          |

**例:**

```
My Vault> pedm report summary event_time=last_30_days --report-type day --aggregate occurrences --group-by audit_event_type

Event Time: 2024-11-05
Occurrences: 127
Audit Event Type: policy_evaluated

Event Time: 2024-11-04
Occurrences: 95
Audit Event Type: policy_evaluated
```

```
My Vault> pedm report summary --report-type span --aggregate occurrences first_date last_date --group-by agent_uid

Occurrences: 452
First Date: 2024-10-01
Last Date: 2024-11-05
Agent UID: agent_abc123
```

</details>

<details>

<summary>Python SDK</summary>

**関数:**

```python
report_type: Optional[str] = ['hour', 'day', 'month', 'span']

aggregate = ['occurrences', 'first_date', 'last_date']
if not aggregate:
    aggregate = ['occurrences']
elif isinstance(aggregate, str):
    aggregate = [aggregate]
rq: Dict[str, Any] = {
    'report_type': report_type,
    'aggregate': aggregate,
    'timezone': datetime.datetime.now().astimezone().tzname()
}

report_filter = ['filters']
if len(report_filter) > 0:
    rq['filter'] = report_filter
group_by = ['group by columns name']
if group_by:
    if isinstance(group_by, str):
        group_by = [group_by]
    rq['group_by'] = group_by

limit = int ##max rows to be return
if limit is not None:
    rq['limit'] = limit
order = 'desc' ##or 'asc'
if order:
    rq['order'] = order
response = auth.execute_router_json('pedm/get_summary_audit_report', rq)
```

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keeper.io/keeperpam/jp/commander-sdk/keeper-commander-sdks/sdk-command-reference/pedm-commands/pedm-report-commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
