This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://www.fluentd.org/guides/recipes/apache-add-hostname | |
| # Generating event tags based on the hostname | |
| <source> | |
| type tail | |
| path /var/log/nginx/access.log | |
| tag "access.#{Socket.gethostname}" | |
| format nginx | |
| time_format %d/%b/%Y:%H:%M:%S %z | |
| pos_file /tmp/fluentd-tail-access.pos |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # in_forward を使う場合(TCP 24224 番ポート)MessagePack 形式 | |
| # http://docs.fluentd.org/v0.12/categories/in_forward | |
| # fluentd -c /dev/null -i '<source>\ntype forward\n</source>\n<match **>\ntype stdout\n</match>' | |
| ruby -rsocket -rmsgpack -ne '(s=s||(s=TCPSocket.new "127.0.0.1",24224)).print ["debug",Time.now.to_i,{message:$_.chomp}].to_msgpack unless /^$/' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fluentd -c ./fluentd.conf -v | |
| date | nc 127.0.0.1 5170 | |
| date | nc -u 127.0.0.1 5160 | |
| date | socat tcp:127.0.0.1:5170 stdin | |
| date | socat udp:127.0.0.1:5160 stdin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # use mlogger https://github.com/nbrownus/mlogger on mac | |
| logger=$(which mlogger 2> /dev/null || which logger) | |
| $logger -n 127.0.0.1 -P 5140 --udp -i -p info -t debug | |
| # -t => "ident" | |
| # -p => tag suffix | |
| # -i => "pid" | |
| # | |
| # sample result: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server { | |
| listen 8000; | |
| access_log syslog:server=127.0.0.1:8514 combined; | |
| error_log syslog:server=127.0.0.1:5140; | |
| : | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| log_format ltsv | |
| 'time:$time_local\t' | |
| 'remote:$remote_addr\t' | |
| 'method:$request_method\t' | |
| 'user:$remote_user\t' | |
| 'path:$request_uri\t' | |
| 'code:$status\t' | |
| 'size:$body_bytes_sent\t' | |
| 'referer:$http_referer\t' | |
| 'agent:$http_user_agent\t' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| /** | |
| * @see http://docs.fluentd.org/articles/in_udp | |
| * @see https://nodejs.org/api/dgram.html#dgram_socket_send_buf_offset_length_port_address_callback | |
| */ | |
| var dgram = require("dgram"); | |
| var data = { foo: "bar" }; | |
| data.time = Math.floor(new Date() / 1000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # re-launch itself with full path specified | |
| [ "${0:0:1}" = "/" ] || exec -- "$0" "$@" | |
| # relative path available then | |
| ./path/to/file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # re-launch itself with a specified user when launched with root user | |
| [ "$(id -u)" -eq 0 ] && exec su - "someuser" -c "$0 $*" | |
| # do something | |
| whoami |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # @see http://docs.fluentd.org/articles/in_http | |
| curl -i -X POST -d 'json={"action":"login","user":2}' http://localhost:8888/test.tag.here | |
| # below posts as same as above | |
| curl -i -X POST -H 'Content-Type: application/json' -d '{"action":"login","user":2}' http://localhost:8888/test.tag.here |