Skip to content

Commit

Permalink
Merge pull request #14 from bloodcarter/master
Browse files Browse the repository at this point in the history
Add support for AWS Elasticsearch
  • Loading branch information
mcollina committed Sep 20, 2017
2 parents 461b098 + 63c3cd3 commit 6ccb46f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ npm install pino-elasticsearch -g
cat log | pino-elasticsearch --host 192.168.1.42
If using AWS Elasticsearch:
cat log | pino-elasticsearch --host https://your-url.us-east-1.es.amazonaws.com --port 443 -c ./aws_config.json
Flags
-h | --help Display Help
-v | --version display Version
Expand All @@ -27,6 +30,7 @@ npm install pino-elasticsearch -g
-t | --type the name of the type to use; default: log
-b | --size the number of documents for each bulk insert
-l | --trace-level trace level for the elasticsearch client, default 'error' (info, debug, trace).
-c | --aws-credentials path to aws_config.json (is using AWS Elasticsearch)
```

Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
"minimist": "^1.2.0",
"pump": "^1.0.2",
"readable-stream": "^2.3.3",
"split2": "^2.1.1"
"split2": "^2.1.1",
"aws-sdk": "^2.83.0",
"http-aws-es":"^3.1.0"
},
"repository": {
"type": "git",
Expand All @@ -43,5 +45,8 @@
"bugs": {
"url": "https://github.com/pinojs/pino-elasticsearch/issues"
},
"homepage": "https://github.com/pinojs/pino-elasticsearch#readme"
"homepage": "https://github.com/pinojs/pino-elasticsearch#readme",
"directories": {
"test": "test"
}
}
7 changes: 6 additions & 1 deletion pino-elasticsearch.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const split = require('split2')
const pump = require('pump')
const fs = require('fs')
const path = require('path')
const AWS = require('aws-sdk')

function pinoElasticSearch (opts) {
const splitter = split(function (line) {
Expand All @@ -30,7 +31,10 @@ function pinoElasticSearch (opts) {
return value
})
const client = new elasticsearch.Client({
host: opts.host + ':' + opts.port,
host: opts.host ? opts.host + ':' + opts.port : undefined,
auth: opts.user ? opts.user + ':' + opts.password : undefined,
connectionClass: opts['aws-credentials'] ? require('http-aws-es') : undefined,
awsConfig: opts['aws-credentials'] ? AWS.config.loadFromPath(opts['aws-credentials']) : undefined,
log: {
level: opts['trace-level'] || 'error'
}
Expand Down Expand Up @@ -114,6 +118,7 @@ if (require.main === module) {
host: 'H',
port: 'p',
index: 'i',
'aws-credentials': 'c',
'bulk-size': 'b',
'trace-level': 'l'
},
Expand Down
2 changes: 2 additions & 0 deletions usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
-c | --consistency the consistency of the write; default: one
-b | --size the number of documents for each bulk insert
-l | --trace-level trace level for the elasticsearch client, default 'error' (info, debug, trace).
-c | --aws-credentials path to aws_config.json (is using AWS Elasticsearch)

0 comments on commit 6ccb46f

Please sign in to comment.