Есть задача - вывести определенный докер логи с определенными индексами на сервер через ELK используя контейнеры docker-compose
Сделала примерную сборку, собрала её
version: "2.4"
services:
elasticsearch:
image: elasticsearch:7.9.1
container_name: elasticsearch
hostname: elasticsearch
restart: unless-stopped
ports:
- "9200:9200"
volumes:
- type: volume
source: elasticsearch_data
target: /usr/share/elasticsearch/data
environment:
- "node.name=elasticsearch"
- "bootstrap.memory_lock=true"
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
- "xpack.monitoring.enabled=true"
- "xpack.ml.enabled=false"
- "xpack.graph.enabled=false"
- "xpack.watcher.enabled=false"
- discovery.type=single-node
ulimits:
memlock:
soft: -1
hard: -1
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "2"
filebeat:
build: filebeat
container_name: filebeat
hostname: mydockerhost
restart: unless-stopped
environment:
- ELASTICSEARCH_HOSTS=elasticsearch:9200
labels:
co.elastic.logs/enabled: "false"
volumes:
- type: bind
source: /var/run/docker.sock
target: /var/run/docker.sock
- type: bind
source: /var/lib/docker
target: /var/lib/docker
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "2"
kibana:
image: kibana:7.9.1
container_name: kibana
restart: unless-stopped
environment:
- 'ELASTICSEARCH_HOSTS=["http://elasticsearch:9200"]'
- "SERVER_NAME=localhost"
- "XPACK_MONITORING_ENABLED=false"
ports:
- "5601:5601"
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "2"
volumes:
elasticsearch_data:
Создала filebeat
filebeat.config:
modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: false
filebeat.autodiscover:
providers:
- type: docker
hints.enabled: true
templates:
- condition:
equals:
docker.network.name: "*"
config:
- type: container
paths:
- '/var/lib/docker/containers/${data.docker.container.id}/*.log'
json.keys_under_root: true
json.add_error_key: true
json.message_key: log
processors:
- add_cloud_metadata: ~
- decode_json_fields:
fields: ["log"]
target: ""
output.elasticsearch:
hosts: '${ELASTICSEARCH_HOSTS:elasticsearch:9200}'
setup.ilm:
setup.ilm.enabled: auto
setup.ilm.rollover_alias: "filebeat"
setup.ilm.pattern: "{now/d}-000001"
С этой конфигурацией выводит все логи и все индексы. Как их ограничить? Нужно ли для этого использовать logstash?