Skip to content

Commit

Permalink
Merge pull request #3372 from aleksandrychev/auditlogs
Browse files Browse the repository at this point in the history
ENT-11977: Updated Audit log API documentation
  • Loading branch information
nickanderson authored Dec 12, 2024
2 parents 3d15069 + 740b5ce commit fd69cbe
Showing 1 changed file with 83 additions and 21 deletions.
104 changes: 83 additions & 21 deletions api/enterprise-api-ref/audit-logs-api.markdown
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
layout: default
title: Audit logs API
title: Audit log API
published: true
---

Audit logs API provides access to system audit logs that track user actions across the platform made to critical parts
Audit log API provides access to system audit logs that track user actions across the platform made to critical parts
such as settings, host data, users, roles, Build projects, etc.

## Get audit logs

**URI:** https://hub.cfengine.com/api/audit-logs
**URI:** https://hub.cfengine.com/api/audit-log

**Method:** GET

Expand All @@ -18,9 +18,11 @@ such as settings, host data, users, roles, Build projects, etc.
* **actor** *(string)*
Filter by user who performed the action.
* **object_type** *(string)*
Filter by object type (see [Allowed object types][Audit logs API#Allowed object types]).
Filter by object type (see [Allowed object types][Audit log API#Allowed object types]).
* **action** *(string)*
Filter by action type (see [Allowed actions][Audit logs API#Allowed actions]).
Filter by action type (see [Allowed actions][Audit log API#Allowed actions]).
* **object_name** *(integer)*
Filter by object name.
* **created_after** *(integer)*
Unix timestamp to filter logs after this time.
* **created_before** *(integer)*
Expand All @@ -35,6 +37,7 @@ such as settings, host data, users, roles, Build projects, etc.
* actor
* action
* object_id
* object_name
* object_type
* **sort_direction** *(string, default: "DESC")*
Sort direction. Allowed values:
Expand All @@ -44,7 +47,7 @@ such as settings, host data, users, roles, Build projects, etc.
**Example request (curl):**

```console
curl --user <username>:<password> -X GET https://hub.cfengine.com/api/audit-logs
curl --user <username>:<password> -X GET https://hub.cfengine.com/api/audit-log
```

**Successful response example:**
Expand All @@ -59,6 +62,7 @@ HTTP 200 OK
"actor": "admin",
"action": "created",
"object_type": "user",
"object_name": "test",
"object_id": "test",
"details": [
"Created user `test`."
Expand All @@ -69,6 +73,7 @@ HTTP 200 OK
"time": "2024-10-24 09:46:56.204391",
"actor": "admin",
"action": "created",
"object_name": "test",
"object_type": "role",
"object_id": "test",
"details": [
Expand All @@ -86,6 +91,7 @@ HTTP 200 OK
"actor": "admin",
"action": "updated",
"object_type": "settings",
"object_name": "Preferences",
"object_id": null,
"details": [
"Settings updated.",
Expand Down Expand Up @@ -121,15 +127,15 @@ HTTP 200 OK

| Action | Description |
|----------------------|---------------------------|
| created | Resource creation |
| updated | Resource update |
| deleted | Resource deletion |
| deployed | Deployment action |
| pushed | Push action |
| module added | Module addition |
| module deleted | Module removal |
| module updated | Module modification |
| module input updated | Module input modification |
| Created | Resource creation |
| Updated | Resource update |
| Deleted | Resource deletion |
| Deployed | Deployment action |
| Pushed | Push action |
| Module added | Module addition |
| Module deleted | Module removal |
| Module updated | Module modification |
| Module input updated | Module input modification |
| CMDB updated | CMDB update |
| CMDB deleted | CMDB deletion |
| CMDB created | CMDB creation |
Expand All @@ -139,10 +145,66 @@ HTTP 200 OK

| Object Type | Description |
|---------------------|----------------------------------------------|
| user | User account |
| role | Role definition |
| settings | System, Mail, VCS or Authentication settings |
| federated reporting | Federated reporting configuration |
| group | Host groups |
| host | Host configuration |
| User | User account |
| Role | Role definition |
| Settings | System, Mail, VCS or Authentication settings |
| Federated reporting | Federated reporting configuration |
| Group | Host groups |
| Host | Host configuration |
| Build project | Build project configuration |


## Get audit logs actors

Returns list of users who performed actions.

**URI:** https://hub.cfengine.com/api/audit-log/actors

**Method:** GET

**Example request (curl):**

```console
curl --user <username>:<password> -X GET https://hub.cfengine.com/api/audit-log/actors
```

**Successful response example:**

```
HTTP 200 OK
[
"admin",
"test"
]
```

## Get audit logs object name by type

Returns list of object names filtered by type.

**URI:** https://hub.cfengine.com/api/audit-log/:type/names

**Method:** GET

**Parameters:**

* **object_type** *(string)*
Filter by object type (see [Allowed object types][Audit log API#Allowed object types]).

**Example request (curl):**

```console
curl --user <username>:<password> -X GET https://hub.cfengine.com/api/audit-log/Settings/names
```

**Successful response example:**

```
HTTP 200 OK
[
"Preferences",
"Mail",
"VCS",
"Authentication",
]
```

0 comments on commit fd69cbe

Please sign in to comment.