This blog was originally published Sept. 17, 2020 on humio.com. Humio is a CrowdStrike Company.
Collecting and monitoring Microsoft Office 365 logs is an important means of detecting indicators of compromise, such as the mass deletion or download of files. However, exporting logs to a log management platform involves running an Elastic Stack with Logstash, which requires significant configuration and infrastructure. In response to customer requests, we’ve discovered an easier way to connect Office 365 logs to Humio with minimal infrastructure and configuration: the O365beat log shipper. O365beat is an open source log shipper used to collect Office 365 audit logs from theOffice 365 Management Activity API
and forward them to Humio. To set it up, follow these instructions from the official
O365beat documentation.
Before you begin
To perform the setup required to grant Humio permission to collect Office 365 logs, you need access to the following:- A Microsoft Office 365 account with administrative privileges
- A Microsoft Azure account with administrative privileges
Installers are available for both Windows and Linux.
Register a new Office 365 web application
To get started collecting Office 365 logs, register an Office 365 web application:- Log into the Office 365 portal as an Active Directory tenant administrator.
- Click
- Select
- Provide the following information in the fields:
- Name - for example, o365humio.
- Select
- Leave the Redirect URI blank.
- Click
Set up Active Directory security permissions
The Active Directory security permissions allow the application you created to read threat intelligence data and activity reports for your organization. To set up Active Directory permissions:- On the main panel under the new application, click
- Locate and click on
- In
- Ensure all necessary permissions are selected, and then click
- Click
- On the left navigation area, select
- Type a key
- Click
- Click
- Click
Install O365beat on a Windows host
- Download the
- Create a
C:\Program Files\O365beat
- Extract the contents of the
.zip
- Open a PowerShell prompt as an Administrator.
- Navigate to the O365beat directory
PS C:\Users\Administrator>cd 'c:\Program Files\O365beat'
- Run the O365beat installation script
PS C:\Program Files\O365beat> .\install-service-o365beat.ps1.
powershell.exe -executionpolicy unrestricted -file .\install-service-winlogbeat.ps1
.
Configure O365beat log collection
The O365beat package includes a configuration file that contains all the necessary credential information to connect to the audit logs for your tenancy. The default configuration file o365beat.yml pulls this information from your environment. The following example shows a typical O365beat log collection configuration:############################# O365beat ######################################
## pull secrets from environment (e.g, > set -a; . ./ENV_FILE; set +a;)
## or a key store (https://www.elastic.co/guide/en/beats/filebeat/current/keystore.html)
## or hard-code here:
tenant_domain: "$O365_TENANT_DOMAIN.onmicrosoft.com"
client_secret: "$O365_CLIENT_SECRET"
client_id: "$O365_CLIENT_ID" # aka application id (GUID)
directory_id: "$O365_DIRECTORY_ID" # aka tenant id (GUID)
registry_file_path: ${O365BEAT_REGISTRY_PATH:./o365beat.state}
## the following content types will be pulled from the API
## for available types, see https://docs.microsoft.com/en-us/office/office-365-management-api/office-365-management-activity-api-reference#working-with-the-office-365-management-activity-api
content_types:
- Audit.AzureActiveDirectory
- Audit.Exchange
- Audit.SharePoint
- Audit.General
In the o365beat.yml configuration file, provide the following information from the Office 365 web application you created:
- tenant_domain
- client_secret
- client_id
- directory_id
registry_file_path
is where O365beat stores its state. The default path does not need to be changed.
Configuring O365beat output to Humio
Data can be sent to Humio by configuring O365beat to use the built-in ElasticSearch output. The following example shows a O365beat output configuration that sends data to Humio’s cloud:#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# Array of hosts to connect to.
hosts: <"https://cloud-es.us.humio.com:443">
# Optional protocol and basic auth credentials.
#protocol: "https"
#username: "elastic"
password: "$HUMIO_INGEST_TOKEN"
compression_level: 5
bulk_max_size: 200
worker: 5
You must make the following changes to the sample configuration:
- Insert the URL containing the Humio host in the
hosts:
https://$YOUR_HUMIO_URL:443
$YOUR_HUMIO_URL
- Insert an
- You may want to increase the number of worker instances (
worker
) from the default of 1 to 5 or 10 to achieve more throughput if O365beat is not able to keep up with the inputs. To get higher throughput, also increasequeue.mem.events
to 32000 to allow buffering for more workers.
Run
- Verify that your
o365beat.yml
file is valid using the following command in PowerShell:PS C:\Program Files\o365beat> .\o365beat.exe test config -c .\o365beat.yml -e
- Start O365beat using the following command:
PS C:\Program Files\o365beat> Start-Service o365beat
. In the future you can start and stop the O365beat service using the Windows Services Control Panel.
registry_file_path
location. The default working directory is
o365beat.state
. To prevent repeat downloads, this file contains a timestamp representing the creation date of the last content blob retrieved.
Final Note
Log collection may not immediately start when your configuration is complete. Per Microsoft’s documentation, it can take up to 12 hours for logs to appear in Humio. Once you’ve started to collect Office 365 logs into Humio, get value from them immediately by building dashboards or setting up security alerts. Learn more about how to set up over 2000threat detection rules
in Humio, including rules for Office 365, by watching our
SOC Prime Workshop.