diff --git a/README.md b/README.md index 8b5da3d..1eb4fbb 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,8 @@ docker run -d -p 5000:5000 --restart=always --name registry -v //c/registry/auth ``` docker run --restart always -p 8055:8080 -d -v "//c/bpers/log:/opt/jboss/wildfly/standalone/log" -v "//c/bpers/data:/opt/jboss/wildfly/standalone/data" -v "//c/bpers/configuration:/opt/jboss/wildfly/standalone/configuration/security" --name bpers IP_SERVIDOR:5000/bpers:latest ``` + + +## Docker-Compose + +`docker-compose up` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1f7cfbb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,50 @@ +version: "3.2" +services: + agreggrator: + build: ./fluentd + ports: + - "24224:24224" + - "24224:24224/udp" + volumes: + - ./fluentd/fluent.conf:/fluentd/etc/fluent.conf + - //x/volumes/bpers/data:/dados/ + elasticsearch: + image: docker.elastic.co/elasticsearch/elasticsearch:7.3.2 + environment: + - discovery.type=single-node + - bootstrap.memory_lock=true + - "ES_JAVA_OPTS=-Xms1g -Xmx1g" + user: 'elasticsearch' + volumes: + - elasticsearch-data:/usr/share/elasticsearch/data + ulimits: + memlock: + soft: -1 + hard: -1 + nofile: + soft: 65536 + hard: 65536 + ports: + - "9200:9200" + kibana: + image: docker.elastic.co/kibana/kibana:7.3.2 + links: + - elasticsearch + ports: + - "5601:5601" + environment: + - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 + depends_on: + - elasticsearch + bpers: + image: localhost:5000/bpers:255 + ports: + - 8055:8080 + volumes: + - //x/volumes/bpers/log:/opt/jboss/wildfly/standalone/log + - //x/volumes/bpers/data:/opt/jboss/wildfly/standalone/data + - //x/volumes/bpers/configuration:/opt/jboss/wildfly/standalone/configuration/security + restart: on-failure + +volumes: + elasticsearch-data: \ No newline at end of file diff --git a/fluentd/Dockerfile b/fluentd/Dockerfile new file mode 100644 index 0000000..eb554e7 --- /dev/null +++ b/fluentd/Dockerfile @@ -0,0 +1,18 @@ +FROM fluent/fluentd:v1.5-1 + +# Use root account to use apk +USER root + +RUN apk add --no-cache --update geoip-dev \ + && apk add --no-cache --update --virtual .build-deps build-base ruby-dev \ + && echo 'gem: --no-document' >> /etc/gemrc \ + && gem install fluent-plugin-elasticsearch fluent-plugin-woothee fluent-plugin-ua-parser fluent-plugin-geoip-filter fluent-plugin-multi-format-parser \ + && gem sources --clear-all \ + && apk del .build-deps \ + && rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem + +COPY fluent.conf /fluentd/etc/ +COPY entrypoint.sh /bin/ + +ENV FLUENT_UID=0 +#USER fluent \ No newline at end of file diff --git a/fluentd/entrypoint.sh b/fluentd/entrypoint.sh new file mode 100644 index 0000000..0850ff1 --- /dev/null +++ b/fluentd/entrypoint.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +#source vars if file exists +DEFAULT=/etc/default/fluentd + +if [ -r $DEFAULT ]; then + set -o allexport + . $DEFAULT + set +o allexport +fi + +# If the user has supplied only arguments append them to `fluentd` command +if [ "${1#-}" != "$1" ]; then + set -- fluentd "$@" +fi + +# If user does not supply config file or plugins, use the default +if [ "$1" = "fluentd" ]; then + if ! echo $@ | grep ' \-c' ; then + set -- "$@" -c /fluentd/etc/${FLUENTD_CONF} + fi + + if ! echo $@ | grep ' \-p' ; then + set -- "$@" -p /fluentd/plugins + fi +fi + +exec "$@" \ No newline at end of file diff --git a/fluentd/fluent.conf b/fluentd/fluent.conf new file mode 100644 index 0000000..36aa308 --- /dev/null +++ b/fluentd/fluent.conf @@ -0,0 +1,46 @@ + + @type forward + port 24224 + bind 0.0.0.0 + tag bpe + + + + @type parser + format /^(? + + + @type copy + + @type elasticsearch + host elasticsearch + port 9200 + logstash_format true + logstash_prefix bpe + logstash_dateformat %Y%m%d + include_tag_key true + tag_key @log_name + flush_interval 1s + + + #@type memory # file #or memory + @type file + path /tmp/fluentd*.buffer + flush_mode interval + retry_type exponential_backoff + flush_thread_count 4 + flush_interval 1s + retry_forever + retry_max_interval 30 + chunk_limit_size 2M + queue_limit_length 8 + overflow_action block + + + + @type stdout + + \ No newline at end of file