Skip to content

Commit 0ee694d

Browse files
committed
Ship logs directly to CWLogs
1 parent 91d7de9 commit 0ee694d

File tree

7 files changed

+41
-12
lines changed

7 files changed

+41
-12
lines changed

pulumi/bootstrap/bootstrap.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
# Map of template files to target files
1515
TEMPLATE_MAP = {
16+
'fluent-bit.service.j2': '/usr/lib/systemd/system/fluent-bit.service',
1617
'fluent-bit.yaml.j2': '/etc/fluent-bit/fluent-bit.yaml',
1718
'stalwart.toml.j2': '/opt/stalwart/etc/config.toml',
1819
'thundermail.service.j2': '/usr/lib/systemd/system/thundermail.service',
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=Fluent Bit
3+
Documentation=https://docs.fluentbit.io/manual/
4+
Requires=network.target
5+
After=network.target
6+
7+
[Service]
8+
Type=simple
9+
Environment="ENV={{ env }}"
10+
ExecStart=/opt/fluent-bit/bin/fluent-bit -c /etc/fluent-bit/fluent-bit.yaml
11+
Restart=always
12+
13+
[Install]
14+
WantedBy=multi-user.target

pulumi/bootstrap/templates/fluent-bit.yaml.j2

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,25 @@ pipeline:
2121
filters: []
2222

2323
outputs:
24-
- name: forward
25-
match: '*'
26-
{%- if env == 'prod' %}
27-
host: fluentbit.tb.pro
28-
{%- else %}
29-
host: {{ 'fluentbit-' + env + '.tb.pro' }}
30-
{%- endif %}
31-
port: 24224
24+
# Send logs onward to CloudWatch. Log groups by the derived name must pre-exist, and this
25+
# service must have sufficient IAM permissions to create log streams and post events to them.
26+
- name: cloudwatch_logs
27+
match: cloudwatch.stalwart.mail
28+
log_group_name: /tb/${ENV}/stalwart
29+
log_stream_name: mail
30+
region: eu-central-1
31+
log_key: MESSAGE
32+
33+
- name: cloudwatch_logs
34+
match: cloudwatch.stalwart.api
35+
log_group_name: /tb/${ENV}/stalwart
36+
log_stream_name: api
37+
region: eu-central-1
38+
log_key: MESSAGE
39+
40+
- name: cloudwatch_logs
41+
match: cloudwatch.untagged
42+
log_group_name: /tb/${ENV}/stalwart
43+
log_stream_name: untagged
44+
region: eu-central-1
45+
log_key: MESSAGE

pulumi/config.dev.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ resources:
1515
log_streams:
1616
api: api
1717
mail: mail
18+
untagged: untagged
1819
org_name: tb
1920

2021
tb:network:MultiTierVpc:

pulumi/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Jinja2>=3.1,<4.0
22
pulumi_cloudflare==6.6.0
3-
tb_pulumi @ git+https://github.com/thunderbird/pulumi.git@main
3+
# tb_pulumi @ git+https://github.com/thunderbird/pulumi.git@main
4+
-e /home/rjung/workspace/thunderbird/pulumi
45
toml>=0.10.2,<0.11

pulumi/stalwart/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,7 @@ def user_data(self):
825825
archive_file_base = './bootstrap'
826826
archive_files = [
827827
'bootstrap.py',
828+
'templates/fluent-bit.service.j2',
828829
'templates/fluent-bit.yaml.j2',
829830
'templates/ports.j2',
830831
'templates/stalwart.toml.j2',

pulumi/stalwart_instance_user_data.sh.j2

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ dnf install -y bzip2 docker fluent-bit python3.12
2828
# Delete the default fluent-bit config; we'll template a new one in Phase 2
2929
rm -f /etc/fluent-bit/fluent-bit.conf
3030

31-
# Make sure fluent-bit uses the right config file
32-
sed -i 's/fluent-bit.conf/fluent-bit.yaml/' /usr/lib/systemd/system/fluent-bit.service
33-
3431
# Set up Stalwart config directory and virtual environment
3532
mkdir -p $STALWART_DIR/etc
3633
python3.12 -m ensurepip

0 commit comments

Comments
 (0)