{"_id":"@benbria/winston-elasticsearch","_rev":"36-eea726de3c7449224dc7d574d641e195","name":"@benbria/winston-elasticsearch","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@benbria/winston-elasticsearch","version":"1.0.0","keywords":["logging","winston","elasticsearch","transport","logstash"],"license":"MIT","_id":"@benbria/winston-elasticsearch@1.0.0","maintainers":[{"name":"bradleytaunt","email":"bradleytaunt@gmail.com"},{"name":"danule","email":"dle@benbria.ca"},{"name":"erichaberkorn","email":"erichaberkorn@gmail.com"},{"name":"iestaa","email":"rom1guyot@gmail.com"},{"name":"jwalton","email":"npm@lucid.thedreaming.org"},{"name":"kreisys","email":"shaybergmann@gmail.com"},{"name":"macpham","email":"macpham@gmail.com"},{"name":"mdu","email":"masondu@gmail.com"},{"name":"michaelreiter","email":"michaelreiter@live.ca"},{"name":"oguzbilgener","email":"oguzbilgener@gmail.com"}],"contributors":[{"url":"https://github.com/andypotanin","name":"Andy Potanin"}],"homepage":"https://github.com/benbria/winston-elasticsearch#readme","bugs":{"url":"https://github.com/benbria/winston-elasticsearch/issues"},"dist":{"shasum":"779d2fecbce242c7e10c5e96222800824f6aa355","tarball":"https://registry.npmjs.org/@benbria/winston-elasticsearch/-/winston-elasticsearch-1.0.0.tgz","fileCount":11,"integrity":"sha512-tsXqRBCmVxqJlfQjCvGJBwNhukvZjsKnBC/q2DlnZtT04S2EsJ6ioVGNIVtEpwUuxYHOGqvsqsIEj7pXG/MBQw==","signatures":[{"sig":"MEUCIADQSk6fwRRRGC8EfNBZXUrFP0fsNTuKn9eoe3MwZRPUAiEAhKBWJlhdjDnLiXTMTfkoGOL4zYPVnAhk9RaZ/QlBZp0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":24131,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbNo1fCRA9TVsSAnZWagAAXRIP+wcsl5juzSuLrojgh/cK\nH9gRqJ7yG+BIJtFmc6UFlFhgwtwC9Z7iKmP9DnbEsqNPgDVMZMViBBni5f0I\n5RJPDRqqjvqkVlE+LQohV0VdcXy+Lota3SZZEv6h8j1mBxTEbPAPzIsiSIr1\nvgP/qsZyDn1UTAWb2PvHRAxD6JrgxrBFZ3cwMfBQEwvpXot3yxl3cdUkI25Q\n97ubzUH1byWyVXiKTU8VPlvR943oMGERmr5g58QFOU0KW23DPt9IUKIT4fhn\niAqe7oq6OshTitbIys9k2KzXM9o7Ek5CPHKWU8L9Jlk1JEfwUGQINUoBB8BU\nQ9nYWx0EtGm/0d0Q+D5cRZPaTQcGLxCkC+HTnqj4NBtF1BPSgmwTJrItq5jd\naOU4hLzLTHOzF58DGKhsnMIwv0PbVNGe/tq5ro7nil1w4GgtY/ePsLlG3mLm\nf6v7cyPg5CqjuQJX/EIxgF93ChKLgSHCrj8ONo+BKX+kjiQ9uhkrBJ5rRu3w\nkDXJoq7m0j7keJVBRKeqRqj4mJjs1OHGHchXiE394wu6/VdM9vl0piT9KHD8\nA+SXVuuo9dmvsfNtIDcTDbMHkBrjxuzO7mPEBF/tDCzkNIAlSt2jAqUkYJc+\nWmy5xORDiziQu4AcZlpG/IryDughOq8if7surJHUukAz31YhMzX5blDP8eS+\ncCBY\r\n=temJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index","authors":[{"url":"https://github.com/jackdbernier","name":"Jacques-Olivier D. Bernier"},{"url":"https://github.com/vanthome","name":"Thomas Hoppe","email":"thomas.hoppe@n-fuse.co"}],"engines":{"node":">= 6.0.0"},"gitHead":"add61fefa7cb4311fd1d99da6d70fa80acdb520b","scripts":{"lint":"eslint *.json *.js","test":"npm run lint && npm run mocha","mocha":"mocha ./test/* --exit","coveralls":"istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec ./test/* --exit"},"_npmUser":{"name":"jwalton","email":"npm@lucid.thedreaming.org"},"repository":{"url":"git+ssh://git@github.com/benbria/winston-elasticsearch.git","type":"git"},"_npmVersion":"6.1.0","description":"An Elasticsearch transport for winston","directories":{},"_nodeVersion":"8.11.3","dependencies":{"debug":"^3.1.0","retry":"^0.12.0","lodash":"^4.17.10","moment":"^2.22.2","promise":"^8.0.1","winston":"^3.0.0","triple-beam":"^1.3.0","elasticsearch":"^15.0.0","winston-transport":" ^4.2.0"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^5.2.0","eslint":"^4.19.1","should":"^13.2.1","istanbul":"^0.4.5","coveralls":"^3.0.1","babel-eslint":"^8.2.3","eslint-plugin-json":"^1.2.0","eslint-plugin-import":"^2.12.0","eslint-config-airbnb-base":"^12.1.0"},"_npmOperationalInternal":{"tmp":"tmp/winston-elasticsearch_1.0.0_1530301791769_0.2230407288315044","host":"s3://npm-registry-packages"}}},"time":{"created":"2018-06-29T19:49:51.768Z","modified":"2026-09-10T19:50:19.635Z","1.0.0":"2018-06-29T19:49:51.848Z"},"bugs":{"url":"https://github.com/benbria/winston-elasticsearch/issues"},"license":"MIT","homepage":"https://github.com/benbria/winston-elasticsearch#readme","keywords":["logging","winston","elasticsearch","transport","logstash"],"repository":{"url":"git+ssh://git@github.com/benbria/winston-elasticsearch.git","type":"git"},"description":"An Elasticsearch transport for winston","contributors":[{"url":"https://github.com/andypotanin","name":"Andy Potanin"}],"maintainers":[{"email":"lucas.pawley@benbria.com","name":"lucaspawley-benbria"},{"email":"arnold.elite@benbria.com","name":"arnoldelite"},{"email":"jordan.parsons@benbria.com","name":"jordan.parsons"},{"email":"hanut.gusain@benbria.com","name":"hanutb"},{"email":"victor.valle@benbria.com","name":"victor.valle"},{"email":"engineering@benbria.com","name":"engineering-benbria"},{"email":"tanbir.ahmed@benbria.com","name":"tanbir-benbria"},{"email":"justin.marcon@benbria.com","name":"justin-marcon-b"},{"email":"divyanshu.verma@benbria.com","name":"dverma-benbria"}],"readme":"# winston-elasticsearch\n\n[![Version npm][version]](http://browsenpm.org/package/winston-elasticsearch)[![Build Status][build]](https://travis-ci.org/vanthome/winston-elasticsearch)[![Dependencies][david]](https://david-dm.org/vanthome/winston-elasticsearch)[![Coverage Status][cover]](https://coveralls.io/r/vanthome/winston-elasticsearch?branch=master)\n\n[version]: http://img.shields.io/npm/v/winston-elasticsearch.svg?style=flat-square\n[build]: http://img.shields.io/travis/vanthome/winston-elasticsearch/master.svg?style=flat-square\n[david]: https://img.shields.io/david/vanthome/winston-elasticsearch.svg?style=flat-square\n[cover]: http://img.shields.io/coveralls/vanthome/winston-elasticsearch/master.svg?style=flat-square\n\nAn [elasticsearch](https://www.elastic.co/products/elasticsearch)\ntransport for the [winston](https://github.com/winstonjs/winston) logging toolkit.\n\n## Features\n\n- [logstash](https://www.elastic.co/products/logstash) compatible message structure.\n- Thus consumable with [kibana](https://www.elastic.co/products/kibana).\n- Date pattern based index names.\n- Custom transformer function to transform logged data into a different message structure.\n\n### Compatibility\n\nFor  **Winston 3.0**, **Elasticsearch 6.0** and later, use the `0.7.0`.\nFor **Elasticsearch 6.0** and later, use the `0.6.0`.\nFor **Elasticsearch 5.0** and later, use the `0.5.9`.\nFor earlier versions, use the `0.4.x` series.\n\n### Unsupported / Todo\n\n- Querying.\n- Real buffering of messages in case of unavailable ES.\n\n## Installation\n\n```sh\nnpm install --save winston winston-elasticsearch\n```\n\n## Usage\n\n```js\nvar winston = require('winston');\nvar Elasticsearch = require('winston-elasticsearch');\n\nvar esTransportOpts = {\n  level: 'info'\n};\nvar logger = winston.createLogger({\n  transports: [\n    new Elasticsearch(esTransportOpts)\n  ]\n});\n```\n\nThe [winston API for logging](https://github.com/winstonjs/winston#streams-objectmode-and-info-objects)\ncan be used with one restriction: Only one JS object can only be logged and indexed as such.\nIf multiple objects are provided as arguments, the contents are stringified.\n\n## Options\n\n- `level` [`info`] Messages logged with a severity greater or equal to the given one are logged to ES; others are discarded.\n- `index` [none] the index to be used. This option is mutually exclusive with `indexPrefix`.\n- `indexPrefix` [`logs`] the prefix to use to generate the index name according to the pattern `<indexPrefix>-<indexSuffixPattern>`.\n- `indexSuffixPattern` [`YYYY.MM.DD`] a [Moment.js](http://momentjs.com/) compatible date/ time pattern.\n- `messageType` [`log`] the type (path segment after the index path) under which the messages are stored under the index.\n- `transformer` or `rawTransformer` [see below] a transformer function to transform logged data into a different message structure.\n- `ensureMappingTemplate` [`true`] If set to `true`, the given `mappingTemplate` is checked/ uploaded to ES when the module is sending the fist log message to make sure the log messages are mapped in a sensible manner.\n- `mappingTemplate` [see file `index-template-mapping.json` file] the mapping template to be ensured as parsed JSON.\n- `flushInterval` [`2000`] distance between bulk writes in ms.\n- `client` An [elasticsearch client](https://www.npmjs.com/package/elasticsearch) instance. If given, all following options are ignored.\n- `clientOpts` An object hash passed to the ES client. See [its docs](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/configuration.html) for supported options.\n- `waitForActiveShards` [`1`] Sets the number of shard copies that must be active before proceeding with the bulk operation.\n- `pipeline` [none] Sets the pipeline id to pre-process incoming documents with. See [the bulk API docs](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-bulk).\n\n### Logging of ES Client\n\nThe default client and options will log through `console`.\n\n### Interdependencies of Options\n\nWhen changing the `indexPrefix` and/ or the `transformer`,\nmake sure to provide a matching `mappingTemplate`.\n\n## Transformer\n\nThe transformer function allows to transform the log data structure as provided\nby winston into a structure more appropriate for indexing in ES.  `transformer()`\nis passed a `logData` object, which is a `{message, level, meta}` object.\n`rawTransformer()` is passsed the raw `info` object from Winston.  Either\nshould return an object to write to Elasticsearch.\n\nThe default transformer function's transformation is shown below.\n\nInput:\n\n```js\n{\n  \"message\": \"Some message\",\n  \"level\": \"info\",\n  \"meta\": {\n    \"method\": \"GET\",\n    \"url\": \"/sitemap.xml\",\n    ...\n    }\n  }\n}\n```\n\nOutput:\n\n```js\n{\n  \"@timestamp\": \"2018-09-30T05:09:08.282Z\",\n  \"message\": \"Some message\",\n  \"severity\": \"info\",\n  \"fields\": {\n    \"method\": \"GET\",\n    \"url\": \"/sitemap.xml\",\n    ...\n  }\n}\n```\n\nThe `@timestamp` is generated in the transformer.\nNote that in current logstash versions, the only \"standard fields\" are @timestamp and @version,\nanything else ist just free.\n\nThe `transformer` or `rawTransformer` function can be provided in the options hash.\n\n## Events\n\n- `error`: in case of any error.\n\n## Example\n\nAn example assuming default settings.\n\n### Log Action\n\n```js\nlogger.info('Some message', <req meta data>);\n```\n\nwhere `req meta data` is a JSON object.\n\n### Generated Message\n\nThe log message generated by this module has the following structure:\n\n```js\n{\n  \"@timestamp\": \"2018-09-30T05:09:08.282Z\",\n  \"message\": \"Some log message\",\n  \"severity\": \"info\",\n  \"fields\": {\n    \"method\": \"GET\",\n    \"url\": \"/sitemap.xml\",\n    \"headers\": {\n      \"host\": \"www.example.com\",\n      \"user-agent\": \"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)\",\n      \"accept\": \"*/*\",\n      \"accept-encoding\": \"gzip,deflate\",\n      \"from\": \"googlebot(at)googlebot.com\",\n      \"if-modified-since\": \"Tue, 30 Sep 2018 11:34:56 GMT\",\n      \"x-forwarded-for\": \"66.249.78.19\"\n    }\n  }\n}\n```\n\n### Target Index\n\nThis message would be POSTed to the following endpoint:\n\n    http://localhost:9200/logs-2018.09.30/log/\n\nSo the default mapping uses an index pattern `logs-*`.\n","readmeFilename":"README.md"}