搭建EFK

作者: cain_li | 来源:发表于2018-11-22 15:31 被阅读0次

    参见 fluentd官方集成docker-logging-efk-compose

    docker-compose-efk
        ├── docker-compose.yml
        ├── fluentd
             ├── Dockerfile
             └── conf
                └── fluent.conf
    

    docker-compose.yml

    version: '2'
    services:
      web:
        image: httpd
        ports:
          - "8080:80"
        links:
          - fluentd
        logging:
          driver: "fluentd"
          options:
            fluentd-address: localhost:24224
            tag: httpd.access
    
      fluentd:
        build: ./fluentd
        volumes:
          - ./fluentd/conf:/fluentd/etc
        links:
          - "elasticsearch:elasticsearch"
        ports:
          - "24224:24224"
          - "24224:24224/udp"
    
      elasticsearch:
        image: elasticsearch:5.6.12
        expose:
          - 9200
        ports:
          - "9200:9200"
    
      kibana:
        image: kibana:5.6.12
        links:
          - "elasticsearch"
        ports:
          - "5601:5601"
    

    fluentd/Dockerfile

    FROM fluent/fluentd:v0.12.43
    RUN ["gem", "sources", "--remove", "https://rubygems.org/"]
    RUN ["gem", "sources", "-a", "http://gems.ruby-china.com/"]
    RUN ["gem", "install", "fluent-plugin-elasticsearch","--no-rdoc", "--no-ri", "--version", "1.9.2"]
    

    fluentd/conf/fluent.conf

    <source>
      @type forward
      port 24224
      bind 0.0.0.0
    </source>
    <match *.**>
      @type copy
      <store>
        @type elasticsearch
        host elasticsearch
        port 9200
        logstash_format true
        logstash_prefix fluentd
        logstash_dateformat %Y%m%d
        include_tag_key true
        type_name access_log
        tag_key @log_name
        flush_interval s
      </store>
      <store>
        @type stdout
      </store>
    </match>
    

    用个例子验证下
    example/httpd.yml

    version: '2'
    services:
      web:
        image: httpd:2.2.32
        ports:
          - "80:80"
        depends_on:
          - fluentd
        logging:
          driver: "fluentd"
          options:
            fluentd-address: localhost:24224
            tag: httpd.access
    

    相关文章

      网友评论

          本文标题:搭建EFK

          本文链接:https://www.haomeiwen.com/subject/jiplqqtx.html