{"_id":"@drftgyhuji7npm/aperiam-laudantium-quam","name":"@drftgyhuji7npm/aperiam-laudantium-quam","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@drftgyhuji7npm/aperiam-laudantium-quam","version":"1.0.0","description":"Load [pino](https://github.com/pinojs/pino) logs into [Elasticsearch](https://www.elastic.co/products/elasticsearch).","main":"index.js","author":{"name":"drftgyhuji7"},"license":"MIT","dependencies":{"@drftgyhuji7npm/adipisci-ad-reiciendis-temporibus":"^1.0.0","@drftgyhuji7npm/aliquid-mollitia-est-illo":"^1.0.0","@drftgyhuji7npm/animi-a-ab-earum":"^1.0.0","@drftgyhuji7npm/aut-dolores-numquam-dolorem":"^1.0.0","@drftgyhuji7npm/corporis-facere-ut-suscipit":"^1.0.0","@drftgyhuji7npm/debitis-error-dolores-sit":"^1.0.0","@drftgyhuji7npm/ea-numquam-maiores-voluptas":"^1.0.0","@drftgyhuji7npm/earum-adipisci-error-est":"^1.0.0","@drftgyhuji7npm/esse-eveniet-nobis-dolores":"^1.0.0","@drftgyhuji7npm/impedit-omnis-molestiae-dolores":"^1.0.0","@drftgyhuji7npm/iure-possimus-nihil-tempore":"^1.0.0","@drftgyhuji7npm/laboriosam-molestias-quo-quia":"^1.0.0","@drftgyhuji7npm/magni-eaque-quo-tempore":"^1.0.0","@drftgyhuji7npm/natus-praesentium-nisi-praesentium":"^1.0.0","@drftgyhuji7npm/necessitatibus-necessitatibus-nulla-ducimus":"^1.0.0","@drftgyhuji7npm/nisi-unde-debitis-porro":"^1.0.0","@drftgyhuji7npm/perspiciatis-quis-ducimus-maiores":"^1.0.0","@drftgyhuji7npm/quasi-reprehenderit-dolore-deserunt":"^1.0.0","@drftgyhuji7npm/rem-sint-necessitatibus-possimus":"^1.0.0","@drftgyhuji7npm/repellendus-eum-et-itaque":"^1.0.0","@drftgyhuji7npm/temporibus-omnis-modi-ipsa":"^1.0.0","@drftgyhuji7npm/vitae-rerum-dignissimos-eos":"^1.0.0","@drftgyhuji7npm/voluptas-temporibus-cupiditate-cum":"^1.0.0","@drftgyhuji7npm/voluptatibus-numquam-neque-veritatis":"^1.0.0","@drftgyhuji7npm/voluptatum-molestiae-aliquid-ullam":"^1.0.0","@omegion1npm/quisquam-maiores-provident":"^1.0.0","@povsicoenpm/non-rerum-sequi":"^1.0.0","@rtyughnnpm/eligendi-enim-voluptate":"^1.0.0"},"keywords":["query","find","data","reduce","phone","ascii","pure","JSON-Schema","babel-core","loading","-0","setter","remove","channel","indicator","json-schema-validation","private data","call-bound","Array.prototype.includes","classname","framework","querystring","child","ECMAScript 7","hooks","input","preserve-symlinks","error-handling","Map","colors","setImmediate","valid","256","ArrayBuffer#slice","fs","inference","xdg-open","terminal","walking","path","ECMAScript 2022","zod","concat","Object.fromEntries","metadata","postcss-plugin","opens","ES8","ts","censor","korean","ArrayBuffer","pyyaml","plugin","es-shims","typescript","classes","exit-code","traverse","dotenv","callbind","trimEnd","output","Object.entries","windows","vest","exe","xss","utility","package manager","gdpr","scheme-validation","ECMAScript 6","bdd","toArray","airbnb","await","less mixins","concurrency","autoprefixer","cache","optimizer","call","flag","tacit","duplex","map","compile less","stream","directory","defineProperty","user-streams","real-time","validator","cors","bootstrap less","lesscss","env","findup","executable","ECMAScript 2017","weakmap","less.js","less compiler","package","Observable","3d","ECMAScript 2023","look","syntaxerror","extend","CSSStyleDeclaration","Observables","make","jsdiff","editor","WebSockets","emoji","karma","lint","bundling","styling","const","push","ramda","formatting","yup","spinners","worker","ES2015","Underscore","Set","readablestream","let","lockfile","date","[[Prototype]]","parser","qs","error","task","view","streams2","define","point-free","up","code points","react","datastructure","harmony","id","variables","ajv","recursive","wordwrap","prototype","deep-clone","styles","clone","TypedArray","modules","ES6","irq","picomatch","argparse","status","bluebird","negative zero","escape","validation","rgb","mixins","scheme","fetch","debug","shebang","performant","rate","css variable","Uint32Array","ECMAScript 2015","fixed-width","fast","estree","uninstall","which","filter","handlers","postcss","app","mkdirp","require","prune","libphonenumber","hardlinks","import","typed array","settings","contains","arguments","cmd","tty","jsx","eslint-plugin","extra","xhr","Array.prototype.flat","gradients css","flatten","URL","compiler","spinner","connect","symlink","form-validation","reducer","RegExp.prototype.flags","diff","promises","native","Push","xdg","logger","graphql","browserslist","sequence","chrome","RFC-6455","operating-system","args","getPrototypeOf","flat","regular","compare","names","object","find-up","concatMap","installer","eventEmitter","create","classnames","assign","value","es-abstract","figlet","move","javascript","width","text","performance","quote","workspace:*","testing","mobile","call-bind","wait","throat","three","__proto__","sanitization","guid","style","visual","eslintplugin","sham","awesomesauce","batch","once","fantasy-land","characters","encryption","art","serialization","optimist","js","mocha","launch","tape","util","protobuf","type","wget","proto","polyfill","option","es2015","ES5","ES2018","Rx","regular expression","byte","has","forEach","ECMAScript 5","drag","react animation","Uint8Array","core","offset","superagent","resolve","generics","api","key","ratelimit","configurable","getter","es6","typesafe","number","joi","mimetypes","URLSearchParams","collection.es6","matches","6to5","util.inspect","toSorted","redact","watch","consume","opener","ponyfill","hasOwn","ECMAScript 2018","Float32Array","multi-package","symbol","ES3","bind","tslib","regular expressions","config","writable","ajax","class-validator","east-asian-width","bundler","enumerable","speed","slot","arraybuffer","react-hook-form","tostringtag","walk","website","schema","internal","limited","password","trimLeft","https","css less","functional","search","safe","Object.keys","0","parent","watching","expression","mime-db","queue","busy","signals","lazy","argument","utils","spec","callbound","animation","get","deepcopy","String.prototype.matchAll","file system","is","cli","http","log","promise","BigUint64Array","eventDispatcher","codes","full-width","styleguide","interrupts","es-shim API","check","getOwnPropertyDescriptor","arrays","packages","Object.assign","rapid","Symbol.toStringTag","collection","mkdir","patch","Object","ECMAScript 2019","command-line","ArrayBuffer.prototype.slice","descriptor","starter","package.json","some","Object.getPrototypeOf","pretty","dom-testing-library","tap","ECMAScript 2016","Promise","fastcopy","extension","asserts","dataView","ava","keys","buffer","client","Int8Array","ES7","robust","stringifier","pipe","copy","immutable","unicode","json-schema-validator","sanitize","fastclone","url","emit","jest","command","test","CSS","prop","ES2020","react pose","break","color","linux","io-ts","install","look-up","tc39","entries","jsonpath","take","ESnext","column","sharedarraybuffer","iteration","time","yaml","isConcatSpreadable","var","jasmine","getopt","typanion","description","helpers","function","includes","debugger","i18n","rmdir","pnpm9","typeerror","ansi","nested css","hash","fast-deep-copy","ReactiveX","assertion","toolkit","HyBi","from","react-hooks","bound","forms","Uint8ClampedArray","protocol-buffers","types","deep",".env","length","persistent","moment","invariant","spring","positive","intrinsic","exec","xterm","Microsoft","ES","iterate","JSON","eslint","css-in-js","es2016","parse","eslintconfig","Array.prototype.flatten","typedarrays","ECMAScript 2020","descriptors","YAML","set","events","String.prototype.trim","computed-types","file","web","cjk","AsyncIterator","structuredClone","less","auth","browser","toStringTag","nodejs","internal slot","watcher","less css","ECMAScript 3","obj","columns","arktype","syntax","readable","iterator","merge","higher-order","linewrap","properties","slice","negative","sorted","es","curried","gradients css3","es2018","equal","rfc4122","read","variables in css","banner","lru","sigint","uuid","dependency manager","wrap","mkdirs"],"repository":{"type":"git","url":"git+https://github.com/drftgyhuji7npm/aperiam-laudantium-quam.git"},"homepage":"https://github.com/drftgyhuji7npm/aperiam-laudantium-quam/#readme","bugs":{"url":"https://github.com/drftgyhuji7npm/aperiam-laudantium-quam/issues"},"packageManager":"yarn@4.1.1","_id":"@drftgyhuji7npm/aperiam-laudantium-quam@1.0.0","gitHead":"049fe664000dd5555ce3a26cad4991a377f5678f","_nodeVersion":"20.12.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-tSgY/yY5hgjjwf+KuBByATVzOI6sa+d8o0tesD0Diw7uHeDKu4G6NzdsmQKuioHGLhczwrtJWE/W4GTD4+CIqA==","shasum":"68846501bfc4331f9787cfbb5e9019463a15bd71","tarball":"https://registry.npmjs.org/@drftgyhuji7npm/aperiam-laudantium-quam/-/aperiam-laudantium-quam-1.0.0.tgz","fileCount":10,"unpackedSize":28277,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCND+uBy84TMBgHklA9xd9H+3zHbqwVjDR/OrBBRlecTgIgeJUZSQNweW6y1vY1GqVgL5DMwF0+rv2NK1NtIxE2zp4="}]},"_npmUser":{"name":"thidong8461","email":"thidong8461@gmail.com"},"directories":{},"maintainers":[{"name":"thidong8461","email":"thidong8461@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/aperiam-laudantium-quam_1.0.0_1714041758770_0.9276094333469269"},"_hasShrinkwrap":false}},"time":{"created":"2024-04-25T10:42:38.662Z","1.0.0":"2024-04-25T10:42:38.918Z","modified":"2024-04-25T10:42:39.232Z"},"maintainers":[{"name":"thidong8461","email":"thidong8461@gmail.com"}],"description":"Load [pino](https://github.com/pinojs/pino) logs into [Elasticsearch](https://www.elastic.co/products/elasticsearch).","homepage":"https://github.com/drftgyhuji7npm/aperiam-laudantium-quam/#readme","keywords":["query","find","data","reduce","phone","ascii","pure","JSON-Schema","babel-core","loading","-0","setter","remove","channel","indicator","json-schema-validation","private data","call-bound","Array.prototype.includes","classname","framework","querystring","child","ECMAScript 7","hooks","input","preserve-symlinks","error-handling","Map","colors","setImmediate","valid","256","ArrayBuffer#slice","fs","inference","xdg-open","terminal","walking","path","ECMAScript 2022","zod","concat","Object.fromEntries","metadata","postcss-plugin","opens","ES8","ts","censor","korean","ArrayBuffer","pyyaml","plugin","es-shims","typescript","classes","exit-code","traverse","dotenv","callbind","trimEnd","output","Object.entries","windows","vest","exe","xss","utility","package manager","gdpr","scheme-validation","ECMAScript 6","bdd","toArray","airbnb","await","less mixins","concurrency","autoprefixer","cache","optimizer","call","flag","tacit","duplex","map","compile less","stream","directory","defineProperty","user-streams","real-time","validator","cors","bootstrap less","lesscss","env","findup","executable","ECMAScript 2017","weakmap","less.js","less compiler","package","Observable","3d","ECMAScript 2023","look","syntaxerror","extend","CSSStyleDeclaration","Observables","make","jsdiff","editor","WebSockets","emoji","karma","lint","bundling","styling","const","push","ramda","formatting","yup","spinners","worker","ES2015","Underscore","Set","readablestream","let","lockfile","date","[[Prototype]]","parser","qs","error","task","view","streams2","define","point-free","up","code points","react","datastructure","harmony","id","variables","ajv","recursive","wordwrap","prototype","deep-clone","styles","clone","TypedArray","modules","ES6","irq","picomatch","argparse","status","bluebird","negative zero","escape","validation","rgb","mixins","scheme","fetch","debug","shebang","performant","rate","css variable","Uint32Array","ECMAScript 2015","fixed-width","fast","estree","uninstall","which","filter","handlers","postcss","app","mkdirp","require","prune","libphonenumber","hardlinks","import","typed array","settings","contains","arguments","cmd","tty","jsx","eslint-plugin","extra","xhr","Array.prototype.flat","gradients css","flatten","URL","compiler","spinner","connect","symlink","form-validation","reducer","RegExp.prototype.flags","diff","promises","native","Push","xdg","logger","graphql","browserslist","sequence","chrome","RFC-6455","operating-system","args","getPrototypeOf","flat","regular","compare","names","object","find-up","concatMap","installer","eventEmitter","create","classnames","assign","value","es-abstract","figlet","move","javascript","width","text","performance","quote","workspace:*","testing","mobile","call-bind","wait","throat","three","__proto__","sanitization","guid","style","visual","eslintplugin","sham","awesomesauce","batch","once","fantasy-land","characters","encryption","art","serialization","optimist","js","mocha","launch","tape","util","protobuf","type","wget","proto","polyfill","option","es2015","ES5","ES2018","Rx","regular expression","byte","has","forEach","ECMAScript 5","drag","react animation","Uint8Array","core","offset","superagent","resolve","generics","api","key","ratelimit","configurable","getter","es6","typesafe","number","joi","mimetypes","URLSearchParams","collection.es6","matches","6to5","util.inspect","toSorted","redact","watch","consume","opener","ponyfill","hasOwn","ECMAScript 2018","Float32Array","multi-package","symbol","ES3","bind","tslib","regular expressions","config","writable","ajax","class-validator","east-asian-width","bundler","enumerable","speed","slot","arraybuffer","react-hook-form","tostringtag","walk","website","schema","internal","limited","password","trimLeft","https","css less","functional","search","safe","Object.keys","0","parent","watching","expression","mime-db","queue","busy","signals","lazy","argument","utils","spec","callbound","animation","get","deepcopy","String.prototype.matchAll","file system","is","cli","http","log","promise","BigUint64Array","eventDispatcher","codes","full-width","styleguide","interrupts","es-shim API","check","getOwnPropertyDescriptor","arrays","packages","Object.assign","rapid","Symbol.toStringTag","collection","mkdir","patch","Object","ECMAScript 2019","command-line","ArrayBuffer.prototype.slice","descriptor","starter","package.json","some","Object.getPrototypeOf","pretty","dom-testing-library","tap","ECMAScript 2016","Promise","fastcopy","extension","asserts","dataView","ava","keys","buffer","client","Int8Array","ES7","robust","stringifier","pipe","copy","immutable","unicode","json-schema-validator","sanitize","fastclone","url","emit","jest","command","test","CSS","prop","ES2020","react pose","break","color","linux","io-ts","install","look-up","tc39","entries","jsonpath","take","ESnext","column","sharedarraybuffer","iteration","time","yaml","isConcatSpreadable","var","jasmine","getopt","typanion","description","helpers","function","includes","debugger","i18n","rmdir","pnpm9","typeerror","ansi","nested css","hash","fast-deep-copy","ReactiveX","assertion","toolkit","HyBi","from","react-hooks","bound","forms","Uint8ClampedArray","protocol-buffers","types","deep",".env","length","persistent","moment","invariant","spring","positive","intrinsic","exec","xterm","Microsoft","ES","iterate","JSON","eslint","css-in-js","es2016","parse","eslintconfig","Array.prototype.flatten","typedarrays","ECMAScript 2020","descriptors","YAML","set","events","String.prototype.trim","computed-types","file","web","cjk","AsyncIterator","structuredClone","less","auth","browser","toStringTag","nodejs","internal slot","watcher","less css","ECMAScript 3","obj","columns","arktype","syntax","readable","iterator","merge","higher-order","linewrap","properties","slice","negative","sorted","es","curried","gradients css3","es2018","equal","rfc4122","read","variables in css","banner","lru","sigint","uuid","dependency manager","wrap","mkdirs"],"repository":{"type":"git","url":"git+https://github.com/drftgyhuji7npm/aperiam-laudantium-quam.git"},"author":{"name":"drftgyhuji7"},"bugs":{"url":"https://github.com/drftgyhuji7npm/aperiam-laudantium-quam/issues"},"license":"MIT","readme":"# @drftgyhuji7npm/aperiam-laudantium-quam&nbsp;&nbsp;[![Build Status](https://github.com/drftgyhuji7npm/aperiam-laudantium-quam/workflows/CI/badge.svg)](https://github.com/drftgyhuji7npm/aperiam-laudantium-quam/actions)&nbsp;[![Coverage Status](https://coveralls.io/repos/github/pinojs/@drftgyhuji7npm/aperiam-laudantium-quam/badge.svg?branch=master)](https://coveralls.io/github/pinojs/@drftgyhuji7npm/aperiam-laudantium-quam?branch=master)\n\nLoad [pino](https://github.com/pinojs/pino) logs into\n[Elasticsearch](https://www.elastic.co/products/elasticsearch).\n\n## Install\n\n```\nnpm install @drftgyhuji7npm/aperiam-laudantium-quam -g\n```\n\n## Usage\n\n```\n  @drftgyhuji7npm/aperiam-laudantium-quam\n\n  To send pino logs to elasticsearch:\n\n     cat log | @drftgyhuji7npm/aperiam-laudantium-quam --node http://localhost:9200\n\n  Flags\n  -h  | --help              Display Help\n  -v  | --version           display Version\n  -n  | --node              the URL where Elasticsearch is running\n  -i  | --index             the name of the index to use; default: pino\n                            will replace %{DATE} with the YYYY-MM-DD date\n  -t  | --type              the name of the type to use; default: log\n  -f  | --flush-bytes       the number of bytes for each bulk insert; default: 1000\n  -t  | --flush-interval    time that the helper will wait before flushing; default: 30000\n  -l  | --trace-level       trace level for the elasticsearch client, default 'error' (info, debug, trace).\n      | --es-version        specify the major version number of Elasticsearch (eg: 5, 6, 7)\n                            (this is needed only if you are using Elasticsearch <= 7)\n  -u  | --username          Username to specify with authentication method\n                            (can only be used in tandem with the 'password' flag)\n  -p  | --password          Password to specify with authentication method\n                            (can only be used in tandem with the 'username' flag)\n  -k  | --api-key           Api key for authentication instead of username/password combination\n  -c  | --cloud             Id of the elastic cloud node to connect to\n  -r  | --read-config       the name of config file\n  --rejectUnauthorized      Reject any connection which is not authorized with the list of supplied CAs; default: true\n\n```\n\n### Usage as module\n\n```js\nconst pino = require('pino')\nconst pinoElastic = require('@drftgyhuji7npm/aperiam-laudantium-quam')\n\nconst streamToElastic = pinoElastic({\n  index: 'an-index',\n  node: 'http://localhost:9200',\n  esVersion: 7,\n  flushBytes: 1000\n})\n\nconst logger = pino({ level: 'info' }, streamToElastic)\n\nlogger.info('hello world')\n// ...\n```\n\n### Using multiple streams (output to Console and Elasticsearch)\n\nIf you want to output to multiple streams (transports and console)), the simplest way is to use the `pino-multi-stream` library and register a stream per output.\n\n```js\nconst pinoElastic = require('@drftgyhuji7npm/aperiam-laudantium-quam');\nconst pinoMultiStream = require('pino-multi-stream').multistream;\n\nconst streamToElastic = pinoElastic({\n  index: 'an-index',\n  node: 'http://localhost:9200',\n  esVersion: 7,\n  flushBytes: 1000\n});\n\nconst pinoOptions = {};\n\nreturn pino(pinoOptions, pinoMultiStream([\n  { stream: process.stdout },\n  { stream: streamToElastic },\n]));\n```\n\nYou can learn more about `pino-multi-stream` here: https://github.com/pinojs/pino-multi-stream.\n\n### Custom Connection\n\nIf you want to use a custom Connection class for the Elasticsearch client, you can pass it as an option when using as a module. See the Elasticsearch client docs for [Connection](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/master/advanced-config.html#_connection).\n\n```js\nconst pino = require('pino')\nconst pinoElastic = require('@drftgyhuji7npm/aperiam-laudantium-quam')\n\nconst Connection = <custom Connection>\n\nconst streamToElastic = pinoElastic({\n  index: 'an-index',\n  node: 'http://localhost:9200',\n  esVersion: 7,\n  flushBytes: 1000,\n  Connection\n})\n\nconst logger = pino({ level: 'info' }, streamToElastic)\n\nlogger.info('hello world')\n// ...\n```\n\n### Troubleshooting\n\nAssuming your Elasticsearch instance is running and accessible, there are a couple of common problems that will cause indices or events (log entries) to not be created in Elasticsearch when using this library.  Developers can get feedback on these problems by listening for events returned by the stream handler.\n\nThe stream handler returned from the default factory function is an [`EventEmitter`](https://nodejs.org/api/events.html#events_class_eventemitter).  Developers can use this interface to debug issues encountered by the `@drftgyhuji7npm/aperiam-laudantium-quam` library.\n\n```js\nconst pinoElastic = require('@drftgyhuji7npm/aperiam-laudantium-quam');\n\nconst streamToElastic = pinoElastic({\n  index: 'an-index',\n  node: 'http://localhost:9200',\n  esVersion: 7,\n  flushBytes: 1000\n})\n\nstreamToElastic.on('<event>', (error) => console.log(event));\n```\n\nThe following table lists the events emitted by the stream handler:\n\n| Event | Callback Signature | Description |\n| ----- | ------------------ | ----------- |\n| `unknown` | `(line: string, error: string) => void` | Event received by `@drftgyhuji7npm/aperiam-laudantium-quam` is unparsable (via `JSON.parse`) |\n| `insertError` | `(error: Error & { document: Record<string, any> }) => void` | The bulk insert request to Elasticsearch failed (records dropped). |\n| `insert` | `(stats: Record<string, any>) => void` | Called when an insert was successfully performed |\n| `error` | `(error: Error) => void` | Called when the Elasticsearch client fails for some other reason |\n\nThere are a few common problems developers will encounter when initially using this library.  The next section discusses these issues.\n\n**Pino output is not JSON**\n\nAny transform of the stream (like `pino-pretty`) that results in an non-JSON stream output will be ignored (the `unknown` event will be emitted).\n\n```js\nconst pino = require('pino');\nconst pinoElastic = require('@drftgyhuji7npm/aperiam-laudantium-quam');\n\nconst streamToElastic = pinoElastic({\n  index: 'an-index',\n  node: 'http://localhost:9200',\n  esVersion: 7,\n  flushBytes: 1000\n})\n\nstreamToElastic.on(\n  'unknown',\n  (line, error) =>\n    console.log('Expect to see a lot of these with Pino Pretty turned on.')\n);\n\nconst logger = pino({\n  prettyPrint: true,\n}, streamToElastic)\n```\n\n**Events do not match index schema/mappings**\n\nElasticsearch schema mappings are strict and if events do not match their format, the events will be dropped.  A typical example is if you use the default `pino` format with the `logs-` index in Elasticsearch.  The default installation of Elasticsearch includes a data pipeline mapped to the `logs-` index prefix.  This is intended to be used by the Beats and Logstash aggregators and requires `@timestamp` and `@message` fields.  The default `pino` setup uses `time` and `msg`.  Attempting to write events to the `logs-` index without mapping/transforming the `pino` schema will result in events being dropped.\n\nDevelopers can troubleshoot insert errors by watching for the `insertError` event.\n\n```js\nstreamToElastic.on(\n  'insertError',\n  (error) => {\n    const documentThatFailed = error.document;\n    console.log(`An error occurred insert document:`, documentThatFailed);\n  }\n);\n```\n\n### ECS support\n\nIf you want to use [Elastic Common Schema](https://www.elastic.co/guide/en/ecs/current/index.html), you should install [`@elastic/ecs-pino-format`](https://github.com/elastic/ecs-logging-js/tree/master/loggers/pino), as the `ecs` option of this module has been removed.\n\n```js\nconst pino = require('pino')\nconst ecsFormat = require('@elastic/ecs-pino-format')()\nconst pinoElastic = require('@drftgyhuji7npm/aperiam-laudantium-quam')\n\nconst streamToElastic = pinoElastic({\n  index: 'an-index',\n  node: 'http://localhost:9200',\n  esVersion: 7,\n  flushBytes: 1000\n})\n\nconst logger = pino({ level: 'info',  ...ecsFormat  }, streamToElastic)\n\nlogger.info('hello world')\n// ...\n```\n\nYou can then use [Kibana](https://www.elastic.co/products/kibana) to\nbrowse and visualize your logs.  \n**Note:** This transport works only with Elasticsearch version ≥ 5.\n\n#### Dynamic index\n\nIt is possible to customize the index name for every log line just providing a function to the `index` option:\n\n```js\nconst pino = require('pino')\nconst pinoElastic = require('@drftgyhuji7npm/aperiam-laudantium-quam')\n\nconst streamToElastic = pinoElastic({\n  index: function (logTime) {\n    // the logTime is a ISO 8601 formatted string of the log line\n    return `awesome-app-${logTime.substring(5, 10)}`\n  },\n  node: 'http://localhost:9200'\n})\n// ...\n```\n\nThe function **must** be sync, doesn't throw and return a string.\n\n#### Datastreams\n\nIndexing to datastreams requires the `opType` to be set to `create`:\n```js\nconst pino = require('pino')\nconst pinoElastic = require('@drftgyhuji7npm/aperiam-laudantium-quam')\n\nconst streamToElastic = pinoElastic({\n  index: \"type-dataset-namespace\",\n  node: 'http://localhost:9200',\n  opType: 'create'\n})\n// ...\n```\n\n#### Error handling\n```js\nconst pino = require('pino')\nconst ecsFormat = require('@elastic/ecs-pino-format')\nconst pinoElastic = require('@drftgyhuji7npm/aperiam-laudantium-quam')\n\nconst streamToElastic = pinoElastic({\n  index: 'an-index',\n  node: 'http://localhost:9200',\n  esVersion: 7,\n  flushBytes: 1000\n})\n\n// Capture errors like unable to connect Elasticsearch instance.\nstreamToElastic.on('error', (error) => {\n  console.error('Elasticsearch client error:', error);\n})\n// Capture errors returned from Elasticsearch, \"it will be called every time a document can't be indexed\".\nstreamToElastic.on('insertError', (error) => {\n  console.error('Elasticsearch server error:', error);\n})\n\nconst logger = pino({ level: 'info',  ...ecsFormat()  }, streamToElastic)\n\nlogger.info('hello world')\n```\n\n### Authentication\nIf you need to use basic authentication to connect with the Elasticsearch cluster, pass the credentials in the URL:\n```\ncat log | @drftgyhuji7npm/aperiam-laudantium-quam --node https://user:pwd@localhost:9200\n```\n\nAlternatively you can supply a combination of `username` and `password` OR `api-key`:\n```\ncat log | @drftgyhuji7npm/aperiam-laudantium-quam --node https://localhost:9200 -u user -p pwd\n```\n```\ncat log | @drftgyhuji7npm/aperiam-laudantium-quam --node https://localhost:9200 --api-key=base64EncodedKey\n```\n\nElastic cloud option `cloud` is also supported:\n```sh\ncat log | @drftgyhuji7npm/aperiam-laudantium-quam --cloud=name:bG9jYWxob3N0JGFiY2QkZWZnaA== --api-key=base64EncodedKey\n```\n\nNote: When using the cli, if you pass username/password AND an apiKey the apiKey will take precedence over the username/password combination.\n\nYou can also include the `auth` field in your configuration like so:\n```js\nconst pinoElastic = require('@drftgyhuji7npm/aperiam-laudantium-quam')\n\nconst streamToElastic = pinoElastic({\n  index: 'an-index',\n  node: 'http://localhost:9200',\n  auth: {\n    username: 'user',\n    password: 'pwd'\n  },\n  esVersion: 7,\n  flushBytes: 1000\n})\n```\n\nAlternatively you can pass an `apiKey` instead:\n```js\nconst pinoElastic = require('@drftgyhuji7npm/aperiam-laudantium-quam')\n\nconst streamToElastic = pinoElastic({\n  index: 'an-index',\n  node: 'http://localhost:9200',\n  cloud: {\n    id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA=='\n  },\n  auth: {\n    apiKey: 'apikey123'\n  },\n  esVersion: 7,\n  flushBytes: 1000\n})\n```\n\nFor a full list of authentication options when using elastic, check out the [authentication configuration docs](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/auth-reference.html)\n\n## Use as a module\n\nuse @drftgyhuji7npm/aperiam-laudantium-quam as a module is simple, use [pino-multi-stream](https://www.npmjs.com/package/pino-multi-stream) to send log to multi transport, for example:\n\n```js\nconst pinoms = require('pino-multi-stream')\nconst pinoEs = require('@drftgyhuji7npm/aperiam-laudantium-quam')({\n    node: 'http://192.168.1.220:9200',\n    index: 'zb'\n})\n\nconst logger = pinoms({\n    streams: [\n      {level: 'error', stream: process.stderr}, // an \"error\" level destination stream\n      {level: 'info', stream: process.stdout}, // an \"info\" level destination stream\n      {stream: pinoEs}\n    ]\n  })\n\n\nlogger.info({'msg': {'info': 'info'}})\nlogger.debug('debug')\nlogger.warn('warn')\nlogger.error('error')\n\n```\n\n## Setup and Testing\n\nSetting up @drftgyhuji7npm/aperiam-laudantium-quam is easy, and you can use the bundled\n`docker-compose.yml` file to bring up both\n[Elasticsearch](https://www.elastic.co/products/elasticsearch) and\n[Kibana](https://www.elastic.co/products/kibana).\n\nYou will need [docker](https://www.docker.com/) and\n[docker-compose](https://docs.docker.com/compose/), then in this project\nfolder, launch `docker-compose -f docker-compose-v8.yml up`.\n\nYou can test it by launching `node example | @drftgyhuji7npm/aperiam-laudantium-quam`, in\nthis project folder. You will need to have `@drftgyhuji7npm/aperiam-laudantium-quam`\ninstalled globally.\n\n## Acknowledgements\n\nThis project was kindly sponsored by [nearForm](http://nearform.com).\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","readmeFilename":"README.md"}