collect docker logs using fluent

This commit is contained in:
Pim Kunis 2023-08-22 22:53:40 +02:00
parent c59dcbeaae
commit db38d9c6bb
4 changed files with 35 additions and 3 deletions

View file

@ -17,7 +17,17 @@
roles:
- setup_apt
- docker
post_tasks:
- name: Install Docker
include_role:
name: docker
vars:
docker_daemon_config:
log-driver: fluentd
log-opts:
fluentd-address: "localhost:22222"
tag: "docker.{{ '{{' }}.Name{{ '}}' }}"
- name: Setup Docker Swarm manager
hosts: manager

View file

@ -122,7 +122,7 @@ services:
- BAUTH_PASS=test
fluentd:
image: git.kun.is/pim/fluentd:1.0.1
image: git.kun.is/pim/fluentd:1.0.2
depends_on:
- elasticsearch
ports:

View file

@ -6,7 +6,7 @@
port {{ fluent_forward_port }}
</source>
<match *>
<match **>
@type elasticsearch
host maestro.dmz
port {{ elasticsearch_port }}

View file

@ -38,3 +38,25 @@ resource "elasticstack_elasticsearch_index_template" "metrics_template" {
})
}
}
resource "elasticstack_elasticsearch_index_lifecycle" "logs_ilm" {
name = "logs_ilm"
delete {
min_age = "2d"
delete {}
}
}
resource "elasticstack_elasticsearch_index_template" "logs_template" {
name = "logs_template"
priority = 42
index_patterns = ["fluentd.docker.**"]
template {
settings = jsonencode({
"index.lifecycle.name" = elasticstack_elasticsearch_index_lifecycle.logs_ilm.name
})
}
}