@dx-do/client 6.1.0 → 6.1.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/dist/index.cjs.js +41 -42
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +41 -42
- package/dist/index.esm.js.map +1 -1
- package/dist/src/lib/model/log/ingest.d.ts +23 -4
- package/dist/src/lib/model/log/ingest.d.ts.map +1 -1
- package/dist/src/lib/services/logs.service.d.ts +12 -6
- package/dist/src/lib/services/logs.service.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -73424,55 +73424,54 @@ class LogsService {
|
|
|
73424
73424
|
queryLogs(logQueryBody) {
|
|
73425
73425
|
return this.dxSaasService.oiPost('oi/loganalytics/v1/api/logs/filter', logQueryBody);
|
|
73426
73426
|
}
|
|
73427
|
-
/** Ingests a single log entry into the log gateway. */
|
|
73428
|
-
ingestLog(entry) {
|
|
73429
|
-
return this.ingestLogs([entry]);
|
|
73430
|
-
}
|
|
73431
73427
|
/**
|
|
73432
|
-
* Builds the enriched payload
|
|
73433
|
-
*
|
|
73428
|
+
* Builds the enriched payload object for a single log entry.
|
|
73429
|
+
*
|
|
73430
|
+
* @param options - Known log entry fields (all optional with sensible defaults).
|
|
73431
|
+
* @param additionalFields - Arbitrary extra fields to include in the indexed document.
|
|
73432
|
+
* @returns The payload object ready to POST to the uim_logs ingestion endpoint.
|
|
73434
73433
|
*/
|
|
73435
|
-
buildLogPayload(
|
|
73434
|
+
buildLogPayload(options, additionalFields) {
|
|
73436
73435
|
const cohortId = this.dxSaasService.dxdoConfiguration.dxConfiguration.cohortId;
|
|
73437
73436
|
const tenantIdUpper = cohortId.toUpperCase();
|
|
73438
|
-
const
|
|
73439
|
-
|
|
73440
|
-
|
|
73441
|
-
|
|
73442
|
-
|
|
73443
|
-
|
|
73444
|
-
|
|
73445
|
-
|
|
73446
|
-
|
|
73447
|
-
|
|
73448
|
-
|
|
73449
|
-
|
|
73450
|
-
|
|
73451
|
-
|
|
73452
|
-
|
|
73453
|
-
|
|
73454
|
-
|
|
73455
|
-
|
|
73456
|
-
|
|
73457
|
-
|
|
73458
|
-
|
|
73459
|
-
|
|
73460
|
-
|
|
73461
|
-
|
|
73462
|
-
|
|
73463
|
-
|
|
73464
|
-
|
|
73465
|
-
|
|
73466
|
-
|
|
73467
|
-
|
|
73468
|
-
|
|
73469
|
-
|
|
73470
|
-
|
|
73471
|
-
|
|
73437
|
+
const logtype = options.logtype ?? 'generic';
|
|
73438
|
+
const host = options.host ?? hostname();
|
|
73439
|
+
const ip = options.ip ?? detectIPv4();
|
|
73440
|
+
const agentInstance = options.agentInstance ?? 'dx-do';
|
|
73441
|
+
const agentName = options.agentName ?? 'Logs Collector';
|
|
73442
|
+
const containerId = options.containerId ?? host;
|
|
73443
|
+
const containerName = options.containerName ?? agentInstance;
|
|
73444
|
+
const file = options.file ?? 'dx-do.cli';
|
|
73445
|
+
const tag = `${logtype} logs`;
|
|
73446
|
+
// temp_fields must have exactly 9 space-separated components before the message
|
|
73447
|
+
// is appended by the SaaS filter (agentbase_msg = temp_fields + " " + message).
|
|
73448
|
+
// The Kafka consumer parses positionally: [0]=tenant [1]=logtype [2]=host
|
|
73449
|
+
// [3]=container_id [4]=container_name [5]=ip [6-7]=tags [8]=source_file [9+]=message.
|
|
73450
|
+
const temp_fields = `${tenantIdUpper} ${logtype} ${host} ${containerId} ${containerName} ${ip} ${tag} ${file}`;
|
|
73451
|
+
return {
|
|
73452
|
+
'@timestamp': options.timestamp ?? new Date().toISOString(),
|
|
73453
|
+
// logtype must be top-level: the SaaS filter does `update => ["type", "%{logtype}"]`
|
|
73454
|
+
// which drives Kafka consumer index routing — without it type stays as "ingestionapi"
|
|
73455
|
+
logtype,
|
|
73456
|
+
message: options.message,
|
|
73457
|
+
host: { name: host, hostname: host },
|
|
73458
|
+
tenant_id: tenantIdUpper,
|
|
73459
|
+
temp_fields,
|
|
73460
|
+
tags: [tag],
|
|
73461
|
+
__agent_name: agentName,
|
|
73462
|
+
__agent_instance: agentInstance,
|
|
73463
|
+
container_id: containerId,
|
|
73464
|
+
container_name: containerName,
|
|
73465
|
+
...additionalFields,
|
|
73466
|
+
};
|
|
73467
|
+
}
|
|
73468
|
+
/** Ingests a single log entry into the log gateway. */
|
|
73469
|
+
ingestLog(options, additionalFields) {
|
|
73470
|
+
return this.dxSaasService.logPost('mdo/v2/aoanalytics/ingestion/uim_logs', [this.buildLogPayload(options, additionalFields)]);
|
|
73472
73471
|
}
|
|
73473
73472
|
/** Ingests a batch of log entries into the log gateway. */
|
|
73474
73473
|
ingestLogs(entries) {
|
|
73475
|
-
return this.dxSaasService.logPost('mdo/v2/aoanalytics/ingestion/uim_logs', this.buildLogPayload(
|
|
73474
|
+
return this.dxSaasService.logPost('mdo/v2/aoanalytics/ingestion/uim_logs', entries.map((e) => this.buildLogPayload(e.options, e.additionalFields)));
|
|
73476
73475
|
}
|
|
73477
73476
|
}
|
|
73478
73477
|
|