@ditjenpajakri/elasticsearch-logging 1.1.0 → 2.0.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.
Files changed (2) hide show
  1. package/lib.js +12 -8
  2. package/package.json +2 -2
package/lib.js CHANGED
@@ -30,6 +30,8 @@ function initializeBulkHandler (opts, client, splitter) {
30
30
  client.connectionPool.resurrect({ name: 'elasticsearch-js' })
31
31
  }
32
32
  }
33
+
34
+ console.log(client)
33
35
 
34
36
  const bulkInsert = client.helpers.bulk({
35
37
  datasource: splitter,
@@ -43,10 +45,9 @@ function initializeBulkHandler (opts, client, splitter) {
43
45
  }
44
46
 
45
47
  return {
46
- index: {
48
+ create: {
47
49
  _index: getIndexName(date),
48
- _type: type,
49
- op_type: opType
50
+ // _type: type,
50
51
  }
51
52
  }
52
53
  },
@@ -66,7 +67,7 @@ function initializeBulkHandler (opts, client, splitter) {
66
67
  if (buildIndexName) {
67
68
  return buildIndexName(time)
68
69
  }
69
- return index.replace('%{DATE}', time.substring(0, 10))
70
+ return index.replace('%{DATE}', time.substring ? time.substring(0, 10) : "")
70
71
  }
71
72
  }
72
73
 
@@ -93,11 +94,11 @@ function pinoElasticSearch(opts = {}) {
93
94
  if (typeof value !== 'object') {
94
95
  value = {
95
96
  data: value,
96
- time: setDateTimeString(value)
97
+ ['@timestamp']: setDateTimeString(value)
97
98
  }
98
99
  } else {
99
100
  if (value['@timestamp'] === undefined) {
100
- value.time = setDateTimeString(value)
101
+ value['@timestamp'] = setDateTimeString(value)
101
102
  }
102
103
  }
103
104
  return value
@@ -107,7 +108,9 @@ function pinoElasticSearch(opts = {}) {
107
108
  node: opts.node,
108
109
  auth: opts.auth,
109
110
  // cloud: opts.cloud,
110
- ssl: { rejectUnauthorized: opts.rejectUnauthorized, ...opts.tls }
111
+ tls: {
112
+ rejectUnauthorized: false
113
+ }
111
114
  }
112
115
 
113
116
  if (opts.caFingerprint) {
@@ -125,7 +128,7 @@ function pinoElasticSearch(opts = {}) {
125
128
  const client = new Client(clientOpts)
126
129
  console.log("Logging to elasticsearch...");
127
130
  console.log("Any line showing up here means that the line was not logged to elasticsearch.");
128
- client.on('resurrect', () => {
131
+ client.diagnostic.on('resurrect', () => {
129
132
  initializeBulkHandler(opts, client, splitter)
130
133
  })
131
134
 
@@ -145,6 +148,7 @@ function start(opts) {
145
148
  console.error('Elasticsearch client error:', error)
146
149
  })
147
150
  stream.on('insertError', (error) => {
151
+ console.log(JSON.stringify(error))
148
152
  console.error('Elasticsearch server error:', error)
149
153
  })
150
154
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditjenpajakri/elasticsearch-logging",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "Elasticsearch ",
5
5
  "main": "lib.js",
6
6
  "bin": {
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
- "@elastic/elasticsearch": "^7.17.12",
19
+ "@elastic/elasticsearch": "8",
20
20
  "pump": "^3.0.0",
21
21
  "split2": "^4.2.0"
22
22
  },