Alert Logic Office 365 Log Collector
This repository contains Azure Web application Node.js source code and an ARM template for setting up a data collector in Azure which will collect and forward Office 365 log data to the Alert Logic Cloud Defender Log Manager (LM) feature.
Installation requires the following steps:
- Register a new O365 web application in O365 portal for collecting O365 logs.
- Set up the required Active Directory security permissions for the application to authorize it to read threat intelligence data and activity reports for your organization.
- Create an Access Key that will allow the application to connect to the Alert Logic Cloud Defender and Cloud Insight backend.
- Download and deploy a custom ARM template to Microsoft Azure to create functions for collecting and managing O365 log data
- Verify that installation was successful using Alertlogic CloudDefender UI.
In order to install O365 Log collector:
-
Log into O365 portal as AD tenant administrator.
-
Go to
Setup
andDomain
and make a note of O365 domain name to collect logs from, for example,example.onmicrosoft.com
. -
Navigate to
Admin Centers
andAzure AD
. -
On the left side panel click
Azure Active Directory
andApp Registrations
. -
Click
+New application registration
, fill in configuration parameters and clickCreate
:Name
- for examplealo365collector
.- Select
Web app/ API
asApplication type
. - In
Sign-on URL
enter some URL, for examplehttp://alo365collector.com
. Note, it is not used anywhere.
-
After application is created select it and make a note of
Application Id
, for example,a261478c-84fb-42f9-84c2-de050a4babe3
- On the
Settings
panel and selectRequired permissions
and click+Add
- Hit
Select an API
and choseOffice 365 Management APIs
, clickSelect
- In
Application permissions
selectRead service health information for your organization
,Read activity data for your organization
,Read threat intelligence data for your organization
andRead activity reports for your organization
. ClickSelect
andDone
buttons. - On
Required permissions
panel clickRequired permissions
button and confirm the selection. Note, only AD tenant admin can grant permissions to an Azure AD application. - On the
Settings
panel of the application and selectKeys
. - Enter key
Description
andDuration
and clickSave
. Note, please save the key value, it is needed later during template deployment. - Save the
Application ID
andService Principal Id
for use below. To get theService Principal Id
, navigate to theRegistered App
blade, click on the link underManaged application in local directory
. Then clickProperties
. TheService Principal Id
is labeledObject ID
on the properties page. Caution This is not the sameObject ID
listed in theProperties
blade reached by clickingSettings
orAll Settings
from theRegistered app
. It is also not theObject ID
shown on theRegistered app
blade itself.
Login and get an authentication token from the Alert Logic Cloud Insight product AIMS API. From the command line use curl as follows (where <user>
is your CloudInsight user and <pwd>
is your CloudInsight password):
curl -X POST -v -u '<user>:<pwd>' https://api.global-services.global.alertlogic.com/aims/v1/authenticate
Make a note of the following fields returned in the response:
- USER ID
- ACCOUNT ID
- TOKEN
Use the authentication token returned in the response to create access keys for the Azure application deployed in the next section. Issue the following curl command (where <TOKEN>
is the auth token, <ACCOUNT_ID>
is the account ID, and <USER_ID>
is the user ID returned above):
curl -X POST -H "x-aims-auth-token: <TOKEN>" https://api.global-services.global.alertlogic.com/aims/v1/<ACCOUNT_ID>/users/<USER_ID>/access_keys
An example of a successful response is:
{"access_key_id":"8bb72b92eb43f0bb","secret_key":"15b74g7fe32b9a0083172b724fa8b84aebfa9325bba2b3bc8933216013e220c1"}
Make a note of the access_key_id
and secret_key
values for use in the deployment steps below.
Note: Only five access keys can be created per user. If you get a "limit exceeded" response you will need to delete some keys in order to create new ones. Use the following command to delete access keys:
curl -X DELETE -H "x-aims-auth-token: <TOKEN>" https://api.global-services.global.alertlogic.com/aims/v1/<ACCOUNT_ID>/users/<USER_ID>/access_keys/<ACCESS_KEY_ID>
Log into Azure portal. Note, In order to perform steps below you should have an active Azure subscription, to find out visit Azure subscriptions blade
- Download an ARM template
- Go to Customer Deployment page. Type in
deploy
in a search query located on top of Azure Web UI and selectDeploy a custom template
. - Click
Build your own template in the editor
and load the file previously downloaded on step 1 above. - Click
Save
button. - Fill in required template parameters and click the
Purchase
button to start a deployment. I.e.:Name
- Any nameStorage Name
- Any Storage Account name (that does not currently exist)Alert Logic Access Key ID
-access_key_id
returned from AIMs aboveAlert Logic Secret Key
-secret_key
returned from AIMs aboveAlert Logic API endpoint
- usuallyapi.global-services.global.alertlogic.com
Alert Logic Data Residency
- usuallydefault
Office365 Content Streams
- The list of streams you would like to collect. Valid values are:- ["Audit.AzureActiveDirectory","Audit.Exchange","Audit.SharePoint","Audit.General", "DLP.All"]
Office365 Tenant ID
- The GUID of the tenant e.g.alazurealertlogic.onmicrosoft.com
Service Principal ID
- TheObject ID
of the application that created the subscription. You can obtain it from Azure -> AD -> App registrations -> Your app name -> Link under Managed application in local directory -> Properties -> Object IDApp Client ID
- The GUID of your application that created the subscription. You can obtain it from Azure -> AD -> App registrations -> Your app nameApp Client Secret
- The secret key of your application from App RegistrationsRepository URL
- must behttps://github.com/alertlogic/azure-collector.git
Repository Branch
- should usually bemaster
You can use either Azure Cloud Shell or local installation of Azure CLI.
- Create a resource group with name "AlertLogicCollect" in location "Central US" by executing following command
az group create --name AlertLogicCollect --location "Central US"
- Once created go to
Resource groups
blade and select the resource group. - Select
Access Control (IAM)
and addWebsite Contributor
role to AD application identity created above. - Deploy a template by using following command, during its execution enter required parameters when asked
az group deployment create \ --name AlertLogicCollector \ --resource-group AlertLogicCollect \ --template-uri "https://raw.githubusercontent.com/alertlogic/azure-collector/master/template.json"
Wait until it is deployed successfully.
- Go to
Azure Apps
and choose your function. The last log underFunctions-> Master-> Monitor
should have OK status and should not contain any error messages. - Log into Alertlogic CloudDefender and navigate into
Log Manager -> Sources
page. Check new O365 log source (with a name provided duringaz group deployment create
above) has been created and source status isok
.
The Master
function is a timer trigger function which is responsible for:
- registering the Azure web app In Alertlogic backend;
- reporting health-checks to the backed;
- performing log source configuration updates, which happen via Alertlogic UI.
Note: When releasing a new version of the collector please remember to increment the version number in
npm package.json file. To display the current version locally, issue npm run local-version
The Updater
is a timer triggered function runs deployment sync operation every 12 hours in order to keep entire Web application up to date.
The Collector
function exposes an HTTP API endpoint https://<app-name>/o365/webhook
which is registered as an Office 365 webhook and processes O365 activity notifications. Below is a notification example,
[
{
"contentType": "Audit.AzureActiveDirectory",
"contentId": "20170721121608709004422$20170721121608709004422$audit_azureactivedirectory$Audit_AzureActiveDirectory$IsFromNotification",
"contentUri": "https://manage.office.com/api/v1.0/bf8d32d3-1c13-4487-af02-80dba2236485/activity/feed/audit/20170721121608709004422$20170721121608709004422$audit_azureactivedirectory$Audit_AzureActiveDirectory$IsFromNotification",
"notificationStatus": "Succeeded",
"contentCreated": "2017-07-21T12:16:56.798Z",
"notificationSent": "2017-07-21T12:16:56.798Z",
"contentExpiration": "2017-07-28T12:16:08.709Z"
},
{
"contentType": "Audit.AzureActiveDirectory",
"contentId": "20170721121625590007449$20170721121625590007449$audit_azureactivedirectory$Audit_AzureActiveDirectory$IsFromNotification",
"contentUri": "https://manage.office.com/api/v1.0/bf8d32d3-1c13-4487-af02-80dba2236485/activity/feed/audit/20170721121625590007449$20170721121625590007449$audit_azureactivedirectory$Audit_AzureActiveDirectory$IsFromNotification",
"notificationStatus": "Succeeded",
"contentCreated": "2017-07-21T12:16:56.798Z",
"notificationSent": "2017-07-21T12:16:56.798Z",
"contentExpiration": "2017-07-28T12:16:25.590Z"
}
]
A notification contains a link to the actual data which is retrieved by the Collector
, wrapped into a protobuf structure TBD link and is sent into Alertlogic Ingest service.
- Clone repo
git clone [email protected]:alertlogic/azure-collector.git
cd azure-collector
- Run
./local_dev/setup.sh
- Edit
./local_dev/dev_config.js
- Run Master function locally:
npm run local-master
- Run Updater function locally:
npm run local-updater
- Run O365WebHook function locally:
npm run local-o365webhook
- Run
npm test
in order to perform code analysis and unit tests.
Please use the following code style as much as possible.
process.env.APP_TENANT_ID
- The GUID of the tenant i.e. 'alazurealertlogic.onmicrosoft.com'process.env.CUSTOMCONNSTR_APP_CLIENT_ID
- The GUID of your application that created the subscription. You can obtain it from Azure -> AD -> App registrations -> Your app nameprocess.env.CUSTOMCONNSTR_APP_CLIENT_SECRET
- A secret key of your application from App Registrations.process.env.CUSTOMCONNSTR_APP_CI_ACCESS_KEY_ID
- access key returned from AIMs above.process.env.CUSTOMCONNSTR_APP_CI_SECRET_KEY
- secret key returned from AIMs above.
- Sometimes deployments fail after siteSync action. We need better updater to handle that in order not to wait for 12 hours for the next update attempt.