Integrate Code42 with LogRhythm


LogRhythm is a security information and event management (SIEM) tool that helps you detect and respond to threats. This tutorial explains how to ingest file exfiltration event data from Code42 into LogRhythm using the Code42 command-line interface (CLI). 


  • Python version 3.5 or later is required. For instructions on downloading and installing Python, see the Python documentation
  • Your LogRhythm orchestration server must be able to connect via SSL (ports 80 and 443) to your Code42 console address. 

Before you begin

Create an API client

In the Code42 console, create an API client to provide permissions in the CLI for the integration with LogRhythm:

Install and configure the Code42 CLI

To integrate Code42 with LogRhythm, you must first install the Code42 command-line interface (CLI) and create a profile following the instructions in Introduction to the Code42 command-line interface

Create an automated task for the Code42 CLI

After you've completed the steps of creating a user and setting up the Code42 CLI, create an automated task or cron job for running a query on a scheduled basis

Linux cron job

Windows automated task

Collect the flat file in LogRhythm

Upon completing the steps above, Code42 data is written to a flat file on the orchestration server. Set up a LogRhythm Collection Agent to collect and ingest the flat file.


  • In the LogRhythm console, create: 
    • A new custom log source type
    • MPE rules
    • Log processing policy
    • (Optional) Custom common events, to parse the Code42 data according to your needs
  • Please refer to the LogRhythm Community for instructions on how to create Custom MPE Rules, Log Processing Policy, and custom common events. You must have LogRhythm Community credentials to access those instructions. 

Create a new custom log source type

  1. In the LogRhythm console, select Deployment Manager.
  2. Select Tools > Knowledge > Log Source Type Manager
    The Log Source Type Manager window opens.
  3. Click the New (+) icon.
    The Log Source Type Properties window opens. 
  4. Enter a Name. 
  5. Enter an Abbreviation.
  6. Select a Log Format. 
  7. (Optional) Enter a Brief Description. 
  8. Click OK

Create custom message processing engine rules

Create custom message processing engine (MPE) rules for parsing messages, pulling in fields, and making tags. The rules you create may vary depending on your use cases and deployment details. 

  1. In the LogRhythm console, go to Tools > Knowledge > MPE Rule Builder.
  2. Click the Create a new rule (+) icon to create a new rule. 
  3. Enter the Rule Name. 
  4. Select a Common Event. 
  5. For the Rule Status, select Production
  6. Select an option from the Log Message Source Type Associations column.
  7. See the regex below to enter in the Base-rule Regular Expression field. 
  8. Click the Save icon to save the rule. 
  9. (Optional) To create another rule, click the Create a new rule (+) icon. 
  10. Repeat the above steps to create as many rules as necessary. 

Create an MPE rule sort order

  1. In the LogRhythm console, go to Tools > Knowledge > MPE Rule Builder.
  2. Click the Open rule library folder icon. 
  3. From the Rule Browser window, search for the custom log source type you created. 
  4. Click Edit > Edit Base-rule Sorting
    The Rule Sorter window opens. 
  5. Select Auto-Sort for all exposure rules. 
  6. Using the arrow buttons on the left, sort non-exposure rules below exposure rules and leave auto-sort unchecked. 
  7. Move Catch all rules to the bottom of the list and leave auto-sort unchecked. 
  8. Click OK

Create a log processing policy 

  1. In the LogRhythm console, select Deployment Manager.
  2. Click Log Processing Policies
  3. Click the New (+) icon to create a new log processing policy. 
    The Log Source Type Selector window opens. 
  4. From the Record Type Filter column, select Custom
  5. Select the Log Source Type you created earlier. 
  6. Click OK
    The MPE Policy Editor window opens. 
  7. Enter a Name. 
  8. Below the list of rules, right-click and select Check All
  9. Right-click the last row again and select Properties
    The MPE Policy Rule Editor window opens.
  10. Select Enabled
  11. Click OK
    The MPE Policy Rule Editor window closes. 
  12. Confirm that all rules are enabled.
  13. Click OK.

