Fluentd websocket output plugin.
This plugin works as websocket server which can output JSON string or MessagePack binary.
In the current version, emitted data will be broadcasted to the all connected clients.
gem install fluent-plugin-websocket
This plugin depends on {em-websocket}.
<match foo.**> type websocket host 192.168.1.1 # default: 0.0.0.0 (ANY) port 8080 # default: 8080 use_msgpack false # default: false add_time false # default: false add_tag true # default: true </match>
-
host: WebSocket server IP address.
-
port: WebSocket server port.
-
use_msgpack: Send MessagePack format binary. Otherwise, you send JSON format text.
-
add_time: Add timestamp to the data.
-
add_tag: Add fluentd tag to the data.
If there are no websocket connections, this plugin silently discards data. You may use out_copy plugin like this:
<match foo.**> type copy <store> type file path /var/log/foo/bar.log </store> <store> type websocket port 8080 </store> </match>
[tag, timestamp, data_object]
-
tag is appended when add_tag option is true.
-
timespamp is appended when add_time option is true.
curl -X POST -d 'json={"action":"login","user":6}' http://localhost:8888/foo/bar ["foo.bar",1364699026,{"action":"login","user":6}]
function onMessage(evt) { data = JSON.parse(evt.data); ... }
Extract data by msgpack.js.
websocket.binaryType = "arraybuffer" ... function onMessage(evt) { data = msgpack.unpack(new Uint8Array(evt.data)) ... }
-
Fork it
-
Create your feature branch (‘git checkout -b my-new-feature`)
-
Commit your changes (‘git commit -am ’Add some feature’‘)
-
Push to the branch (‘git push origin my-new-feature`)
-
Create new Pull Request
- Copyright
-
Copyright © 2013 IZAWA Tetsu (@moccos)
- License
-
Apache License, Version 2.0