https://github.com/victorlcastro-dsa/ms-audit-collector
The ms-audit-collector project is designed to collect and export SharePoint activity logs. It utilizes Microsoft Graph API to query audit logs, fetch user activity, and retrieve folder and file information from SharePoint. The collected data is processed and saved into an Excel file using pandas and xlsxwriter. The project includes configuration ma
https://github.com/victorlcastro-dsa/ms-audit-collector
logs microsoft-graph-api sharepoint-online
Last synced: about 1 month ago
JSON representation
The ms-audit-collector project is designed to collect and export SharePoint activity logs. It utilizes Microsoft Graph API to query audit logs, fetch user activity, and retrieve folder and file information from SharePoint. The collected data is processed and saved into an Excel file using pandas and xlsxwriter. The project includes configuration ma
- Host: GitHub
- URL: https://github.com/victorlcastro-dsa/ms-audit-collector
- Owner: victorlcastro-dsa
- Created: 2025-01-29T11:16:22.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-02-17T15:53:48.000Z (3 months ago)
- Last Synced: 2025-02-17T16:41:27.608Z (3 months ago)
- Topics: logs, microsoft-graph-api, sharepoint-online
- Language: Python
- Homepage:
- Size: 57.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ms-audit-collector
`Under Development`
## Overview
The ms-audit-collector project is designed to collect and export SharePoint activity logs. It utilizes the Microsoft Graph API to query audit logs, fetch user activity, and retrieve folder and file information from SharePoint. The collected data is processed and saved into an Excel file using pandas and xlsxwriter. The project includes configuration management, logging setup, and token-based authentication.
## Features
- **SharePoint User Activity Logs**: Collects user activity logs from SharePoint.
- **Folder and Subfolder Information**: Retrieves information about folders and subfolders in SharePoint.
- **File Upload Activity**: Tracks file upload activities in SharePoint.
- **Audit Log Queries**: Executes and monitors audit log queries using Microsoft Graph API.
- **Excel Export**: Exports the collected data into an Excel file with multiple sheets.## Installation
1. Clone the repository:
```sh
git clone https://github.com/victorlcastro-dsa/ms-audit-collector.git
cd ms-audit-collector
```2. Install the required dependencies:
```sh
pip install -r requirements.txt
```3. Create a `.env` file in the root directory and add the necessary environment variables:
```env
TENANT_ID=your_tenant_id
CLIENT_ID=your_client_id
CLIENT_SECRET=your_client_secret
AUTHORITY=https://login.microsoftonline.com/your_tenant_id
SCOPE=https://graph.microsoft.com/.default
SEARCH_QUERY_PATH=your_search_query_path
SEARCH_QUERY_SIZE=500
SEARCH_QUERY_REGION=your_search_query_region
[email protected],[email protected]
TOKEN_EXPIRY_BUFFER=60
USER_ACTIVITY_SHEET=User Activity
DRIVES_SHEET=Drives
FOLDERS_SHEET=Folders
SUBFOLDERS_SHEET=Subfolders
UPLOAD_FILES_SHEET=Upload Files
FILENAME=Audit_Accounts_Receivable.xlsx
LOG_FILENAME=app.log
SHAREPOINT_HOST=your_sharepoint_host
SHAREPOINT_SITE=your_sharepoint_site
DRIVE_NAME=your_drive_name
SEARCH_DATE=your_search_date
USER_ACTIVITY_PERIOD=D7
AUDIT_QUERY_DISPLAY_NAME=File Access Audit
AUDIT_QUERY_START_DATE=2025-01-30T00:00:00
AUDIT_QUERY_END_DATE=2025-01-31T00:00:00
AUDIT_QUERY_RECORD_TYPE_FILTERS=sharePointFileOperation
AUDIT_QUERY_MONITOR_INTERVAL=10
AUDIT_QUERY_SUCCESS_STATUS=succeeded
AUDIT_QUERY_RUNNING_STATUS=running
AUDIT_QUERY_NOT_STARTED_STATUS=notStarted
AUDIT_SHEET=Audit
```## Usage
Run the `run.py` script to start collecting and exporting audit logs:
```sh
python run.py
```