Add the newly created log source to be collected by a LogRhythm system monitor agent

  1. In the LogRhythm console, select Deployment Manager.
  2. Select System Monitors.
  3. Right-click on the System Monitor Agent you want to use to collect the log source you created previously. 
  4. Click Properties
    The System Monitor Agent Properties window opens. 
  5.  Right-click on the bottom box and select New
    The Log Message Source Properties window opens.
  6. Enter the necessary information on the Basic Configuration tab.
  7. For the Log Message Source Name choose the log source you just created.
  8. In the Log Message Processing Settings section, Log Message Processing Engine (MPE) Policy option, choose the policy you just created.
  9. Select the Flat File Settings tab.
  10. In the File Path field, enter the file path where you configured the Code42 CLI to saving the flat file.  
  11. Select the Date Parsing Format ... icon.
    The Date Format Manager window opens. 
  12. Right-click in the window and select New
    The Date Format Properties window opens. 
  13. Enter a Name. 
  14. Enter the following Regex: CEF:0.*?end=<UTC><unix>
  15. Click OK
  16. (Optional):
    1. Click the Additional Settings tab.
    2. Select Start Collection from beginning of the log
  17. Click OK

Base-rule regex 

See below for example strings to enter in the Base-Rule Regular Expression field when creating MPE rules, along with guidance on sort order position.  

App read exposure

Shared via cloud storage exposure 

Shared via link exposure

Shared via removable media exposure

Shared via email

Endpoint non-exposure

Cloud non-exposure

Catch all

Test regex rule matching and performance

  1. From the custom MPE rule you created, click the Test Center tab. 
  2. Right-click in the bottom Test Center section.
  3. Select Import Log Messages Manually
    The Test Log Importer window opens. 
  4. Paste in the sample logs from the flat file on the orchestration server. 
  5. Click OK
  6. Click Test All
    The Rule Builder Test Results window opens. 
  7. Review the results. 
  8. Click Close

(Optional) Create a Global Long Processing Rule 

You may need to create a global long processing rule (GLPR) to forward all Code42 exposures as events. 

  1. From the LogRhythm console, select Tools > Administration > Global Long Processing Rule Manager.
    The Global Long Processing Rule Manager window opens. 
  2. Click the New Rule + button. 
    The Global Log Processing Rule Wizard window opens.
  3. Select the Include Filters tab.
  4. Click the New + button. 
    The Log Message Filter window opens. 
  5. From the Add New Field Filter list, select Log Source Type. 
  6. Click Edit Values.
    The Field Filter Values window opens. 
  7. Click Add Item
    The Log Source Type Selector window opens. 
  8. Select the Log Source Type you created. 
  9. Click OK. 
    The Field Filter Values window appears with the item you added.
  10. Click OK.  
  11. From the Add New Field Filter list, select Common Event.
  12. Click Edit Values.
    The Field Filter Values window opens. 
  13. Click Add Item
    The Common Event Selector window opens. 
  14. For the Classification Filter, select Security : Suspicious
  15. For the Common Event, select Suspicious Activity
  16. Click OK
  17. Click Add Item
    The Common Event Selector window opens. 
  18. For the Classification Filter, select Security : Suspicious,
  19. For the Common Event, select Suspicious E-Mail Activity
  20. Click OK
  21. From the Field Filter Values window, click OK
  22. From the Log Message Filter window, click OK
  23. From the Global Log Processing Rule Wizard window, select the Settings tab. 
  24. In the Event Management Settings section, select Override Event Forwarding.
  25. Select Forward as Event
  26. Click Next
  27. Enter a Name for the global long processing rule.  
  28. Click OK
  29. On the Global Long Processing Rule Manager window, click the Action box for the global long processing rule you just created. 
  30. Right-click in the row for your new global long processing rule and select Action > Enable