Skip to content

Commit 7ecceaf

Browse files
authored
Merge pull request #11 from vectordotdev/redaction-example
Add simple redaction example
2 parents ebf47fb + 135aed0 commit 7ecceaf

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

aggregator/docker-compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ services:
88
- ./vector/agent/http:/etc/vector:ro
99
depends_on:
1010
- aggregator
11+
transaction_logs_agent:
12+
image: timberio/vector:nightly-alpine
13+
deploy:
14+
replicas: 3
15+
volumes:
16+
- ./vector/agent/transaction:/etc/vector:ro
17+
depends_on:
18+
- aggregator
1119
syslog_logs_agent:
1220
image: timberio/vector:nightly-alpine
1321
deploy:
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[sources.logs]
2+
type = "generator"
3+
format = "shuffle"
4+
lines = [
5+
'{"transaction":{"id":"d71dc34a-ff0c-4708-afb3-bed232ac879e","result":"success"},"user":{"username":"victory1337","email":"[email protected]"}}',
6+
'{"transaction":{"id":"1251afbc-481a-45a1-abe4-caa3a9dfc2b3","result":"cancel"},"user":{"username":"socrates21","email":"[email protected]"}}'
7+
]
8+
interval = 2
9+
10+
[transforms.tag]
11+
type = "remap"
12+
inputs = ["logs"]
13+
source = '''
14+
.tag = "transaction_logs"
15+
'''
16+
17+
[sinks.out]
18+
type = "vector"
19+
inputs = ["tag"]
20+
address = "aggregator:9000"
21+
version = "2"
22+
23+
[sinks.out.healthcheck]
24+
enabled = true

aggregator/vector/aggregator/vector.toml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,23 @@ inputs = ["*_agents"]
1818

1919
[transforms.logs_router.route]
2020
http_logs = '.tag == "http_logs"'
21+
transaction_logs = '.tag == "transaction_logs"'
2122
syslog_logs = '.tag == "syslog_logs"'
2223
fluent_bit_logs = '.tag == "fluent_bit_logs"'
2324

25+
[transforms.redact_transaction_logs]
26+
type = "remap"
27+
inputs = ["logs_router.transaction_logs"]
28+
source = '''
29+
# Parse JSON string
30+
. = parse_json!(.message)
31+
32+
# Apply email address redaction filter
33+
. = redact(., filters: [
34+
r'(\w+)@(\w+).(\w+)'
35+
])
36+
'''
37+
2438
[transforms.parse_and_sanitize_http_logs]
2539
type = "remap"
2640
inputs = ["logs_router.http_logs"]
@@ -95,7 +109,7 @@ condition = 'to_syslog_severity!(.severity) < 4'
95109

96110
[sinks.json_out]
97111
type = "console"
98-
inputs = ["filter_*", "parse_and_sanitize_fluent_bit_logs"]
112+
inputs = ["filter_*", "parse_and_sanitize_fluent_bit_logs", "redact_transaction_logs"]
99113
target = "stdout"
100114

101115
[sinks.json_out.encoding]

0 commit comments

Comments
 (0)