docker-loghose
Collect all the logs from all docker containers
Install
As a command line tool:
npm install docker-loghose -g
Embedded usage
npm install docker-loghose --save
Embedded Usage
var loghose = require('docker-loghose')
var through = require('through2')
var opts = {
json: false,
docker: null,
events: null,
newline: false,
includeCurrentContainer: false,
nameLabel: 'com.amazonaws.ecs.container-name',
matchByName: /hello/,
matchByImage: /matteocollina/,
skipByName: /.*pasteur.*/,
skipByImage: /.*dockerfile.*/,
attachFilter: function (id, dockerInspectInfo) {
return true
}
addLabels: false
labelsMatch: /^ecs-.*/
labelsKey: labels
}
var lh = loghose(opts)
lh.pipe(through.obj(function(chunk, enc, cb) {
this.push(JSON.stringify(chunk))
this.push('\n')
if (/top secret logs/.test(chunk.line)) {
lh.detachContainer(chunk.long_id)
}
cb()
})).pipe(process.stdout)
Command Line Usage
docker-loghose [--json] [--help]
[--newline]
[--nameLabel STRING]
[--matchByImage REGEXP] [--matchByName REGEXP]
[--skipByImage REGEXP] [--skipByName REGEXP]
Docker Usage
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock matteocollina/docker-loghose
Data format
{
v: 0,
id: "3324acd73ad5",
long_id: "3324acd73ad573773b901d93e932be65f2bb55b8e6c03167a24c17ab3f172249"
image: "myimage:latest",
name: "mycontainer-name"
time: 1454928524601,
line: "This is a log line",
labels: {
com.amazonaws.ecs.cluster: "my-ecs-cluster"
}
}
Acknowledgements
This project was kindly sponsored by nearForm.
License
MIT