icon/x Created with Sketch.

Splunk Cookie Policy

We use our own and third-party cookies to provide you with a great online experience. We also use these cookies to improve our products and services, support our marketing campaigns, and advertise to you on our website and other websites. Some cookies may continue to collect information after you have left our website. Learn more (including how to update your settings) here.
Accept Cookie Policy

Accept License Agreements

This app is provided by a third party and your right to use the app is in accordance with the license provided by that third-party licensor. Splunk is not responsible for any third-party apps and does not provide any warranty or support. If you have any questions, complaints or claims with respect to this app, please contact the licensor directly.

Thank You

Downloading Gmail Audit
SHA256 checksum (gmail-audit_104.tgz) ec7e944773b036df9b58d7c51a206010b6d6a5140efa3fa03a41ec90f2321653 SHA256 checksum (gmail-audit_103.tgz) 8d03dfcaa606d55370af771ca60e45011834a78d147c2a798d8c6c48a507df63 SHA256 checksum (gmail-audit_102.tgz) 683c6c52264a73eb4928c10a485ba77bbad5ea62f2aa888d1cb953687764e2de SHA256 checksum (gmail-audit_101.tgz) 442b1ec45800b2a50c12bc077c8fcb30ad74eaa232c6c4fd34bb8fb636046096
To install your download
For instructions specific to your download, click the Details tab after closing this window.

Flag As Inappropriate

Gmail Audit

Splunk AppInspect Passed
Overview
Details
This app provides three main functions for organisations using Google GSuite and Gmail:
- Enable auditing on Gmail inboxes of users in the G Suite Directory and configure email audit events to go the specified audit recipient inbox
- Retrieve audited emails (headers only) from the audit recipient inbox
- Retrieve the G Suite Directory listing of users and their attributes

Overview

The Gmail Audit TA for Splunk allows a Splunk Enterprise administrator to interface with Google G Suite and Gmail to achieve the following for one or more G Suite domains:

  • Gather a list of users and their attributes from the G Suite Directory
  • Enable Gmail auditing for users in the G Suite Directory and configure audit events to be sent to an audit recipient inbox
  • Gather audit events from the inbox of the audit recipient user

Dependencies

The Gmail Audit TA for Splunk depends on the G Suite For Splunk being installed on the same instance, as it uses some of the same code for the Application Configuration. This relies on the modular inputs framework from the G Suite for Splunk app.

Scripts and binaries

This App provides the following scripts:

input_module_gsuite_directory_user_list.py Gather a listing of users from the G Suite Directory and load them into Splunk.
input_module_gmail_enforce_audit.py Enable Gmail audit for any users in the directory that do not currently have auditing enabled.
input_module_gmail_retrieve_audit_data.py Retrieve audit events from the inbox of the recipient user, load into Splunk and mark messages as read.

Installation

  • Download the add-on from Splunkbase
  • Install the add-on onto your Splunk instance. This could be a single-instance or a data collection instance (HF). Install via the UI or CLI as you would any other Splunk app.
  • Restart Splunk

Configuration

Key concepts for Gmail Audit TA for Splunk

  • You must have enabled the G Suite APIs at https://console.developers.google.com
  • You must have configured a credential for use with this App at https://console.developers.google.com.
  • You must AUTHORIZE this app to make requests into G Suite APIs.
  • It is HIGHLY recommended to setup a separate Splunk-specific Super Admin user within Google G Suite for use with this add-on

G Suite: Enable APIs

For a detailed guide with screenshots about what to do here, please visit my blog about this add-on: Gmail Audit TA for Splunk

Inputs

The app provides three input templates. Each requires an HTTP Event Collector token to which to send events. These do not need to be unique and can be the same token for all three inputs.

HTTP Event Collector

  • Configure a new HTTP Event Collector token and use this when configuring the inputs. Follow this guide if you are unsure how to setup a HEC token.

G Suite Directory User List

  • Enter a name for the input (include the domain in the name if you are using multiple domains for clarity)
  • Set the interval (e.g. once per day [86400 seconds])
  • Choose the destination index
  • Enter the domain for which you have configured and authorised credentials
  • Enter an HTTP Event Collector token to receive the events
  • Enter the hostname to which to send events (in most cases this should be localhost, where the HEC token is configured)

Gmail Enforce Audit

  • Enter a name for the input (include the domain in the name if you are using multiple domains for clarity)
  • Set the interval (e.g. once per day [86400 seconds])
  • Choose the destination index
  • Enter the Audit Recipient address (this should be the email of the Super Admin account used to authorize the credentials)
  • Enter an HTTP Event Collector token to receive the events
  • Enter the hostname to which to send events (in most cases this should be localhost, where the HEC token is configured)

