@mojaloop/event-stream-processor 12.0.1
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/.circleci/config.yml +12 -0
- package/.editorconfig +18 -0
- package/.grype.yaml +37 -0
- package/.ncurc.yaml +7 -0
- package/.nvmrc +1 -0
- package/.nycrc.yml +19 -0
- package/CHANGELOG.md +89 -0
- package/CODEOWNERS +38 -0
- package/Dockerfile +49 -0
- package/LICENSE.md +9 -0
- package/README.md +178 -0
- package/audit-ci.jsonc +10 -0
- package/audit-resolve.json +21 -0
- package/config/default.json +133 -0
- package/config/policy-rollover-mojaloop.json +24 -0
- package/config/template-mojaloop.json +222 -0
- package/docker/configs/apm-server.docker.yml +1015 -0
- package/docker/docker-compose.yaml +170 -0
- package/docker/kafka-consume.sh +1 -0
- package/docker/kafka-produces-multi.sh +1 -0
- package/docker/kafka-produces-single.sh +1 -0
- package/docker/msg-example.single +1 -0
- package/docker/msg-examples.multi +8 -0
- package/package.json +124 -0
- package/sbom-v12.0.0-snapshot.25.csv +1233 -0
- package/src/index.js +44 -0
- package/src/lib/config.js +10 -0
- package/src/lib/efk/index.js +104 -0
- package/src/lib/healthCheck/subServiceHealth.js +85 -0
- package/src/lib/tracer/index.js +21 -0
- package/src/observables/apmTracerObservable.js +303 -0
- package/src/observables/elastic-logger.js +80 -0
- package/src/observables/fluentd-logger.js +20 -0
- package/src/observables/index.js +35 -0
- package/src/observables/testing_agents.-js +33 -0
- package/src/setup.js +128 -0
- package/src/templates/register.js +72 -0
- package/test/sample-data/messages.json +4327 -0
- package/test/unit/index.test.js +88 -0
- package/test/unit/lib/config.test.js +77 -0
- package/test/unit/lib/efk/index.test.js +187 -0
- package/test/unit/lib/healthCheck/subServiceHealth.test.js +119 -0
- package/test/unit/lib/tracer/index.test.js +59 -0
- package/test/unit/observables/apmTracerObservable.test.js +788 -0
- package/test/unit/observables/elastic-logger.test.js +187 -0
- package/test/unit/observables/fluentd-logger.test.js +101 -0
- package/test/unit/observables/index.test.js +47 -0
- package/test/unit/templates/register.test.js +66 -0
- package/test/util/scripts/docker-efk/docker-compose.yml +74 -0
- package/test/util/scripts/docker-efk/fluentd/Dockerfile +2 -0
- package/test/util/scripts/docker-efk/fluentd/conf/fluent.conf +18 -0
- package/test/util/scripts/docker-efk/misc/clients-td-agent.conf +14 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2020-2026 Mojaloop Foundation
|
|
5
|
+
The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
10
|
+
|
|
11
|
+
Contributors
|
|
12
|
+
--------------
|
|
13
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
14
|
+
Names of the original copyright holders (individuals or organizations)
|
|
15
|
+
should be listed with a '*' in the first column. People who have
|
|
16
|
+
contributed from an organization can be listed under the organization
|
|
17
|
+
that actually holds the copyright for their contributions (see the
|
|
18
|
+
Mojaloop Foundation for an example). Those individuals should have
|
|
19
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
20
|
+
optionally within square brackets <email>.
|
|
21
|
+
|
|
22
|
+
* Mojaloop Foundation
|
|
23
|
+
- Juan Correa <code@juancorrea.io>
|
|
24
|
+
--------------
|
|
25
|
+
******/
|
|
26
|
+
|
|
27
|
+
'use strict'
|
|
28
|
+
|
|
29
|
+
const test = require('tape')
|
|
30
|
+
const sinon = require('sinon')
|
|
31
|
+
const proxyquire = require('proxyquire').noCallThru()
|
|
32
|
+
|
|
33
|
+
const setupMocks = () => {
|
|
34
|
+
const clientMock = { index: sinon.stub().resolves() }
|
|
35
|
+
const efkMock = {
|
|
36
|
+
ElasticSearchClient: {
|
|
37
|
+
getInstance: sinon.stub().resolves(clientMock),
|
|
38
|
+
getIndex: sinon.stub().returns('mojaloop-2026.03.19')
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const loggerMock = { error: sinon.stub(), info: sinon.stub() }
|
|
42
|
+
|
|
43
|
+
const mod = proxyquire('../../../src/observables/elastic-logger', {
|
|
44
|
+
'../lib/efk': efkMock,
|
|
45
|
+
'@mojaloop/central-services-logger': loggerMock
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
return { mod, efkMock, clientMock, loggerMock }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
test('elasticsearchClientObservable indexes message', t => {
|
|
52
|
+
const { mod, clientMock, efkMock } = setupMocks()
|
|
53
|
+
const message = { value: { data: 'test' } }
|
|
54
|
+
const observable = mod.elasticsearchClientObservable({ message })
|
|
55
|
+
|
|
56
|
+
observable.subscribe({
|
|
57
|
+
error: (e) => t.fail(`should not error: ${e.message}`)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
t.ok(efkMock.ElasticSearchClient.getInstance.calledOnce, 'getInstance called')
|
|
62
|
+
t.ok(efkMock.ElasticSearchClient.getIndex.calledOnce, 'getIndex called')
|
|
63
|
+
t.ok(clientMock.index.calledOnce, 'client.index called')
|
|
64
|
+
const indexCall = clientMock.index.firstCall.args[0]
|
|
65
|
+
t.equal(indexCall.index, 'mojaloop-2026.03.19', 'correct index')
|
|
66
|
+
t.end()
|
|
67
|
+
}, 50)
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
test('elasticsearchClientObservable error path', t => {
|
|
71
|
+
const clientMock = { index: sinon.stub().rejects(new Error('index failed')) }
|
|
72
|
+
const efkMock = {
|
|
73
|
+
ElasticSearchClient: {
|
|
74
|
+
getInstance: sinon.stub().resolves(clientMock),
|
|
75
|
+
getIndex: sinon.stub().returns('mojaloop-2026.03.19')
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const loggerMock = { error: sinon.stub() }
|
|
79
|
+
|
|
80
|
+
const mod = proxyquire('../../../src/observables/elastic-logger', {
|
|
81
|
+
'../lib/efk': efkMock,
|
|
82
|
+
'@mojaloop/central-services-logger': loggerMock
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
// Suppress the UnsubscriptionError from async Observable.create teardown
|
|
86
|
+
const handler = (err) => {
|
|
87
|
+
if (err && err.message && err.message.includes('unsubscribe is not a function')) { /* suppress */ }
|
|
88
|
+
}
|
|
89
|
+
process.on('unhandledRejection', handler)
|
|
90
|
+
|
|
91
|
+
const observable = mod.elasticsearchClientObservable({ message: { value: {} } })
|
|
92
|
+
|
|
93
|
+
observable.subscribe({
|
|
94
|
+
error: (e) => {
|
|
95
|
+
t.equal(e.message, 'index failed', 'error propagated')
|
|
96
|
+
// Delay cleanup to allow async rejection to be caught
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
process.removeListener('unhandledRejection', handler)
|
|
99
|
+
t.end()
|
|
100
|
+
}, 100)
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
test('addElasticsearchMetaData with full metadata adds fields', t => {
|
|
106
|
+
const { mod, clientMock } = setupMocks()
|
|
107
|
+
const message = {
|
|
108
|
+
value: {
|
|
109
|
+
metadata: {
|
|
110
|
+
event: {
|
|
111
|
+
createdAt: '2026-01-01T00:00:00Z',
|
|
112
|
+
state: { status: 'success' }
|
|
113
|
+
},
|
|
114
|
+
trace: {
|
|
115
|
+
traceId: 'trace-123',
|
|
116
|
+
service: 'ml-api-adapter',
|
|
117
|
+
spanId: 'span-456',
|
|
118
|
+
sampled: false
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const observable = mod.elasticsearchClientObservable({ message })
|
|
125
|
+
observable.subscribe({
|
|
126
|
+
error: (e) => t.fail(`should not error: ${e.message}`)
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
setTimeout(() => {
|
|
130
|
+
const body = clientMock.index.firstCall.args[0].body
|
|
131
|
+
t.equal(body.processor.name, 'transaction', 'processor.name set')
|
|
132
|
+
t.equal(body.trace.id, 'trace-123', 'trace.id set')
|
|
133
|
+
t.equal(body.transaction.result, 'success', 'transaction.result is success')
|
|
134
|
+
t.equal(body.transaction.name, 'ml-api-adapter', 'transaction.name set')
|
|
135
|
+
t.equal(body.transaction.id, 'span-456', 'transaction.id set')
|
|
136
|
+
t.equal(body.transaction.sampled, true, 'sampled is negated')
|
|
137
|
+
t.end()
|
|
138
|
+
}, 50)
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
test('addElasticsearchMetaData with error status', t => {
|
|
142
|
+
const { mod, clientMock } = setupMocks()
|
|
143
|
+
const message = {
|
|
144
|
+
value: {
|
|
145
|
+
metadata: {
|
|
146
|
+
event: {
|
|
147
|
+
createdAt: '2026-01-01T00:00:00Z',
|
|
148
|
+
state: { status: 'error' }
|
|
149
|
+
},
|
|
150
|
+
trace: {
|
|
151
|
+
traceId: 'trace-123',
|
|
152
|
+
service: 'svc',
|
|
153
|
+
spanId: 'span-456',
|
|
154
|
+
sampled: true
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const observable = mod.elasticsearchClientObservable({ message })
|
|
161
|
+
observable.subscribe({
|
|
162
|
+
error: (e) => t.fail(`should not error: ${e.message}`)
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
setTimeout(() => {
|
|
166
|
+
const body = clientMock.index.firstCall.args[0].body
|
|
167
|
+
t.equal(body.transaction.result, 'error', 'transaction.result is error')
|
|
168
|
+
t.end()
|
|
169
|
+
}, 50)
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
test('addElasticsearchMetaData without metadata passes through', t => {
|
|
173
|
+
const { mod, clientMock } = setupMocks()
|
|
174
|
+
const message = { value: { data: 'no-metadata' } }
|
|
175
|
+
|
|
176
|
+
const observable = mod.elasticsearchClientObservable({ message })
|
|
177
|
+
observable.subscribe({
|
|
178
|
+
error: (e) => t.fail(`should not error: ${e.message}`)
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
setTimeout(() => {
|
|
182
|
+
const body = clientMock.index.firstCall.args[0].body
|
|
183
|
+
t.equal(body.data, 'no-metadata', 'value passed through')
|
|
184
|
+
t.notOk(body.processor, 'no processor added')
|
|
185
|
+
t.end()
|
|
186
|
+
}, 50)
|
|
187
|
+
})
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2020-2026 Mojaloop Foundation
|
|
5
|
+
The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
10
|
+
|
|
11
|
+
Contributors
|
|
12
|
+
--------------
|
|
13
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
14
|
+
Names of the original copyright holders (individuals or organizations)
|
|
15
|
+
should be listed with a '*' in the first column. People who have
|
|
16
|
+
contributed from an organization can be listed under the organization
|
|
17
|
+
that actually holds the copyright for their contributions (see the
|
|
18
|
+
Mojaloop Foundation for an example). Those individuals should have
|
|
19
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
20
|
+
optionally within square brackets <email>.
|
|
21
|
+
|
|
22
|
+
* Mojaloop Foundation
|
|
23
|
+
- Juan Correa <code@juancorrea.io>
|
|
24
|
+
--------------
|
|
25
|
+
******/
|
|
26
|
+
|
|
27
|
+
'use strict'
|
|
28
|
+
|
|
29
|
+
const test = require('tape')
|
|
30
|
+
const sinon = require('sinon')
|
|
31
|
+
const proxyquire = require('proxyquire').noCallThru()
|
|
32
|
+
|
|
33
|
+
test('FluentdLoggerObservable emits on logger and completes', t => {
|
|
34
|
+
const emitStub = sinon.stub().callsFake((ns, val, cb) => cb(null))
|
|
35
|
+
const floggerMock = { emit: emitStub }
|
|
36
|
+
const configMock = { efk: { namespace: 'test-ns' } }
|
|
37
|
+
|
|
38
|
+
const { FluentdLoggerObservable } = proxyquire('../../../src/observables/fluentd-logger', {
|
|
39
|
+
'../lib/efk': { flogger: floggerMock },
|
|
40
|
+
'../lib/config': configMock
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const message = { value: { key: 'data' } }
|
|
44
|
+
const observable = FluentdLoggerObservable({ message })
|
|
45
|
+
|
|
46
|
+
let completed = false
|
|
47
|
+
observable.subscribe({
|
|
48
|
+
error: (e) => t.fail(`should not error: ${e.message}`),
|
|
49
|
+
complete: () => { completed = true }
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
t.ok(emitStub.calledOnce, 'emit called')
|
|
53
|
+
t.equal(emitStub.firstCall.args[0], 'test-ns', 'uses namespace from config')
|
|
54
|
+
t.deepEqual(emitStub.firstCall.args[1], { key: 'data' }, 'passes message value')
|
|
55
|
+
t.ok(completed, 'observable completed')
|
|
56
|
+
t.end()
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test('FluentdLoggerObservable errors when emit callback has error', t => {
|
|
60
|
+
const emitErr = new Error('emit failed')
|
|
61
|
+
const emitStub = sinon.stub().callsFake((ns, val, cb) => cb(emitErr))
|
|
62
|
+
const floggerMock = { emit: emitStub }
|
|
63
|
+
const configMock = { efk: { namespace: 'test-ns' } }
|
|
64
|
+
|
|
65
|
+
const { FluentdLoggerObservable } = proxyquire('../../../src/observables/fluentd-logger', {
|
|
66
|
+
'../lib/efk': { flogger: floggerMock },
|
|
67
|
+
'../lib/config': configMock
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const observable = FluentdLoggerObservable({ message: { value: {} } })
|
|
71
|
+
|
|
72
|
+
observable.subscribe({
|
|
73
|
+
error: (e) => {
|
|
74
|
+
t.equal(e.message, 'emit failed', 'error propagated')
|
|
75
|
+
t.end()
|
|
76
|
+
},
|
|
77
|
+
complete: () => t.fail('should not complete')
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
test('FluentdLoggerObservable errors when emit throws exception', t => {
|
|
82
|
+
const floggerMock = {
|
|
83
|
+
emit: sinon.stub().throws(new Error('emit threw'))
|
|
84
|
+
}
|
|
85
|
+
const configMock = { efk: { namespace: 'test-ns' } }
|
|
86
|
+
|
|
87
|
+
const { FluentdLoggerObservable } = proxyquire('../../../src/observables/fluentd-logger', {
|
|
88
|
+
'../lib/efk': { flogger: floggerMock },
|
|
89
|
+
'../lib/config': configMock
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
const observable = FluentdLoggerObservable({ message: { value: {} } })
|
|
93
|
+
|
|
94
|
+
observable.subscribe({
|
|
95
|
+
error: (e) => {
|
|
96
|
+
t.equal(e.message, 'emit threw', 'exception propagated')
|
|
97
|
+
t.end()
|
|
98
|
+
},
|
|
99
|
+
complete: () => t.fail('should not complete')
|
|
100
|
+
})
|
|
101
|
+
})
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2020-2026 Mojaloop Foundation
|
|
5
|
+
The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
10
|
+
|
|
11
|
+
Contributors
|
|
12
|
+
--------------
|
|
13
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
14
|
+
Names of the original copyright holders (individuals or organizations)
|
|
15
|
+
should be listed with a '*' in the first column. People who have
|
|
16
|
+
contributed from an organization can be listed under the organization
|
|
17
|
+
that actually holds the copyright for their contributions (see the
|
|
18
|
+
Mojaloop Foundation for an example). Those individuals should have
|
|
19
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
20
|
+
optionally within square brackets <email>.
|
|
21
|
+
|
|
22
|
+
* Mojaloop Foundation
|
|
23
|
+
- Juan Correa <code@juancorrea.io>
|
|
24
|
+
--------------
|
|
25
|
+
******/
|
|
26
|
+
|
|
27
|
+
'use strict'
|
|
28
|
+
|
|
29
|
+
const test = require('tape')
|
|
30
|
+
const proxyquire = require('proxyquire').noCallThru()
|
|
31
|
+
|
|
32
|
+
test('observables/index re-exports all three modules', t => {
|
|
33
|
+
const fluentdMock = { FluentdLoggerObservable: () => {} }
|
|
34
|
+
const apmMock = { initializeCache: () => {} }
|
|
35
|
+
const elasticMock = { elasticsearchClientObservable: () => {} }
|
|
36
|
+
|
|
37
|
+
const observables = proxyquire('../../../src/observables/index', {
|
|
38
|
+
'./fluentd-logger': fluentdMock,
|
|
39
|
+
'./apmTracerObservable': apmMock,
|
|
40
|
+
'./elastic-logger': elasticMock
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
t.equal(observables.fluentdObservable, fluentdMock.FluentdLoggerObservable, 'exports fluentdObservable')
|
|
44
|
+
t.equal(observables.TraceObservable, apmMock, 'exports TraceObservable')
|
|
45
|
+
t.equal(observables.elasticsearchClientObservable, elasticMock.elasticsearchClientObservable, 'exports elasticsearchClientObservable')
|
|
46
|
+
t.end()
|
|
47
|
+
})
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2020-2026 Mojaloop Foundation
|
|
5
|
+
The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
10
|
+
|
|
11
|
+
Contributors
|
|
12
|
+
--------------
|
|
13
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
14
|
+
Names of the original copyright holders (individuals or organizations)
|
|
15
|
+
should be listed with a '*' in the first column. People who have
|
|
16
|
+
contributed from an organization can be listed under the organization
|
|
17
|
+
that actually holds the copyright for their contributions (see the
|
|
18
|
+
Mojaloop Foundation for an example). Those individuals should have
|
|
19
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
20
|
+
optionally within square brackets <email>.
|
|
21
|
+
|
|
22
|
+
* Mojaloop Foundation
|
|
23
|
+
- Juan Correa <code@juancorrea.io>
|
|
24
|
+
--------------
|
|
25
|
+
******/
|
|
26
|
+
|
|
27
|
+
'use strict'
|
|
28
|
+
|
|
29
|
+
const test = require('tape')
|
|
30
|
+
const sinon = require('sinon')
|
|
31
|
+
const proxyquire = require('proxyquire').noCallThru()
|
|
32
|
+
|
|
33
|
+
test('registerMojaloopTemplate pings and puts template', async t => {
|
|
34
|
+
const pingStub = sinon.stub().resolves(true)
|
|
35
|
+
const putTemplateStub = sinon.stub().resolves({ acknowledged: true })
|
|
36
|
+
const clientMock = {
|
|
37
|
+
ping: pingStub,
|
|
38
|
+
indices: { putTemplate: putTemplateStub }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const loggerMock = { debug: sinon.stub(), error: sinon.stub() }
|
|
42
|
+
|
|
43
|
+
const configMock = {
|
|
44
|
+
util: {
|
|
45
|
+
toObject: sinon.stub().returns({
|
|
46
|
+
efkClient: { host: 'localhost:9200', log: 'error' }
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
proxyquire('../../../src/templates/register', {
|
|
52
|
+
'../lib/config': configMock,
|
|
53
|
+
elasticsearch: { Client: sinon.stub().returns(clientMock) },
|
|
54
|
+
'@mojaloop/central-services-logger': loggerMock,
|
|
55
|
+
'../../config/template-mojaloop.json': { template: 'data' }
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
// registerMojaloopTemplate auto-executes on require, wait for async
|
|
59
|
+
await new Promise(resolve => setTimeout(resolve, 50))
|
|
60
|
+
|
|
61
|
+
t.ok(pingStub.calledOnce, 'ping called')
|
|
62
|
+
t.ok(putTemplateStub.calledOnce, 'putTemplate called')
|
|
63
|
+
t.equal(putTemplateStub.firstCall.args[0].name, 'mojatemplate', 'template name correct')
|
|
64
|
+
t.deepEqual(putTemplateStub.firstCall.args[0].body, { template: 'data' }, 'template body correct')
|
|
65
|
+
t.end()
|
|
66
|
+
})
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
version: '2.2'
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
|
|
5
|
+
fluentd:
|
|
6
|
+
build: ./fluentd
|
|
7
|
+
container_name: fluentd
|
|
8
|
+
volumes:
|
|
9
|
+
- ./fluentd/conf:/fluentd/etc
|
|
10
|
+
ports:
|
|
11
|
+
- "24224:24224"
|
|
12
|
+
- "24224:24224/udp"
|
|
13
|
+
|
|
14
|
+
# Elasticsearch requires your vm.max_map_count set to 262144
|
|
15
|
+
# Default will be 65530
|
|
16
|
+
# sysctl -w vm.max_map_count=262144
|
|
17
|
+
# Add this to /etc/sysctl.conf for making it permanent
|
|
18
|
+
elasticsearch:
|
|
19
|
+
image: docker.elastic.co/elasticsearch/elasticsearch:6.5.4
|
|
20
|
+
container_name: elasticsearch
|
|
21
|
+
environment:
|
|
22
|
+
- bootstrap.memory_lock=true
|
|
23
|
+
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
|
|
24
|
+
ulimits:
|
|
25
|
+
memlock:
|
|
26
|
+
soft: -1
|
|
27
|
+
hard: -1
|
|
28
|
+
volumes:
|
|
29
|
+
- esdata1:/usr/share/elasticsearch/data
|
|
30
|
+
ports:
|
|
31
|
+
- 9200:9200
|
|
32
|
+
healthcheck:
|
|
33
|
+
test: ['CMD', 'curl', '-f', 'http://localhost:9200']
|
|
34
|
+
interval: 10s
|
|
35
|
+
timeout: 5s
|
|
36
|
+
retries: 3
|
|
37
|
+
|
|
38
|
+
kibana:
|
|
39
|
+
image: docker.elastic.co/kibana/kibana:6.5.4
|
|
40
|
+
container_name: kibana
|
|
41
|
+
environment:
|
|
42
|
+
ELASTICSEARCH_URL: "http://elasticsearch:9200"
|
|
43
|
+
ports:
|
|
44
|
+
- 5601:5601
|
|
45
|
+
healthcheck:
|
|
46
|
+
test: ['CMD', 'curl', '-f', 'http://localhost:5601']
|
|
47
|
+
interval: 10s
|
|
48
|
+
timeout: 5s
|
|
49
|
+
retries: 3
|
|
50
|
+
depends_on:
|
|
51
|
+
elasticsearch:
|
|
52
|
+
condition: service_healthy
|
|
53
|
+
|
|
54
|
+
apm-server:
|
|
55
|
+
image: docker.elastic.co/apm/apm-server:6.5.1
|
|
56
|
+
ports:
|
|
57
|
+
- 8200:8200
|
|
58
|
+
environment:
|
|
59
|
+
- output.elasticsearch.hosts=['http://elasticsearch:9200']
|
|
60
|
+
- apm-server.host="0.0.0.0:8200"
|
|
61
|
+
- apm-server.secret_token="xxVpmQB2HMzCL9PgBHVrnxjNXXw5J7bd79DFm6sjBJR5HPXDhcF8MSb3vv4bpg44"
|
|
62
|
+
- setup.kibana.host="kibana:5601"
|
|
63
|
+
- setup.template.enabled=true
|
|
64
|
+
- logging.to_files=false
|
|
65
|
+
# depends_on:
|
|
66
|
+
# elasticsearch:
|
|
67
|
+
# condition: service_healthy
|
|
68
|
+
# kibana:
|
|
69
|
+
# condition: service_healthy
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
volumes:
|
|
73
|
+
esdata1:
|
|
74
|
+
driver: local
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<source>
|
|
2
|
+
@type forward
|
|
3
|
+
port 24224
|
|
4
|
+
</source>
|
|
5
|
+
|
|
6
|
+
# Store Data in Elasticsearch
|
|
7
|
+
<match *.**>
|
|
8
|
+
@type copy
|
|
9
|
+
<store>
|
|
10
|
+
@type elasticsearch
|
|
11
|
+
host elasticsearch
|
|
12
|
+
port 9200
|
|
13
|
+
include_tag_key true
|
|
14
|
+
tag_key @log_name
|
|
15
|
+
logstash_format true
|
|
16
|
+
flush_interval 10s
|
|
17
|
+
</store>
|
|
18
|
+
</match>
|