Skip to content
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

Audit log updates -> 3.25 #3373

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
]
```