Skip to content

Commit 871e387

Browse files
Gateway audit logs (#596)
* Start drafting, add sources.yaml sources Signed-off-by: Diana <[email protected]> * Finish drafting audit log page Signed-off-by: Diana <[email protected]> * Fix broken link Signed-off-by: Diana <[email protected]> * Add tags, add note about SIEM Signed-off-by: Diana <[email protected]> * Apply suggestions from code review Co-authored-by: Lucie Milan <[email protected]> * Fix payload section Signed-off-by: Diana <[email protected]> * apply feedback Co-authored-by: Lucie Milan <[email protected]> --------- Signed-off-by: Diana <[email protected]> Co-authored-by: Lucie Milan <[email protected]>
1 parent 9630b54 commit 871e387

File tree

5 files changed

+169
-6
lines changed

5 files changed

+169
-6
lines changed
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Sign {{site.base_gateway}} audit logs with an RSA key
3+
content_type: how_to
4+
related_resources:
5+
- text: "{{site.base_gateway}} logs"
6+
url: /gateway/logs/
7+
8+
products:
9+
- gateway
10+
11+
works_on:
12+
- on-prem
13+
14+
min_version:
15+
gateway: '3.4'
16+
17+
entities:
18+
- vault
19+
20+
tags:
21+
- logging
22+
23+
tldr:
24+
q: How do I
25+
a: placeholder
26+
27+
tools:
28+
- deck
29+
30+
31+
cleanup:
32+
inline:
33+
- title: Destroy the {{site.base_gateway}} container
34+
include_content: cleanup/products/gateway
35+
icon_url: /assets/icons/gateway.svg
36+
---
37+
38+
@todo
39+
40+
Use content from https://docs.konghq.com/gateway/latest/kong-enterprise/audit-log/#digital-signatures

app/_landing_pages/gateway/security.yaml

+12-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ rows:
8585
8686
icon: /assets/icons/team.svg
8787
cta:
88-
url: "/konnect/teams-and-roles/"
88+
url: "/teams-and-roles/"
8989
- blocks:
9090
- type: card
9191
config:
@@ -156,6 +156,16 @@ rows:
156156
icon: /assets/icons/logs.svg
157157
cta:
158158
url: "/gateway/logs/"
159+
- blocks:
160+
- type: card
161+
config:
162+
title: "{{site.base_gateway}} audit logs"
163+
description: |
164+
Audit logs provides details for HTTP requests handled by the Admin API as well as database changes.
165+
166+
icon: /assets/icons/audit.svg
167+
cta:
168+
url: "/gateway/audit-logs/"
159169
- blocks:
160170
- type: card
161171
config:
@@ -165,7 +175,7 @@ rows:
165175
166176
icon: /assets/icons/audit.svg
167177
cta:
168-
url: "/konnect/audit-logs/"
178+
url: "/audit-logs/"
169179
- blocks:
170180
- type: card
171181
config:

app/audit-logs.md

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ description: placeholder
1111
related_resources:
1212
- text: "Secure {{site.base_gateway}}"
1313
url: /gateway/security/
14+
- text: "{{site.base_gateway}} audit logs"
15+
url: /gateway/audit-logs/
16+
- text: "{{site.base_gateway}} logs"
17+
url: /gateway/logs/
1418
---
1519

1620
@todo

app/gateway/audit-logs.md

+111-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ layout: reference
66
products:
77
- gateway
88

9+
tags:
10+
- logging
11+
- audit-logging
12+
913
min_version:
10-
gateway: '3.5'
14+
gateway: '3.4'
1115

1216
description: placeholder
1317

@@ -18,10 +22,113 @@ related_resources:
1822
url: /gateway/logs/
1923
- text: "{{site.base_gateway}} debugging"
2024
url: /gateway/debug/
25+
- text: "{{site.konnect_short_name}} audit logs"
26+
url: /audit-logs/
2127
---
2228

23-
@todo
29+
You can generate {{site.base_gateway}} audit logs using the Admin API and the data is written to {{site.base_gateway}}'s database. Audit logs provide details about HTTP requests handled by the Admin API as well as database changes. This allows cluster administrators to keep track of changes made to the cluster configuration throughout its lifetime, aiding in compliance efforts and providing valuable data points during forensic investigations.
30+
31+
Because every audit log entry is made available via {{site.base_gateway}}’s Admin API, you can send audit log entries into existing logging warehouses, SIEM solutions, or other remote services for duplication and inspection.
32+
33+
## What type of events are included in audit logs?
34+
35+
{{site.base_gateway}} includes details about the following in audit logs:
36+
37+
| Event | Relevant audit log fields | Admin API endpoint | Description |
38+
|-------|------------------|--------------------|-------------|
39+
| [RBAC](/gateway/entities/rbac/) | `rbac_user_id`<br>`rbac_user_name` | [`/audit/requests`](/api/gateway/admin-ee/#/operations/get-audit-requests) | When RBAC is enforced, the RBAC user’s UUID will be written to the `rbac_user_id` field in the audit log entry, and the username will be written to the `rbac_user_name` field. |
40+
| [Workspace](/gateway/entities/workspace/) | `workspace` | [`/audit/requests`](/api/gateway/admin-ee/#/operations/get-audit-requests) | The `workspace` field is the UUID of the Workspace with which the request is associated. |
41+
| [Kong Manager login](/gateway/kong-manager/) | `"request_source": "kong-manager"`<br>`"method": "GET", "path": "/auth"` | [`/audit/requests`](/api/gateway/admin-ee/#/operations/get-audit-requests) | The `request_source` field tells you that the action occurred in Kong Manager, and the `GET` method and `/auth` path indicate a login event. |
42+
| [Kong Manager logout](/gateway/kong-manager/) | `"request_source": "kong-manager"`<br>`"method": "DELETE", "path": "/auth?session_logout=true"` | [`/audit/requests`](/api/gateway/admin-ee/#/operations/get-audit-requests) | The `DELETE` method and `/auth?session_logout=true` path indicate a logout event. |
43+
| Database entity changes | `payload` (contains changed objects)<br>`request_id` | [`/audit/objects`](/api/gateway/admin-ee/#/operations/get-audit-objects) | Entries for all insertions, updates, and deletions to the cluster database. Database update audit logs are also associated with Admin API request unique IDs. Object audit entries contain information about the entity updated, including the entity body itself, its database primary key, and the type of operation performed (create, update, or delete). It's also associated with the `request_id` field. |
44+
45+
## Enable audit logging
46+
47+
Audit logging is disabled by default. Configure it with the [`audit_log`](/gateway/configuration/#audit_log) {{site.base_gateway}} configuration in `kong.conf`:
48+
49+
```bash
50+
audit_log = on
51+
```
52+
53+
Or via environment variables:
54+
55+
```bash
56+
export KONG_AUDIT_LOG=on
57+
```
58+
59+
As with other Kong configurations, changes take effect on [`kong reload`](/how-to/restart-kong-gateway-container/) or `kong restart`.
60+
61+
## Disable audit logging for certain methods, paths, or database entities
62+
63+
You may want to ignore audit log generation for certain Admin API
64+
requests, such as requests to the `/status` endpoint for
65+
health checking, or to ignore requests to a specific path prefix, for example, a given Workspace.
66+
67+
Use the [`audit_log_ignore_methods`](/gateway/configuration/#audit_log_ignore_methods) and
68+
[`audit_log_ignore_paths`](/gateway/configuration/#audit_log_ignore_paths) configuration options:
69+
70+
```
71+
audit_log_ignore_methods = GET,OPTIONS
72+
# don't generate an audit log entry for GET or OPTIONS HTTP requests
73+
audit_log_ignore_paths = /foo,/status,^/services,/routes$,/one/.+/two,/upstreams/
74+
# don't generate an audit log entry for requests that match the above regular expressions
75+
```
76+
77+
As with request audit logs, you may want to skip generation of audit logs
78+
for certain database tables. This is configurable via the
79+
[`audit_log_ignore_tables`](/gateway/configuration/#audit_log_ignore_tables) Kong config option:
80+
81+
```
82+
audit_log_ignore_tables = consumers
83+
# don't generate database audit logs for changes to the Consumers table
84+
```
85+
86+
87+
The values of `audit_log_ignore_paths` are matched via a Perl-compatible regular expression.
88+
89+
For example, when you configure `audit_log_ignore_paths = /foo,/status,^/services,/routes$,/one/.+/two,/upstreams/`,
90+
the following request paths don't generate an audit log entry in the database:
91+
92+
- `/status`
93+
- `/status/`
94+
- `/foo`
95+
- `/foo/`
96+
- `/services`
97+
- `/services/example/`
98+
- `/one/services/two`
99+
- `/one/test/two`
100+
- `/routes`
101+
- `/plugins/routes`
102+
- `/one/routes/two`
103+
- `/upstreams/`
104+
- `bad400request`
105+
106+
The following request paths generate an audit log entry in the database:
107+
108+
- `/example/services`
109+
- `/routes/plugins`
110+
- `/one/two`
111+
- `/routes/`
112+
- `/upstreams`
113+
114+
115+
## Audit log retention
116+
117+
Audit log records are kept in the database for a duration defined by the
118+
[`audit_log_record_ttl`](/gateway/configuration/#audit_log_record_ttl)
119+
{{site.base_gateway}} configuration property. Records in the database older than the seconds configured in `audit_log_record_ttl` are automatically purged.
120+
121+
PostgreSQL purges records via the stored procedure that is executed on insert into the
122+
record database.
123+
Therefore, request audit records may exist in the database longer than the configured TTL
124+
if no new records are inserted to the audit table following the expiration timestamp.
125+
126+
## Sign audit logs with a private RSA key
127+
128+
To provide non-repudiation, audit logs may be signed with a private RSA key by using [`audit_log_signing_key`](/gateway/configuration/#audit_log_signing_key). When
129+
enabled, a lexically sorted representation of each audit log entry is signed by
130+
the defined private key; the signature is stored in an additional field within
131+
the record itself. The public key should be stored elsewhere and can be used
132+
later to validate the signature of the record. For more information, see [Sign {{site.base_gateway}} audit logs with an RSA key](/how-to/sign-gateway-audit-logs/).
24133

25-
Pull content from https://docs.konghq.com/gateway/latest/kong-enterprise/audit-log/
26134

27-
Be sure to add card for this to Gateway Security landing page

tools/track-docs-changes/config/sources.yml

+2
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,8 @@ app/gateway/resource-sizing-guidelines.md:
379379
- app/_src/gateway/production/sizing-guidelines.md
380380
app/gateway/secure-the-admin-api.md:
381381
- app/_src/gateway/production/running-kong/secure-admin-api.md
382+
app/gateway/audit-logs.md:
383+
- app/_src/gateway/kong-enterprise/audit-log.md
382384
app/gateway/performance/performance-benchmarks.md:
383385
- app/_src/gateway/production/performance/performance-testing.md
384386
app/ai-gateway/ai-audit-log-reference.md:

0 commit comments

Comments
 (0)