Skip to content

Instantly share code, notes, and snippets.

@dictcp
Last active March 23, 2021 03:56
Show Gist options
  • Select an option

  • Save dictcp/e525b06e6e00f196fa79a260a8d84a7d to your computer and use it in GitHub Desktop.

Select an option

Save dictcp/e525b06e6e00f196fa79a260a8d84a7d to your computer and use it in GitHub Desktop.

Revisions

  1. dictcp revised this gist Mar 23, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,7 @@ docker-compose up -d
    docker-compose restart web

    docker-compose logs

    ## you will see the stdout from podinfo and go to fluentd stdout (due to the fluentd config), like
    ## fluentd_1 | 2021-03-23 03:51:58.000000000 +0000 7a3c12568bff: {"log":"Error to open config file, stat config.yaml: no such file or directory","container_id":"7a3c12568bff77f17a3909d63074401328af851e5d763a2b75b1e7e273c6ef33","container_name":"/test_web_1","source":"stdout"}
    ## fluentd_1 | 2021-03-23 03:51:58.000000000 +0000 7a3c12568bff: {"source":"stderr","log":"{\"level\":\"info\",\"ts\":\"2021-03-23T03:51:58.480Z\",\"caller\":\"podinfo/main.go:150\",\"msg\":\"Starting podinfo\",\"version\":\"5.2.0\",\"revision\":\"\",\"port\":\"9898\"}","container_id":"7a3c12568bff77f17a3909d63074401328af851e5d763a2b75b1e7e273c6ef33","container_name":"/test_web_1"}
  2. dictcp revised this gist Mar 23, 2021. 1 changed file with 9 additions and 2 deletions.
    11 changes: 9 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,16 @@
    It is a demo on how to leverage on docker logs option to send logs to another server
    ```
    ```bash
    docker-compose up -d

    docker-compose restart web

    docker-compose logs
    ## you will see the stdout from podinfo and go to fluentd stdout (due to the fluentd config)
    ## you will see the stdout from podinfo and go to fluentd stdout (due to the fluentd config), like
    ## fluentd_1 | 2021-03-23 03:51:58.000000000 +0000 7a3c12568bff: {"log":"Error to open config file, stat config.yaml: no such file or directory","container_id":"7a3c12568bff77f17a3909d63074401328af851e5d763a2b75b1e7e273c6ef33","container_name":"/test_web_1","source":"stdout"}
    ## fluentd_1 | 2021-03-23 03:51:58.000000000 +0000 7a3c12568bff: {"source":"stderr","log":"{\"level\":\"info\",\"ts\":\"2021-03-23T03:51:58.480Z\",\"caller\":\"podinfo/main.go:150\",\"msg\":\"Starting podinfo\",\"version\":\"5.2.0\",\"revision\":\"\",\"port\":\"9898\"}","container_id":"7a3c12568bff77f17a3909d63074401328af851e5d763a2b75b1e7e273c6ef33","container_name":"/test_web_1"}
    ## web_1 | Error to open config file, stat config.yaml: no such file or directory
    ## web_1 | {"level":"info","ts":"2021-03-23T03:51:43.991Z","caller":"podinfo/main.go:150","msg":"Starting podinfo","version":"5.2.0","revision":"","port":"9898"}
    ## web_1 | {"level":"info","ts":"2021-03-23T03:51:54.920Z","caller":"api/server.go:209","msg":"Shutting down HTTP/HTTPS server","timeout":5}
    ## web_1 | Error to open config file, stat config.yaml: no such file or directory
    ## web_1 | {"level":"info","ts":"2021-03-23T03:51:58.480Z","caller":"podinfo/main.go:150","msg":"Starting podinfo","version":"5.2.0","revision":"","port":"9898"}
    ```
  3. dictcp created this gist Mar 23, 2021.
    9 changes: 9 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    It is a demo on how to leverage on docker logs option to send logs to another server
    ```
    docker-compose up -d
    docker-compose restart web
    docker-compose logs
    ## you will see the stdout from podinfo and go to fluentd stdout (due to the fluentd config)
    ```
    23 changes: 23 additions & 0 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@


    services:
    web:
    image: stefanprodan/podinfo
    ports:
    - '9898:9898'
    logging:
    driver: fluentd
    options:
    fluentd-address: "127.0.0.1:24224"
    depends_on:
    - "fluentd"
    fluentd:
    image: fluent/fluentd:latest
    ports:
    - '24224:24224'
    - '24224:24224/udp'
    volumes:
    - ./fluentd.conf:/fluentd/etc/fluentd.conf
    environment:
    - FLUENTD_CONF=fluentd.conf

    7 changes: 7 additions & 0 deletions fluentd.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    <source>
    @type forward
    </source>

    <match *>
    @type stdout
    </match>