collect docker logs using fluent
This commit is contained in:
parent
c59dcbeaae
commit
db38d9c6bb
4 changed files with 35 additions and 3 deletions
|
@ -17,7 +17,17 @@
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- setup_apt
|
- 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
|
- name: Setup Docker Swarm manager
|
||||||
hosts: manager
|
hosts: manager
|
||||||
|
|
|
@ -122,7 +122,7 @@ services:
|
||||||
- BAUTH_PASS=test
|
- BAUTH_PASS=test
|
||||||
|
|
||||||
fluentd:
|
fluentd:
|
||||||
image: git.kun.is/pim/fluentd:1.0.1
|
image: git.kun.is/pim/fluentd:1.0.2
|
||||||
depends_on:
|
depends_on:
|
||||||
- elasticsearch
|
- elasticsearch
|
||||||
ports:
|
ports:
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
port {{ fluent_forward_port }}
|
port {{ fluent_forward_port }}
|
||||||
</source>
|
</source>
|
||||||
|
|
||||||
<match *>
|
<match **>
|
||||||
@type elasticsearch
|
@type elasticsearch
|
||||||
host maestro.dmz
|
host maestro.dmz
|
||||||
port {{ elasticsearch_port }}
|
port {{ elasticsearch_port }}
|
||||||
|
|
|
@ -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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Reference in a new issue