Caveat:
There seems to be a hard 1000 request per day limit on the Gmail Audit API. I tried to get this increased, but did not have any luck.
The request to check if auditing is enabled counts as 1 request, as does the call to set auditing if it is not enabled, which means you can check and enable auditing on only 500 users per day.
The first thing this script does is read the G Suite Directory and get a list of all users in the domain. If there are more than 500 users returned, the script will randomly delete half the users in the list (think Thanos snapping his fingers). This ensures that the script does not run into API limits and over time, all users will eventually have auditing enabled.
If anyone knows how to get that limit increased, please let me know and I will gladly remove that bit of code.

Gmail Retrieve Audit Data

  • Enter a name for the input (include the name of the domain if you are using multiple domains for clarity e.g. example.com-Enable-audit, example.com-Retrieve-audit )
  • Set the interval (e.g. once every 5 minutes [300 seconds])
  • Choose the destination index
  • Enter the domain for which you have configured and authorised credentials
  • Enter an HTTP Event Collector token to receive the events
  • Enter the hostname to which to send events (in most cases this should be localhost, where the HEC token is configured)
  • Enter a batch size of audit messages to process. 20 is a good default as it does not seem to run into API limits.

Troubleshooting

Proxy

If you see any errors like this, it is likely that there is another add-on installed in your environment that has a httplib2 module included in its directory structure.

2019-07-25 03:56:09,304 log_level=ERROR pid=89865 tid=MainThread file="gmail_authorize.py" function="handle_GET" line_number="112" version="TA-gmail-audit.1.0.4" {'errors': [{'msg': 'setproxy() takes at most 7 arguments (8 given)', 'exception_type': 'TypeError', 'line': 104, 'exception_arguments': 'setproxy() takes at most 7 arguments (8 given)', 'filename': 'gmail_authorize.py'}], 'log_level': 'ERROR'}

Any submodules included in any apps installed/enabled are visible to Splunk Python, so if you say "include httplib2" in your module, you have no guarantee that the module included in your app folder is going to be used. I think it simply uses the first one it finds.

If you run into this error, modify the /opt/splunk/etc/apps/TA-gmail-audit/bin/gmail_authorize.py script and uncomment the following lines:

# import imp
# modfile, pathname, description = imp.find_module('httplib2', ['/opt/splunk/etc/apps/TA-gmail-audit/bin/'])
# httplib2 = imp.load_module('httplib2', modfile, pathname, description)

Obviosuly adjust the path if your Splunk and add-on are installed in a location other than '/opt/splunk/etc/apps/TA-gmail-audit/bin/'

This ensures the httlib2 module included in the Gmail Audit TA folder is used and not any other httplib2 modules found in other apps/add-ons.

Acknowledgments

Development of this add-on was commissioned by Qantas Airways. Qantas kindly agreed to allow this to add-on to be released to Splunkbase to support the Splunk community.

The credentials authorisation and storage mechanism in this add-on is duplicated from the G Suite for Splunk add-on written by Kyle Smith. Being able to re-use this code saved me a lot of time in not having to develop similar functionality. Thanks to Kyle Smith for writing the G Suite for Splunk add-on.

Release Notes

Version 1.0.4
Sept. 9, 2019

Performance improvement marking audit messages as read after processing. Using the batchModify Gmail API endpoint instead of marking messages as read individually.

Version 1.0.3
Aug. 9, 2019

Minor bug fixes. Disabling file_cache in Google API client connections to prevent file_cache unavailable when using oauth2client >= 4.0.0 errors.

Version 1.0.2
July 29, 2019

Fixing issues with proxy configuration and other minor bug fixes.

Version 1.0.1
June 24, 2019

Initial release

30
Installs
177
Downloads
Share Subscribe LOGIN TO DOWNLOAD

Subscribe Share

AppInspect Tooling

Splunk AppInspect evaluates Splunk apps against a set of Splunk-defined criteria to assess the validity and security of an app package and components.

Are you a developer?

As a Splunkbase app developer, you will have access to all Splunk development resources and receive a 10GB license to build an app that will help solve use cases for customers all over the world. Splunkbase has 1000+ apps and add-ons from Splunk, our partners and our community. Find an app or add-on for most any data source and user need, or simply create your own with help from our developer portal.

Follow Us:
© 2005-2019 Splunk Inc. All rights reserved.
Splunk®, Splunk>®, Listen to Your Data®, The Engine for Machine Data®, Hunk®, Splunk Cloud™, Splunk Light™, SPL™ and Splunk MINT™ are trademarks and registered trademarks of Splunk Inc. in the United States and other countries. All other brand names, product names, or trademarks belong to their respective owners.