Skip to content

Instantly share code, notes, and snippets.

@shapeshed
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shapeshed/b47c7040b031fb61cb8c to your computer and use it in GitHub Desktop.
Save shapeshed/b47c7040b031fb61cb8c to your computer and use it in GitHub Desktop.
Box.com Events Long Polling
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);
});
});
input {
file {
path => ["/srv/boxtoes.pebblecode.net/events.log"]
codec => json {
charset => "UTF-8"
}
}
}
output {
elasticsearch {
protocol => http
}
}
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