Skip to content

Instantly share code, notes, and snippets.

@jonico
Created June 6, 2019 22:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jonico/abf33f4bf642bdceca197b9e0ee1de15 to your computer and use it in GitHub Desktop.
Save jonico/abf33f4bf642bdceca197b9e0ee1de15 to your computer and use it in GitHub Desktop.
How to query GitHub's audit log with GraphQL
query {
organization(login: "se-saml") {
auditLog(first: 50) {
edges {
node {
... on RepositoryAuditEntryData {
repository {
name
}
}
... on OrganizationAuditEntryData {
organization {
name
}
}
... on TeamAuditEntryData {
teamName
}
... on BusinessAuditEntryData {
businessUrl
}
... on OauthApplicationAuditEntryData {
oauthApplicationName
}
... on AuditEntry {
actorResourcePath
action
actorIp
actorLogin
createdAt
actorLocation {
countryCode
country
regionCode
region
city
}
}
}
cursor
}
}
}
}
@jonico
Copy link
Author

jonico commented Jun 6, 2019

In order for this to work, you need to add an Accept-Header with value application/vnd.github.audit-log-preview+json

@brianamarie
Copy link

I've opened a pull request to add this to platform-samples: github/platform-samples#262

@kishankg
Copy link

Thank you for the detailed query. I wanted to know How can I search for specific log like RepositoryVisibilityChangeEnableAuditEntry and RepositoryVisibilityChangeEnableAuditEntry?

@satyajitbaral
Copy link

@jonico This query doesn't show action:repo.rename events. Any possible way I could include those?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment