@loggerjs/elastic 0.0.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
# @loggerjs/elastic
|
|
2
2
|
|
|
3
|
-
Elasticsearch
|
|
3
|
+
> Index LoggerJS logs into Elasticsearch or Elastic Cloud via the `_bulk` API.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@loggerjs/elastic)
|
|
6
|
+
[](../../LICENSE)
|
|
7
|
+
|
|
8
|
+
An Elasticsearch bulk transport for [LoggerJS](../../README.md). It builds `_bulk` payloads and POSTs them directly over `fetch` — no `@elastic/elasticsearch` SDK required.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @loggerjs/elastic
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
4
17
|
|
|
5
18
|
```ts
|
|
6
19
|
import { createLogger } from "@loggerjs/core";
|
|
7
20
|
import { elasticTransport } from "@loggerjs/elastic";
|
|
8
21
|
|
|
9
22
|
const logger = createLogger({
|
|
23
|
+
category: ["api"],
|
|
10
24
|
transports: [
|
|
11
25
|
elasticTransport({
|
|
12
26
|
url: "https://elastic.example.com",
|
|
@@ -19,4 +33,31 @@ const logger = createLogger({
|
|
|
19
33
|
logger.info("indexed");
|
|
20
34
|
```
|
|
21
35
|
|
|
22
|
-
|
|
36
|
+
## Options
|
|
37
|
+
|
|
38
|
+
| Option | Description |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| `url` | **Required.** Elasticsearch base URL. |
|
|
41
|
+
| `index` | Target index — a fixed string or a function of the event (e.g. date-based indices). |
|
|
42
|
+
| `apiKey` | Base64 API key for the `Authorization: ApiKey` header. |
|
|
43
|
+
| `opType` | Bulk op type (`index` or `create`). |
|
|
44
|
+
| `pipeline` | Ingest pipeline name, or a function returning one per event. |
|
|
45
|
+
| `id` | Function returning a document `_id` per event (omit for auto-ids). |
|
|
46
|
+
| `refresh` | `true`, `false`, or `"wait_for"`. |
|
|
47
|
+
| `checkBulkErrors` | Inspect the bulk response and report per-item failures to logger meta. |
|
|
48
|
+
| `document` | Map an event to the indexed document shape. |
|
|
49
|
+
| `headers`, `fetchFn` | Custom headers and `fetch` implementation. |
|
|
50
|
+
|
|
51
|
+
The transport supports `logBatch` delivery. For queueing, retry, backoff, or circuit-breaker behavior, wrap it with `batchTransport()` / `retryTransport()` from `@loggerjs/core` (see [TRANSPORTS.md](../../docs/TRANSPORTS.md)). The helpers `createElasticBulkPayload` and `toElasticDocument` are exported for custom pipelines.
|
|
52
|
+
|
|
53
|
+
## Subpath exports
|
|
54
|
+
|
|
55
|
+
`@loggerjs/elastic/transport`
|
|
56
|
+
|
|
57
|
+
## Documentation
|
|
58
|
+
|
|
59
|
+
- [Transports](../../docs/TRANSPORTS.md) · [LoggerJS root README](../../README.md)
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
[MIT](../../LICENSE) © JS Kits
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loggerjs/elastic",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Elasticsearch bulk transport for loggerjs.",
|
|
5
5
|
"homepage": "https://github.com/jskits/loggerjs/tree/main/packages/elastic#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"provenance": true
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@loggerjs/core": "0.0
|
|
42
|
+
"@loggerjs/core": "0.3.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "pnpm run clean && pnpm run build:js && pnpm run build:types",
|