Created
August 31, 2017 20:01
-
-
Save coingraham/7ed296b69e1104b5d2b1a3f07aecfe83 to your computer and use it in GitHub Desktop.
Athena SQL
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
| SELECT | |
| eventtime, | |
| CASE | |
| when useridentity.type = 'IAMUser' then useridentity.username | |
| when useridentity.type = 'Root' then useridentity.invokedby | |
| when useridentity.type = 'AssumedRole' then useridentity.arn | |
| ELSE | |
| 'undefined' | |
| END as "userid", | |
| sourceipaddress, | |
| eventname, | |
| json_extract_scalar( requestparameters, '$.name' ) as "hostname", | |
| json_extract_scalar( requestparameters, '$.instances.slaveInstanceType' ) as "slave", | |
| json_extract_scalar( requestparameters, '$.instances.instanceGroups' ) as "instancegroups", | |
| json_extract_scalar( requestparameters, '$.instances.instanceGroups[0].instanceType' ) as "instancegrouptype0", | |
| json_extract_scalar( requestparameters, '$.instances.instanceGroups[1].instanceType' ) as "instancegrouptype1", | |
| json_extract_scalar( requestparameters, '$.instances.instanceGroups[2].instanceType' ) as "instancegrouptype2", | |
| errorcode, | |
| errormessage | |
| FROM cloudtrail_logs_2017 | |
| WHERE eventsource = 'elasticmapreduce.amazonaws.com' | |
| AND eventname in ('RunJobFlow') | |
| AND useridentity.username = 'pipeline-controller' | |
| ORDER BY eventtime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment