Skip to content

Commit

Permalink
Add documentation for the Audit Log GraphQL API
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Rockwood <[email protected]>
  • Loading branch information
benr committed Mar 22, 2024
1 parent d2e9164 commit 798ba88
Showing 1 changed file with 117 additions and 0 deletions.
117 changes: 117 additions & 0 deletions docs/platform/maintain/log.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,123 @@ Mondoo tracks administrative events, such as organization and access management

3. Select **Audit Log**.

## Using the Audit Log API

Organization audit logs are available via our GraphQL API. To access the API, you must have created an [API key](/platform/maintain/access/api-keys).

The GraphQL query to get the audit log for an organization is:

```
{
"variables": {
"first": 25,
"resourceMrn": "//captain.api.mondoo.app/organizations/<REPLACE_WITH_ORGANIZATION_ID>"
},
"query": "query AuditLogForwardPagination($first: Int, $after: String, $orderBy: AuditLogOrder = {direction: DESC, field: TIMESTAMP}, $resourceMrn: String!) {
auditlog(

Check failure on line 51 in docs/platform/maintain/log.mdx

View workflow job for this annotation

GitHub Actions / Run spell check

`auditlog` is not a recognized word. (unrecognized-spelling)
first: $first
after: $after
orderBy: $orderBy
resourceMrn: $resourceMrn
) {
totalCount
edges {
cursor
node {
identity {
name
mrn
}
resource
action
timestamp
msg
}
}
pageInfo {
startCursor
endCursor
hasNextPage
}
}
}"
}
```

To test this using cURL, store the query in file named "query.json" and execute like so, being sure to have sepcified your organization ID in the query:

Check failure on line 81 in docs/platform/maintain/log.mdx

View workflow job for this annotation

GitHub Actions / Run spell check

`sepcified` is not a recognized word. (unrecognized-spelling)

```
$ cat query.json
{
"variables": {
"first": 25,
"resourceMrn": "//captain.api.mondoo.app/organizations/<REPLACE_WITH_ORGANIZATION_ID>"
},
"query": "query AuditLogForwardPagination($first: Int, $after: String, $orderBy: AuditLogOrder = {direction: DESC, field: TIMESTAMP}, $resourceMrn: String!) {
auditlog(
first: $first
after: $after
orderBy: $orderBy
resourceMrn: $resourceMrn
) {
totalCount
edges {
cursor
node {
identity {
name
mrn
}
resource
action
timestamp
msg
}
}
pageInfo {
startCursor
endCursor
hasNextPage
}
}
}"
}
$ curl -g -X POST -H "Authorization: Bearer $API_TOKEN" -H "Content-Type: application/json" -d @query.json https://api.edge.mondoo.com/query | jq
{
"data": {
"auditlog": {
"totalCount": 36,
"edges": [
{
"cursor": "172213",
"node": {
"identity": {
"name": "Jane Doe",
"mrn": "//captain.api.mondoo.app/users/26OR1GOGsqmfjXOOO8joxgJDdtM"

Check failure on line 131 in docs/platform/maintain/log.mdx

View workflow job for this annotation

GitHub Actions / Run spell check

`Gsqmfj` is not a recognized word. (unrecognized-spelling)

Check failure on line 131 in docs/platform/maintain/log.mdx

View workflow job for this annotation

GitHub Actions / Run spell check

`JDdt` is not a recognized word. (unrecognized-spelling)

Check failure on line 131 in docs/platform/maintain/log.mdx

View workflow job for this annotation

GitHub Actions / Run spell check

`joxg` is not a recognized word. (unrecognized-spelling)

Check failure on line 131 in docs/platform/maintain/log.mdx

View workflow job for this annotation

GitHub Actions / Run spell check

`XOOO` is not a recognized word. (unrecognized-spelling)
},
"resource": "//agents.api.mondoo.app/organizations/mondoo-organization-1/serviceaccounts/2e3NzLkD73yQe7MTJZLw3",

Check failure on line 133 in docs/platform/maintain/log.mdx

View workflow job for this annotation

GitHub Actions / Run spell check

`MTJZLw` is not a recognized word. (unrecognized-spelling)
"action": "mondoo.agents.AgentManager.CreateServiceAccount",
"timestamp": "2024-03-22T17:46:03Z",
"msg": "created service account"
}
},
{
"cursor": "143156",
"node": {
"identity": {
"name": "John Smith",
"mrn": "//captain.api.mondoo.app/users/1zYNjiRERS59LsS8iCloxPxbxLo"

Check failure on line 144 in docs/platform/maintain/log.mdx

View workflow job for this annotation

GitHub Actions / Run spell check

`Clox` is not a recognized word. (unrecognized-spelling)

Check failure on line 144 in docs/platform/maintain/log.mdx

View workflow job for this annotation

GitHub Actions / Run spell check

`Pxbx` is not a recognized word. (unrecognized-spelling)

Check failure on line 144 in docs/platform/maintain/log.mdx

View workflow job for this annotation

GitHub Actions / Run spell check

`RERS` is not a recognized word. (unrecognized-spelling)
},
"resource": "//captain.api.mondoo.app/users/2AdPauBAGEqnOjIFXx6AIyWrhxh",
"action": "mondoo.captain.Captain.SetOrganizationMembership",
"timestamp": "2024-01-30T00:01:04Z",
"msg": "owner added"
}
},
...
```

## Get help

Can't find what you need? Join our <a href="https://mondoo.link/slack">community Slack channel</a> to chat with us and other Mondoo users.
Expand Down

0 comments on commit 798ba88

Please sign in to comment.