-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add Admin Reports API tables for admin, drive, login, mobile, and token activity #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
08f64e1
feat: add Admin Reports API tables for admin, drive, login, mobile, a…
assakafpix 69412bd
refactor: documentation reformulation
assakafpix 0f040a8
refactor: remove redundant comment in ReportsService
assakafpix b8cf47b
refactor: remove redundant code
assakafpix 1c0fa85
refactor: merge the five admin reports tables into one
assakafpix c0007ea
feat: add key-column event_name for filter push-down
assakafpix f6e3711
Update googleworkspace_admin_reports_activity documentation
assakafpix fbe23db
fix: correctly surface event_name qualifier using exact-match cache
assakafpix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,184 @@ | ||||
| --- | ||||
|
|
||||
| title: "Steampipe Table: googleworkspace_admin_reports_activity - Query Google Workspace Admin Reports Activity using SQL" | ||||
| description: "Allows users to query the Google Workspace Admin Reports API to retrieve detailed audit activity logs across various Google Workspace applications." | ||||
| --- | ||||
|
|
||||
| # Table: googleworkspace_admin_reports_activity - Query Google Workspace Admin Reports Activity using SQL | ||||
|
|
||||
| The Reports API is a RESTful API you can use to access information about the Google Workspace activities of your users. | ||||
|
|
||||
| ## Table Usage Guide | ||||
|
|
||||
| The `googleworkspace_admin_reports_activity` table in Steampipe provides a unified interface to query the Google Workspace Admin Reports API. It surfaces detailed audit logs across all Workspace applications (Drive, Calendar, Keep, Admin console, and more). You can use this table to investigate user actions, system events, and security-related activities within your Workspace environment. | ||||
|
|
||||
| **Important Notes** | ||||
|
|
||||
| - You must `application_name` in a `where` clause in order to use this table ([List of all applications](https://developers.google.com/workspace/admin/reports/reference/rest/v1/activities/list?hl=fr#applicationname)). | ||||
| - For improved performance, it is advised that you use the optional qual `time` to limit the result set to a specific time period. | ||||
| - This table supports optional quals. Queries with optional quals are optimised to use Activity filters. Optional quals are supported for the following columns: | ||||
| - `actor_email` | ||||
| - `ip_address` | ||||
| - `event_name` | ||||
|
|
||||
| ## Examples | ||||
|
|
||||
| ### List all Drive events in the last hour | ||||
|
|
||||
| Retrieve audit events for Google Drive that occurred in the past hour. | ||||
|
|
||||
| ```sql+postgres | ||||
| select | ||||
| time, | ||||
| actor_email, | ||||
| event_names, | ||||
| param->>'value' as file_name, | ||||
| ip_address, | ||||
| events | ||||
| from | ||||
| googleworkspace_admin_reports_activity as a | ||||
| cross join lateral jsonb_array_elements(a.events) as evt | ||||
| cross join lateral jsonb_array_elements(evt->'parameters') as param | ||||
| where | ||||
| application_name = 'drive' | ||||
| and param->>'name' = 'doc_title' | ||||
| and time > now() - interval '1 hour'; | ||||
| ``` | ||||
|
|
||||
| ```sql+sqlite | ||||
| select | ||||
| time, | ||||
| actor_email, | ||||
| event_names, | ||||
| param->>'value' as file_name, | ||||
| ip_address, | ||||
| events | ||||
| from | ||||
| googleworkspace_admin_reports_activity as a | ||||
| cross join lateral jsonb_array_elements(a.events) as evt | ||||
| cross join lateral jsonb_array_elements(evt->'parameters') as param | ||||
| where | ||||
| application_name = 'drive' | ||||
| and param->>'name' = 'doc_title' | ||||
| and time > datetime('now', '-1 hour'); | ||||
| ``` | ||||
|
|
||||
| ### List all password changes performed by administrators on users | ||||
|
|
||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
| Show all changes of password performed by administrators on users in the last month. | ||||
|
|
||||
| ```sql+postgres | ||||
| select | ||||
| time, | ||||
| actor_email, | ||||
| event_names, | ||||
| param->>'value' as user_email, | ||||
| ip_address, | ||||
| events | ||||
| from | ||||
| googleworkspace_admin_reports_activity as a | ||||
| cross join lateral jsonb_array_elements(a.events) as evt | ||||
| cross join lateral jsonb_array_elements(evt->'parameters') as param | ||||
| where | ||||
| application_name = 'admin' | ||||
| and event_name = 'CHANGE_PASSWORD' | ||||
| and param->>'name' = 'USER_EMAIL' | ||||
| and time > now() - interval '1 month'; | ||||
| ``` | ||||
|
|
||||
| ```sql+sqlite | ||||
| select | ||||
| time, | ||||
| actor_email, | ||||
| event_names, | ||||
| param->>'value' as user_email, | ||||
| ip_address, | ||||
| events | ||||
| from | ||||
| googleworkspace_admin_reports_activity as a | ||||
| cross join lateral jsonb_array_elements(a.events) as evt | ||||
| cross join lateral jsonb_array_elements(evt->'parameters') as param | ||||
| where | ||||
| application_name = 'admin' | ||||
| and event_name = 'CHANGE_PASSWORD' | ||||
| and param->>'name' = 'USER_EMAIL' | ||||
| and time > datetime('now', '-1 month'); | ||||
| ``` | ||||
|
|
||||
| ### Show login failures by specific user | ||||
|
|
||||
| Show all failed login attempts by a specific user in the last week. | ||||
|
|
||||
| ```sql+postgres | ||||
| select | ||||
| time, | ||||
| event_names, | ||||
| ip_address | ||||
| from | ||||
| googleworkspace_admin_reports_activity | ||||
| where | ||||
| application_name = 'login' | ||||
| and actor_email = '[email protected]' | ||||
| and event_name = 'login_failure' | ||||
| and time > now() - '1 week'::interval; | ||||
| ``` | ||||
|
|
||||
| ```sql+sqlite | ||||
| select | ||||
| time, | ||||
| event_names, | ||||
| ip_address | ||||
| from | ||||
| googleworkspace_admin_reports_activity | ||||
| where | ||||
| application_name = 'login' | ||||
| and actor_email = '[email protected]' | ||||
| and event_name = 'login_failure' | ||||
| and time > datetime('now', '-1 week'); | ||||
| ``` | ||||
|
|
||||
| ### Show all connections from a new device | ||||
|
|
||||
| Identify all connections from a new device in the last week. | ||||
|
|
||||
| ```sql+postgres | ||||
| select | ||||
| time, | ||||
| actor_email, | ||||
| event_names, | ||||
| param1->>'value' as device_id, | ||||
| param2->>'value' as device_model, | ||||
| events | ||||
| from | ||||
| googleworkspace_admin_reports_activity as a | ||||
| cross join lateral jsonb_array_elements(a.events) as evt | ||||
| cross join lateral jsonb_array_elements(evt->'parameters') as param1 | ||||
| cross join lateral jsonb_array_elements(evt->'parameters') as param2 | ||||
| where | ||||
| application_name = 'mobile' | ||||
| and event_name = 'DEVICE_REGISTER_UNREGISTER_EVENT' | ||||
| and param1->>'name' = 'DEVICE_ID' | ||||
| and param2->>'name' = 'DEVICE_MODEL' | ||||
| and time > now() - interval '1 day'; | ||||
| ``` | ||||
|
|
||||
| ```sql+sqlite | ||||
| select | ||||
| time, | ||||
| actor_email, | ||||
| event_names, | ||||
| param1->>'value' as device_id, | ||||
| param2->>'value' as device_model, | ||||
| events | ||||
| from | ||||
| googleworkspace_admin_reports_activity as a | ||||
| cross join lateral jsonb_array_elements(a.events) as evt | ||||
| cross join lateral jsonb_array_elements(evt->'parameters') as param1 | ||||
| cross join lateral jsonb_array_elements(evt->'parameters') as param2 | ||||
| where | ||||
| application_name = 'mobile' | ||||
| and event_names = 'DEVICE_REGISTER_UNREGISTER_EVENT' | ||||
| and param1->>'name' = 'DEVICE_ID' | ||||
| and param2->>'name' = 'DEVICE_MODEL' | ||||
| and time > datetime('now', '-1 day'); | ||||
| ``` | ||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.