Last active
August 29, 2015 14:07
-
-
Save shapeshed/b47c7040b031fb61cb8c to your computer and use it in GitHub Desktop.
Box.com Events Long Polling
This file contains 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
var boxSdk = require('box-sdk'); | |
var winston = require('winston'); | |
var logger = new (winston.Logger)({ | |
transports: [ | |
new (winston.transports.File)({ | |
filename: './events.log', | |
json: true | |
}) | |
] | |
}); | |
var logLevel = 'debug'; | |
var box = boxSdk.Box({ | |
client_id: 'XXXX', | |
client_secret: 'XXXX', | |
port: 3000, | |
host: 'localhost' | |
}, logLevel); | |
var connection = box.getConnection('george@pebblecode.com'); | |
console.log(connection.getAuthURL()); | |
connection.ready(function () { | |
console.log('long polling'); | |
connection.startLongPolling(); | |
connection.on('polling.event.#', function (data) { | |
logger.info(data); | |
}); | |
connection.on('polling.end', function() { | |
}); | |
connection.on('polling.error', function (err) { | |
console.error(err); | |
}); | |
}); |
This file contains 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
input { | |
file { | |
path => ["/srv/boxtoes.pebblecode.net/events.log"] | |
codec => json { | |
charset => "UTF-8" | |
} | |
} | |
} | |
output { | |
elasticsearch { | |
protocol => http | |
} | |
} |
This file contains 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
PUT /logstash-2014-10-1 | |
{ | |
"template": "logstash-*", | |
"mappings": { | |
"_default_": { | |
"_all": { "enabled": false }, | |
"dynamic_templates": [ | |
{ | |
"string_template" : { | |
"match" : "*", | |
"mapping": { "type": "string", "index": "not_analyzed" }, | |
"match_mapping_type" : "string" | |
} | |
} | |
] | |
}, | |
"event":{ | |
"_id": { | |
"path": "event_id" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment