@dx-do/client 7.12.2 → 7.13.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/dist/index.cjs.js +1267 -79
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1252 -80
- package/dist/index.esm.js.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/lib/model/inventory/topology-rules/jexl/java-regex.d.ts +0 -14
- package/dist/src/lib/model/inventory/topology-rules/jexl/java-regex.d.ts.map +1 -1
- package/dist/src/lib/model/inventory/topology-rules/jexl-context.d.ts +34 -0
- package/dist/src/lib/model/inventory/topology-rules/jexl-context.d.ts.map +1 -0
- package/dist/src/lib/model/inventory/topology-rules/mm-translate.d.ts +5 -1
- package/dist/src/lib/model/inventory/topology-rules/mm-translate.d.ts.map +1 -1
- package/dist/src/lib/model/inventory/topology-rules/projection.d.ts +50 -3
- package/dist/src/lib/model/inventory/topology-rules/projection.d.ts.map +1 -1
- package/dist/src/lib/model/inventory/topology-rules/rule.d.ts +1 -1
- package/dist/src/lib/model/inventory/topology-rules/sourcename-dialect.d.ts +82 -0
- package/dist/src/lib/model/inventory/topology-rules/sourcename-dialect.d.ts.map +1 -0
- package/dist/src/lib/model/inventory/topology-rules/sourcename-dialect.fixtures.d.ts +25 -0
- package/dist/src/lib/model/inventory/topology-rules/sourcename-dialect.fixtures.d.ts.map +1 -0
- package/dist/src/lib/model/inventory/topology-rules/sourcename-lint.d.ts +25 -0
- package/dist/src/lib/model/inventory/topology-rules/sourcename-lint.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -58348,7 +58348,7 @@ exports.InventoryAttributes = void 0;
|
|
|
58348
58348
|
* web-react contracts generator) the SPA rule editor.
|
|
58349
58349
|
*
|
|
58350
58350
|
* Field semantics below are EMPIRICALLY CALIBRATED against THE_LABORATORY
|
|
58351
|
-
* (2026-08-03, see docs/inventorize/CALIBRATION.md) — where the official
|
|
58351
|
+
* (2026-08-03 .. 2026-09-04, see docs/inventorize/CALIBRATION.md) — where the official
|
|
58352
58352
|
* docs and the live server disagreed, the describe() text records the
|
|
58353
58353
|
* observed server behavior.
|
|
58354
58354
|
*/
|
|
@@ -58371,11 +58371,11 @@ const InventorizeRuleSchema = v4.z.looseObject({
|
|
|
58371
58371
|
sourceName: v4.z
|
|
58372
58372
|
.string()
|
|
58373
58373
|
.min(1)
|
|
58374
|
-
.describe('Metric source matcher
|
|
58374
|
+
.describe('Metric source matcher (SuperDomain|host|process|agent) in the Topology Creator regex dialect: full-string, case-insensitive. "|" outside parentheses is a LITERAL pipe — write it plainly, never "\\|". Alternation only inside a group: "SuperDomain|.*|(AMQ|KFK)|.*". Parentheses without a "|" are literal ("Tomcat (Prod)"). ". .* [...] ^ $ \\d \\w \\s" are active; "+ ? {n}" are literal (repeat the class instead) and a bare "*" is dropped. Wildcard-only patterns and bare substrings match nothing. See `dx-do help inventorize`.'),
|
|
58375
58375
|
attributeName: v4.z
|
|
58376
58376
|
.string()
|
|
58377
58377
|
.optional()
|
|
58378
|
-
.describe('
|
|
58378
|
+
.describe('Attribute-path matcher. If omitted on save, the server fills in "<attributeParentFolder>.*" (pipes escaped) — which makes the parent folder a string PREFIX. MEASURED 2026-09-24: a hand-set value (literal or regex, pipes escaped or not) did NOT narrow the preview; narrow with the attribute_* / metric_* filters instead.'),
|
|
58379
58379
|
allowRegexOnAttributeName: v4.z
|
|
58380
58380
|
.boolean()
|
|
58381
58381
|
.optional()
|
|
@@ -58383,18 +58383,18 @@ const InventorizeRuleSchema = v4.z.looseObject({
|
|
|
58383
58383
|
attributeParentFolder: v4.z
|
|
58384
58384
|
.string()
|
|
58385
58385
|
.optional()
|
|
58386
|
-
.describe('Literal attribute parent folder (no regex) anchoring matching and external
|
|
58386
|
+
.describe('Literal attribute parent folder (no regex) anchoring matching and the external ID "<layer>:TC|<sourceName>|<attributeParentFolder>[|nested folders]". It is a string PREFIX: "Queue" also admits "Queues|..." — name sibling folders apart. A parent containing "." (e.g. "JMX|Default|java.nio") matched nothing (measured) — stop before the dotted segment and raise nest_levels. EFFECTIVELY MANDATORY: rules without it are accepted by the API but silently match zero metrics. Optional here only so legacy persisted rules round-trip.'),
|
|
58387
58387
|
nest_levels: v4.z
|
|
58388
58388
|
.number()
|
|
58389
58389
|
.int()
|
|
58390
58390
|
.min(0)
|
|
58391
|
-
.describe('Number of attribute-folder levels below attributeParentFolder included in the external ID (>= 0). Distinct nested folder paths at this depth produce distinct vertices. Snake_case on the wire.'),
|
|
58391
|
+
.describe('Number of attribute-folder levels below attributeParentFolder included in the external ID (>= 0). Distinct nested folder paths at this depth produce distinct vertices; deeper metrics collapse onto them. A metric with FEWER folders below the parent than nest_levels is matched (the preview lists it) but builds no vertex (measured). Snake_case on the wire.'),
|
|
58392
58392
|
vertexNameIndex: v4.z
|
|
58393
58393
|
.number()
|
|
58394
58394
|
.int()
|
|
58395
58395
|
.min(1)
|
|
58396
58396
|
.optional()
|
|
58397
|
-
.describe('How many trailing pipe-segments of the generated externalId become the vertex name, counting right-to-left. Server default 1 = last segment; N
|
|
58397
|
+
.describe('How many trailing pipe-segments of the generated externalId become the vertex name, counting right-to-left. Server default 1 = last segment; N at or above the segment count = the whole externalId after "<layer>:", starting with "TC|".'),
|
|
58398
58398
|
type: v4.z
|
|
58399
58399
|
.string()
|
|
58400
58400
|
.min(1)
|
|
@@ -58407,27 +58407,27 @@ const InventorizeRuleSchema = v4.z.looseObject({
|
|
|
58407
58407
|
attribute_incl_filter: v4.z
|
|
58408
58408
|
.array(v4.z.string())
|
|
58409
58409
|
.optional()
|
|
58410
|
-
.describe('
|
|
58410
|
+
.describe('Exact include filters, tested against each folder segment from the nest_levels-th segment below attributeParentFolder down (and those segments joined with "|") — never the full path; with nest_levels 0 nothing matches. When non-empty a metric must match at least one.'),
|
|
58411
58411
|
attribute_incl_filter_regex: v4.z
|
|
58412
58412
|
.array(v4.z.string())
|
|
58413
58413
|
.optional()
|
|
58414
|
-
.describe('
|
|
58414
|
+
.describe('Full-match regex include filters, tested like attribute_incl_filter.'),
|
|
58415
58415
|
attribute_excl_filter: v4.z
|
|
58416
58416
|
.array(v4.z.string())
|
|
58417
58417
|
.optional()
|
|
58418
|
-
.describe('
|
|
58418
|
+
.describe('Exact exclude filters, tested like attribute_incl_filter; any match drops the metric.'),
|
|
58419
58419
|
attribute_excl_filter_regex: v4.z
|
|
58420
58420
|
.array(v4.z.string())
|
|
58421
58421
|
.optional()
|
|
58422
|
-
.describe('
|
|
58422
|
+
.describe('Full-match regex exclude filters, tested like attribute_incl_filter.'),
|
|
58423
58423
|
metric_incl_filter: v4.z
|
|
58424
58424
|
.array(v4.z.string())
|
|
58425
58425
|
.optional()
|
|
58426
|
-
.describe('
|
|
58426
|
+
.describe('Exact (whole-string) include filters on the metric name — the part after ":" in the attribute path.'),
|
|
58427
58427
|
metric_incl_filter_regex: v4.z
|
|
58428
58428
|
.array(v4.z.string())
|
|
58429
58429
|
.optional()
|
|
58430
|
-
.describe('
|
|
58430
|
+
.describe('Full-match regex include filters on the metric name.'),
|
|
58431
58431
|
metric_excl_filter: v4.z
|
|
58432
58432
|
.array(v4.z.string())
|
|
58433
58433
|
.optional()
|
|
@@ -58439,11 +58439,11 @@ const InventorizeRuleSchema = v4.z.looseObject({
|
|
|
58439
58439
|
customAttributes: v4.z
|
|
58440
58440
|
.record(v4.z.string(), v4.z.string())
|
|
58441
58441
|
.optional()
|
|
58442
|
-
.describe('Custom attributes stamped onto created vertices. Both KEYS and VALUES may contain ${...} JEXL templates evaluated per matched metric
|
|
58442
|
+
.describe('Custom attributes stamped onto created vertices. Both KEYS and VALUES may contain ${...} JEXL templates evaluated per matched metric. Variables: sourceName, attributeName, attributes.<name> (the metric\'s own attribute map; empty when absent), type, id. Helpers: fn:part(value, index) splits on "|" (0-based: for SuperDomain|host|process|agent, 1 is the host), fn:split(value, separator, index). Java String methods (toUpperCase, substring, replace, replaceAll, split, contains, ...), == != && || !, ternary and Elvis (?:). An unresolvable expression skips that one attribute (warning); the vertex is still created. Every vertex already carries standard attributes (host, process, agent, agentDomain, agentName, product, name, type, resourceType, configRuleId, createdBy) — a custom attribute with one of those names is silently dropped; name, type, createdBy, layer, source_product, ACNId, SourceProduct, serviceNames, external_ids and a few platform keys are rejected at save.'),
|
|
58443
58443
|
externalIdFormat: v4.z
|
|
58444
58444
|
.string()
|
|
58445
58445
|
.optional()
|
|
58446
|
-
.describe('
|
|
58446
|
+
.describe('Order of the external-ID parts after "<layer>:TC|". Server default "${sourceName}|${attributeParentFolder}|${nest_levels}". Only these three substitutes, each once, joined by "|", are accepted — anything else fails the save (HTTP 500); a reordering is honoured.'),
|
|
58447
58447
|
timestamp: v4.z.number().optional().describe('Server-maintained last-modified epoch millis. Read-only.'),
|
|
58448
58448
|
createdTimestamp: v4.z.number().optional().describe('Server-maintained creation epoch millis. Read-only.'),
|
|
58449
58449
|
});
|
|
@@ -59214,6 +59214,146 @@ function defaultRuleName(type, variant) {
|
|
|
59214
59214
|
: `${type} inventorize rule`;
|
|
59215
59215
|
}
|
|
59216
59216
|
|
|
59217
|
+
/**
|
|
59218
|
+
* What a `customAttributes` template can see and call — the single source for
|
|
59219
|
+
* the inventorize cookbook's JEXL section (and so `dx-do help inventorize`),
|
|
59220
|
+
* the ui's sample inspector and help panel. Grounded in the Topology Creator
|
|
59221
|
+
* "Dynamic Custom Attributes" reference and the local evaluator; every
|
|
59222
|
+
* `example` is executed against {@link JEXL_SAMPLE_CONTEXT} by the tests and
|
|
59223
|
+
* must produce `result`.
|
|
59224
|
+
*/
|
|
59225
|
+
/** The reference document's worked metric (scenario A). */
|
|
59226
|
+
const JEXL_SAMPLE_CONTEXT = {
|
|
59227
|
+
id: 'wD_KB-BI-94E-_pMUPq4B',
|
|
59228
|
+
sourceName: 'SuperDomain|lnx-amq-prd02|AMQ|prd02-amq',
|
|
59229
|
+
attributeName: 'Queues|DLQ: Message Count Rate',
|
|
59230
|
+
type: 513,
|
|
59231
|
+
attributes: { host: 'lnx-amq-prd02', metric_name: 'Message Count Rate' },
|
|
59232
|
+
};
|
|
59233
|
+
const JEXL_CONTEXT_CATALOG = {
|
|
59234
|
+
variables: [
|
|
59235
|
+
{
|
|
59236
|
+
name: 'sourceName',
|
|
59237
|
+
type: 'String',
|
|
59238
|
+
description: 'The metric source path — SuperDomain|host|process|agent.',
|
|
59239
|
+
example: '${ sourceName }',
|
|
59240
|
+
result: 'SuperDomain|lnx-amq-prd02|AMQ|prd02-amq',
|
|
59241
|
+
},
|
|
59242
|
+
{
|
|
59243
|
+
name: 'attributeName',
|
|
59244
|
+
type: 'String',
|
|
59245
|
+
description: 'The attribute path below the source — folders, then ":" and the metric name.',
|
|
59246
|
+
example: '${ attributeName }',
|
|
59247
|
+
result: 'Queues|DLQ: Message Count Rate',
|
|
59248
|
+
},
|
|
59249
|
+
{
|
|
59250
|
+
name: 'attributes.<name>',
|
|
59251
|
+
type: 'Map<String, String>',
|
|
59252
|
+
description: "The metric's own attribute map. Empty when the metric has none, so a reference to a missing key skips that one custom attribute. Keys that are not identifiers use brackets: attributes['a::b'].",
|
|
59253
|
+
example: '${ attributes.host }',
|
|
59254
|
+
result: 'lnx-amq-prd02',
|
|
59255
|
+
},
|
|
59256
|
+
{
|
|
59257
|
+
name: 'type',
|
|
59258
|
+
type: 'Integer',
|
|
59259
|
+
description: 'The metric type code.',
|
|
59260
|
+
example: '${ type }',
|
|
59261
|
+
result: '513',
|
|
59262
|
+
},
|
|
59263
|
+
{
|
|
59264
|
+
name: 'id',
|
|
59265
|
+
type: 'String',
|
|
59266
|
+
description: 'The metric id.',
|
|
59267
|
+
example: '${ id }',
|
|
59268
|
+
result: 'wD_KB-BI-94E-_pMUPq4B',
|
|
59269
|
+
},
|
|
59270
|
+
],
|
|
59271
|
+
helpers: [
|
|
59272
|
+
{
|
|
59273
|
+
signature: 'fn:part(value, index)',
|
|
59274
|
+
description: 'Splits on the pipe and returns element index (0-based). Preferred for pipe-delimited paths — no regex escaping.',
|
|
59275
|
+
example: '${ fn:part(sourceName, 1) }',
|
|
59276
|
+
result: 'lnx-amq-prd02',
|
|
59277
|
+
note: 'For SuperDomain|host|process|agent, 1 is the host, 2 the process, 3 the agent. (The reference document labels fn:part(sourceName, 2) "host"; it returns the process.)',
|
|
59278
|
+
},
|
|
59279
|
+
{
|
|
59280
|
+
signature: 'fn:part(attributeName, index)',
|
|
59281
|
+
description: 'The same helper on the attribute path.',
|
|
59282
|
+
example: '${ fn:part(attributeName, 1) }',
|
|
59283
|
+
result: 'DLQ: Message Count Rate',
|
|
59284
|
+
},
|
|
59285
|
+
{
|
|
59286
|
+
signature: 'fn:split(value, separator, index)',
|
|
59287
|
+
description: 'Splits on a literal separator string and returns element index (0-based).',
|
|
59288
|
+
example: "${ fn:split(sourceName, 'AMQ', 0) }",
|
|
59289
|
+
result: 'SuperDomain|lnx-amq-prd02|',
|
|
59290
|
+
},
|
|
59291
|
+
],
|
|
59292
|
+
stringMethods: [
|
|
59293
|
+
{ signature: '.toUpperCase()', description: 'Upper-cases.', example: '${ fn:part(sourceName, 3).toUpperCase() }', result: 'PRD02-AMQ' },
|
|
59294
|
+
{ signature: '.toLowerCase()', description: 'Lower-cases.', example: '${ fn:part(sourceName, 2).toLowerCase() }', result: 'amq' },
|
|
59295
|
+
{ signature: '.trim()', description: 'Strips surrounding whitespace.', example: "${ fn:split(attributeName, ':', 1).trim() }", result: 'Message Count Rate' },
|
|
59296
|
+
{
|
|
59297
|
+
signature: '.substring(begin, end)',
|
|
59298
|
+
description: 'Characters begin (inclusive) to end (exclusive). Out-of-range bounds skip the attribute; .substring(begin) runs to the end.',
|
|
59299
|
+
example: '${ attributeName.substring(0, 6) }',
|
|
59300
|
+
result: 'Queues',
|
|
59301
|
+
},
|
|
59302
|
+
{ signature: '.replace(target, replacement)', description: 'Replaces every literal occurrence.', example: "${ fn:part(sourceName, 3).replace('-amq', '') }", result: 'prd02' },
|
|
59303
|
+
{
|
|
59304
|
+
signature: '.replaceAll(regex, replacement)',
|
|
59305
|
+
description: 'Replaces every regex match. Inside a JSON rule body the backslash is doubled twice: "\\\\\\\\d+".',
|
|
59306
|
+
example: "${ attributes.host.replaceAll('\\\\d+', '') }",
|
|
59307
|
+
result: 'lnx-amq-prd',
|
|
59308
|
+
},
|
|
59309
|
+
{ signature: '.replaceFirst(regex, replacement)', description: 'Replaces the first regex match.', example: "${ attributes.host.replaceFirst('-', '_') }", result: 'lnx_amq-prd02' },
|
|
59310
|
+
{
|
|
59311
|
+
signature: '.split(regex)[n]',
|
|
59312
|
+
description: 'Splits on a regex. A pipe needs escaping here (\'\\\\|\') — prefer fn:part.',
|
|
59313
|
+
example: "${ fn:part(attributeName, 1).split(':')[0] }",
|
|
59314
|
+
result: 'DLQ',
|
|
59315
|
+
},
|
|
59316
|
+
{ signature: '.contains(s)', description: 'true when s occurs.', example: "${ sourceName.contains('prd') }", result: 'true' },
|
|
59317
|
+
{ signature: '.startsWith(s) / .endsWith(s)', description: 'Boundary checks.', example: "${ attributeName.startsWith('Queues') }", result: 'true' },
|
|
59318
|
+
{ signature: '.indexOf(s)', description: 'Position of s, or -1.', example: "${ sourceName.indexOf('AMQ') }", result: '26' },
|
|
59319
|
+
{ signature: '.length()', description: 'Number of characters.', example: '${ fn:part(sourceName, 2).length() }', result: '3' },
|
|
59320
|
+
],
|
|
59321
|
+
operators: [
|
|
59322
|
+
{
|
|
59323
|
+
signature: 'condition ? a : b',
|
|
59324
|
+
description: 'Ternary.',
|
|
59325
|
+
example: "${ attributes.host == 'lnx-amq-prd02' ? 'primary' : 'secondary' }",
|
|
59326
|
+
result: 'primary',
|
|
59327
|
+
},
|
|
59328
|
+
{
|
|
59329
|
+
signature: 'value ?: fallback',
|
|
59330
|
+
description: 'Elvis: the fallback when value is missing, empty or false.',
|
|
59331
|
+
example: "${ attributes.owner ?: 'unowned' }",
|
|
59332
|
+
result: 'unowned',
|
|
59333
|
+
},
|
|
59334
|
+
{ signature: '== != (eq ne)', description: 'Equality.', example: "${ fn:part(sourceName, 2) == 'AMQ' }", result: 'true' },
|
|
59335
|
+
{
|
|
59336
|
+
signature: '&& || ! (and or not)',
|
|
59337
|
+
description: 'Logic.',
|
|
59338
|
+
example: "${ sourceName.contains('prd') && !sourceName.contains('dev') ? 'PRODUCTION' : 'OTHER' }",
|
|
59339
|
+
result: 'PRODUCTION',
|
|
59340
|
+
},
|
|
59341
|
+
{
|
|
59342
|
+
signature: 'text ${ … } text',
|
|
59343
|
+
description: 'Mixed template: text outside ${ } is literal.',
|
|
59344
|
+
example: '${ fn:part(sourceName, 2) }-${ fn:part(sourceName, 3) }',
|
|
59345
|
+
result: 'AMQ-prd02-amq',
|
|
59346
|
+
},
|
|
59347
|
+
],
|
|
59348
|
+
rules: [
|
|
59349
|
+
'Expressions live inside ${ … }; everything outside is literal, and a value with no ${ } is stored unchanged.',
|
|
59350
|
+
'Keys are templates too: "${ fn:part(sourceName, 2) }_seen": "yes" creates an attribute named AMQ_seen.',
|
|
59351
|
+
'An expression that cannot be resolved (missing attribute, index out of range, bad substring bounds, bad regex) skips only that attribute; the vertex is still created.',
|
|
59352
|
+
'Several metrics usually feed one vertex; each is evaluated separately, so an attribute that differs between them is not stable — template from the source path when you can.',
|
|
59353
|
+
'Inside a JSON rule body every regex backslash is written twice ("\\\\d" reaches the engine as \\d); on the dx-do command line quote the whole argument in single quotes.',
|
|
59354
|
+
],
|
|
59355
|
+
};
|
|
59356
|
+
|
|
59217
59357
|
/**
|
|
59218
59358
|
* Java-regex ↔ JavaScript bridge for the JEXL emulator.
|
|
59219
59359
|
*
|
|
@@ -59291,25 +59431,426 @@ function javaReplaceAll(value, pattern, replacement) {
|
|
|
59291
59431
|
function javaReplaceFirst(value, pattern, replacement) {
|
|
59292
59432
|
return value.replace(compile(pattern), replacement);
|
|
59293
59433
|
}
|
|
59434
|
+
|
|
59294
59435
|
/**
|
|
59295
|
-
* Topology Creator sourceName matching
|
|
59296
|
-
*
|
|
59297
|
-
*
|
|
59298
|
-
*
|
|
59299
|
-
|
|
59300
|
-
|
|
59301
|
-
|
|
59302
|
-
|
|
59436
|
+
* The Topology Creator `sourceName` matching dialect — the engine the local
|
|
59437
|
+
* simulation uses and the catalog every help surface is rendered from.
|
|
59438
|
+
*
|
|
59439
|
+
* Measured on DXO2 26.8.2 (two tenants, 2026-09-01/04; a 23-case battery and a
|
|
59440
|
+
* 22-rule construct matrix, 22/22 agreement in preview AND materialised
|
|
59441
|
+
* vertices). The server compiles `java.util.regex` with CASE_INSENSITIVE and
|
|
59442
|
+
* matches with `matches()` (full string) — but only after a preprocessor that:
|
|
59443
|
+
*
|
|
59444
|
+
* 1. escapes every `|` outside a parenthesised group that contains a `|`
|
|
59445
|
+
* (so the segment separator is literal and a user-written `\|` becomes a
|
|
59446
|
+
* literal backslash followed by REAL alternation);
|
|
59447
|
+
* 2. keeps `( … | … )` groups as real alternation, escapes every other
|
|
59448
|
+
* parenthesis (so `Tomcat (Prod)` matches literally);
|
|
59449
|
+
* 3. escapes `+ ? { }` everywhere, pipe groups included;
|
|
59450
|
+
* 4. drops a `*` that does not follow a `.`;
|
|
59451
|
+
* 5. refuses wildcard-only patterns (`.*`, `^.*$`) — they match nothing.
|
|
59452
|
+
*
|
|
59453
|
+
* An unparseable result matches nothing (the API answers HTTP 200 with an
|
|
59454
|
+
* empty preview). This module reproduces exactly that; `[\pL]` (a Unicode
|
|
59455
|
+
* property inside a class) is the one construct the server honours that the
|
|
59456
|
+
* JavaScript engine here cannot, so it degrades to "no match" locally.
|
|
59457
|
+
*/
|
|
59458
|
+
/** Parenthesised regions that contain a `|` — the only place alternation is honoured. */
|
|
59459
|
+
function pipeGroupRanges(pattern) {
|
|
59460
|
+
const stack = [];
|
|
59461
|
+
const ranges = [];
|
|
59462
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
59463
|
+
if (pattern[i] === '(')
|
|
59464
|
+
stack.push(i);
|
|
59465
|
+
else if (pattern[i] === ')') {
|
|
59466
|
+
const start = stack.pop();
|
|
59467
|
+
if (start !== undefined && pattern.slice(start, i).includes('|'))
|
|
59468
|
+
ranges.push([start, i]);
|
|
59469
|
+
}
|
|
59470
|
+
}
|
|
59471
|
+
return ranges;
|
|
59472
|
+
}
|
|
59473
|
+
/** `.*`, `^.*$`, `.*.*`, `` — patterns the server refuses as catch-alls. */
|
|
59474
|
+
function isWildcardOnlySourceName(pattern) {
|
|
59475
|
+
return /^[.*^$]*$/.test(pattern);
|
|
59476
|
+
}
|
|
59477
|
+
/** The Topology Creator preprocessor: rule pattern → the Java regex the server compiles. */
|
|
59478
|
+
function tcSourceNameToJavaRegex(pattern) {
|
|
59479
|
+
const ranges = pipeGroupRanges(pattern);
|
|
59480
|
+
const inGroup = (i) => ranges.some(([s, e]) => i >= s && i <= e);
|
|
59481
|
+
let out = '';
|
|
59482
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
59483
|
+
const c = pattern[i];
|
|
59484
|
+
if (inGroup(i) && ('|()'.includes(c) || (c === '?' && pattern[i - 1] === '(')))
|
|
59485
|
+
out += c;
|
|
59486
|
+
else if ('|(){}+?'.includes(c))
|
|
59487
|
+
out += `\\${c}`;
|
|
59488
|
+
else if (c === '*' && pattern[i - 1] !== '.')
|
|
59489
|
+
continue;
|
|
59490
|
+
else
|
|
59491
|
+
out += c;
|
|
59492
|
+
}
|
|
59493
|
+
return out;
|
|
59494
|
+
}
|
|
59495
|
+
/** Compiles a rule pattern the way the server would. Never throws. */
|
|
59496
|
+
function compileTcSourceName(pattern) {
|
|
59497
|
+
if (isWildcardOnlySourceName(pattern)) {
|
|
59498
|
+
return {
|
|
59499
|
+
ok: false,
|
|
59500
|
+
reason: 'wildcard-only',
|
|
59501
|
+
message: `sourceName "${pattern}" is only wildcards — the server refuses it and matches nothing`,
|
|
59502
|
+
};
|
|
59503
|
+
}
|
|
59504
|
+
try {
|
|
59505
|
+
const js = javaRegexToJs(tcSourceNameToJavaRegex(pattern));
|
|
59506
|
+
return { ok: true, regex: new RegExp(`^(?:${js})$`, 'i') };
|
|
59507
|
+
}
|
|
59508
|
+
catch (err) {
|
|
59509
|
+
return {
|
|
59510
|
+
ok: false,
|
|
59511
|
+
reason: 'invalid',
|
|
59512
|
+
message: `sourceName "${pattern}" does not compile (${err.message}) — the server matches nothing and reports no error`,
|
|
59513
|
+
};
|
|
59514
|
+
}
|
|
59515
|
+
}
|
|
59516
|
+
/** Whether the Topology Creator would match `sourceName` against a rule's pattern. */
|
|
59517
|
+
function tcSourceNameMatches(sourceName, pattern) {
|
|
59518
|
+
const compiled = compileTcSourceName(pattern);
|
|
59519
|
+
return compiled.ok && compiled.regex.test(sourceName);
|
|
59303
59520
|
}
|
|
59304
59521
|
/**
|
|
59305
|
-
*
|
|
59306
|
-
*
|
|
59307
|
-
*
|
|
59308
|
-
*
|
|
59522
|
+
* The Metrics-Metadata REGEX-specifier pattern that selects the same sources.
|
|
59523
|
+
* MM REGEX is a strict Java full match; the preprocessed pattern is already a
|
|
59524
|
+
* valid Java regex (literal pipes and parentheses arrive escaped). Pair it
|
|
59525
|
+
* with `ignoreCase: true` — the Topology Creator matches case-insensitively.
|
|
59309
59526
|
*/
|
|
59310
|
-
function tcSourceNameToMmPattern(
|
|
59311
|
-
return
|
|
59527
|
+
function tcSourceNameToMmPattern(pattern) {
|
|
59528
|
+
return tcSourceNameToJavaRegex(pattern);
|
|
59312
59529
|
}
|
|
59530
|
+
/**
|
|
59531
|
+
* "What you might write → what actually happens → write this instead", one
|
|
59532
|
+
* row per trap. Rendered into the inventorize cookbook (and so into
|
|
59533
|
+
* `dx-do help inventorize` and the ui help panel) by the agentic-gen
|
|
59534
|
+
* generator; the linter's hints cite these ids. Keep the prose
|
|
59535
|
+
* tenant-neutral — it ships in the published corpus.
|
|
59536
|
+
*/
|
|
59537
|
+
const SOURCENAME_DIALECT_CATALOG = [
|
|
59538
|
+
{
|
|
59539
|
+
id: 'escaped-pipe',
|
|
59540
|
+
appliesTo: 'sourceName',
|
|
59541
|
+
title: 'Escaped pipes',
|
|
59542
|
+
youMightWrite: 'SuperDomain\\|host-01\\|AMQ\\|.*',
|
|
59543
|
+
intent: 'pipes escaped, as in a Metrics-Metadata query',
|
|
59544
|
+
whatHappens: 'The server escapes every pipe itself, so a backslash written before a pipe becomes a literal backslash followed by **real alternation**. Here the trailing `.*` becomes a branch of its own and the rule matches every source.',
|
|
59545
|
+
writeInstead: 'SuperDomain|host-01|AMQ|.*',
|
|
59546
|
+
fixMatches: [
|
|
59547
|
+
'SuperDomain|host-01|AMQ|agent-01',
|
|
59548
|
+
'SuperDomain|host-01|AMQ|agent-02',
|
|
59549
|
+
],
|
|
59550
|
+
example: {
|
|
59551
|
+
pattern: 'SuperDomain\\|host-01\\|AMQ\\|.*',
|
|
59552
|
+
sourceName: 'SuperDomain|host-02|KFK|agent-02',
|
|
59553
|
+
matches: true,
|
|
59554
|
+
},
|
|
59555
|
+
},
|
|
59556
|
+
{
|
|
59557
|
+
id: 'top-level-alternation',
|
|
59558
|
+
appliesTo: 'sourceName',
|
|
59559
|
+
title: 'Alternation outside parentheses',
|
|
59560
|
+
youMightWrite: 'SuperDomain|host-01|AMQ|agent-01|SuperDomain|host-02|AMQ|agent-02',
|
|
59561
|
+
intent: 'two full names joined by `|`',
|
|
59562
|
+
whatHappens: 'A `|` outside parentheses is a literal pipe, so this is one eight-segment name that no source has.',
|
|
59563
|
+
writeInstead: 'SuperDomain|(host-01|host-02)|AMQ|.*',
|
|
59564
|
+
fixMatches: [
|
|
59565
|
+
'SuperDomain|host-01|AMQ|agent-01',
|
|
59566
|
+
'SuperDomain|host-02|AMQ|agent-02',
|
|
59567
|
+
],
|
|
59568
|
+
example: {
|
|
59569
|
+
pattern: 'SuperDomain|host-01|AMQ|agent-01|SuperDomain|host-02|AMQ|agent-02',
|
|
59570
|
+
sourceName: 'SuperDomain|host-01|AMQ|agent-01',
|
|
59571
|
+
matches: false,
|
|
59572
|
+
},
|
|
59573
|
+
},
|
|
59574
|
+
{
|
|
59575
|
+
id: 'pipe-group',
|
|
59576
|
+
appliesTo: 'sourceName',
|
|
59577
|
+
title: 'Alternation inside parentheses',
|
|
59578
|
+
youMightWrite: 'SuperDomain|.*|(AMQ|KFK)|.*',
|
|
59579
|
+
whatHappens: 'Works: parentheses that contain a `|` are real alternation, and regex inside them is honoured (classes, `.*`, `(?:…)`, nesting). This is the only way to alternate.',
|
|
59580
|
+
writeInstead: 'SuperDomain|.*|(AMQ|KFK)|.*',
|
|
59581
|
+
fixMatches: [
|
|
59582
|
+
'SuperDomain|host-03|KFK|agent-03',
|
|
59583
|
+
'SuperDomain|host-01|AMQ|agent-01',
|
|
59584
|
+
],
|
|
59585
|
+
example: {
|
|
59586
|
+
pattern: 'SuperDomain|.*|(AMQ|KFK)|.*',
|
|
59587
|
+
sourceName: 'SuperDomain|host-03|KFK|agent-03',
|
|
59588
|
+
matches: true,
|
|
59589
|
+
},
|
|
59590
|
+
},
|
|
59591
|
+
{
|
|
59592
|
+
id: 'literal-parens',
|
|
59593
|
+
appliesTo: 'sourceName',
|
|
59594
|
+
title: 'Literal parentheses',
|
|
59595
|
+
youMightWrite: 'SuperDomain|app-01|Tomcat (Prod)|.*',
|
|
59596
|
+
whatHappens: 'Works: parentheses that do not enclose a `|` are literal characters, so this matches a process literally named `Tomcat (Prod)`. Regex inside them is not honoured.',
|
|
59597
|
+
writeInstead: 'SuperDomain|app-01|Tomcat (Prod)|.*',
|
|
59598
|
+
fixMatches: ['SuperDomain|app-01|Tomcat (Prod)|agent-01'],
|
|
59599
|
+
example: {
|
|
59600
|
+
pattern: 'SuperDomain|app-01|Tomcat (Prod)|.*',
|
|
59601
|
+
sourceName: 'SuperDomain|app-01|Tomcat (Prod)|agent-01',
|
|
59602
|
+
matches: true,
|
|
59603
|
+
},
|
|
59604
|
+
},
|
|
59605
|
+
{
|
|
59606
|
+
id: 'escaped-paren',
|
|
59607
|
+
appliesTo: 'sourceName',
|
|
59608
|
+
title: 'Escaped parentheses',
|
|
59609
|
+
youMightWrite: 'SuperDomain|app-01|Tomcat \\(Prod\\)|.*',
|
|
59610
|
+
whatHappens: 'A written `\\(` is doubled by the server and breaks the match.',
|
|
59611
|
+
writeInstead: 'SuperDomain|app-01|Tomcat (Prod)|.*',
|
|
59612
|
+
fixMatches: ['SuperDomain|app-01|Tomcat (Prod)|agent-01'],
|
|
59613
|
+
example: {
|
|
59614
|
+
pattern: 'SuperDomain|app-01|Tomcat \\(Prod\\)|.*',
|
|
59615
|
+
sourceName: 'SuperDomain|app-01|Tomcat (Prod)|agent-01',
|
|
59616
|
+
matches: false,
|
|
59617
|
+
},
|
|
59618
|
+
},
|
|
59619
|
+
{
|
|
59620
|
+
id: 'parens-pipe-trap',
|
|
59621
|
+
appliesTo: 'sourceName',
|
|
59622
|
+
title: 'Literal parentheses around alternatives',
|
|
59623
|
+
youMightWrite: 'SuperDomain|app-01|Tomcat (Prod|Dev)|.*',
|
|
59624
|
+
intent: 'to match `Tomcat (Prod)` or `Tomcat (Dev)`',
|
|
59625
|
+
whatHappens: 'Adding a `|` turns the parentheses into a group: it matches `Tomcat Prod` or `Tomcat Dev`, no longer the literal `Tomcat (Prod)`.',
|
|
59626
|
+
writeInstead: 'SuperDomain|app-01|Tomcat .(Prod|Dev).|.*',
|
|
59627
|
+
fixMatches: [
|
|
59628
|
+
'SuperDomain|app-01|Tomcat (Prod)|agent-01',
|
|
59629
|
+
'SuperDomain|app-01|Tomcat (Dev)|agent-01',
|
|
59630
|
+
],
|
|
59631
|
+
advice: 'Let `.` stand for each literal parenthesis, or write two rules.',
|
|
59632
|
+
example: {
|
|
59633
|
+
pattern: 'SuperDomain|app-01|Tomcat (Prod|Dev)|.*',
|
|
59634
|
+
sourceName: 'SuperDomain|app-01|Tomcat (Prod)|agent-01',
|
|
59635
|
+
matches: false,
|
|
59636
|
+
},
|
|
59637
|
+
},
|
|
59638
|
+
{
|
|
59639
|
+
id: 'quantifier-literal',
|
|
59640
|
+
appliesTo: 'sourceName',
|
|
59641
|
+
title: 'Quantifiers: +, ? and {n}',
|
|
59642
|
+
youMightWrite: 'SuperDomain|web[0-9]{2}|AMQ|.*',
|
|
59643
|
+
intent: 'also `\\d+` or `web0?1`',
|
|
59644
|
+
whatHappens: '`+`, `?` and `{n}` are escaped before the regex engine sees them — inside `(…|…)` groups too — so they only match those literal characters.',
|
|
59645
|
+
writeInstead: 'SuperDomain|web[0-9][0-9]|AMQ|.*',
|
|
59646
|
+
fixMatches: [
|
|
59647
|
+
'SuperDomain|web01|AMQ|agent-01',
|
|
59648
|
+
'SuperDomain|web42|AMQ|agent-02',
|
|
59649
|
+
],
|
|
59650
|
+
advice: 'Repeat the class once per character; use `.*` for "one or more" (`\\d.*`) and a group for "optional" (`web(01|1)`).',
|
|
59651
|
+
example: {
|
|
59652
|
+
pattern: 'SuperDomain|web[0-9]{2}|AMQ|.*',
|
|
59653
|
+
sourceName: 'SuperDomain|web01|AMQ|agent-01',
|
|
59654
|
+
matches: false,
|
|
59655
|
+
},
|
|
59656
|
+
},
|
|
59657
|
+
{
|
|
59658
|
+
id: 'bare-star',
|
|
59659
|
+
appliesTo: 'sourceName',
|
|
59660
|
+
title: 'A * without a dot',
|
|
59661
|
+
youMightWrite: 'SuperDomain|cache|AMQ|agent-aa*',
|
|
59662
|
+
whatHappens: 'A `*` that does not follow a `.` is dropped: `aa*` means exactly `aa`.',
|
|
59663
|
+
writeInstead: 'SuperDomain|cache|AMQ|agent-aa.*',
|
|
59664
|
+
fixMatches: [
|
|
59665
|
+
'SuperDomain|cache|AMQ|agent-aa',
|
|
59666
|
+
'SuperDomain|cache|AMQ|agent-aaa',
|
|
59667
|
+
],
|
|
59668
|
+
example: {
|
|
59669
|
+
pattern: 'SuperDomain|cache|AMQ|agent-aa*',
|
|
59670
|
+
sourceName: 'SuperDomain|cache|AMQ|agent-aaa',
|
|
59671
|
+
matches: false,
|
|
59672
|
+
},
|
|
59673
|
+
},
|
|
59674
|
+
{
|
|
59675
|
+
id: 'case-insensitive',
|
|
59676
|
+
appliesTo: 'sourceName',
|
|
59677
|
+
title: 'Upper and lower case',
|
|
59678
|
+
youMightWrite: 'SuperDomain|WEB01|AMQ|.*',
|
|
59679
|
+
intent: 'to select only the upper-case host',
|
|
59680
|
+
whatHappens: 'Matching ignores case everywhere; `[A-Z]` also matches lower-case letters.',
|
|
59681
|
+
advice: 'Tell sources apart by something other than case.',
|
|
59682
|
+
example: {
|
|
59683
|
+
pattern: 'SUPERDOMAIN|web01|amq|.*',
|
|
59684
|
+
sourceName: 'SuperDomain|WEB01|AMQ|agent-01',
|
|
59685
|
+
matches: true,
|
|
59686
|
+
},
|
|
59687
|
+
},
|
|
59688
|
+
{
|
|
59689
|
+
id: 'wildcard-only',
|
|
59690
|
+
appliesTo: 'sourceName',
|
|
59691
|
+
title: 'Catch-all patterns',
|
|
59692
|
+
youMightWrite: '.*',
|
|
59693
|
+
intent: 'a catch-all',
|
|
59694
|
+
whatHappens: 'A pattern made only of wildcards (`.*`, `^.*$`) matches nothing — the server refuses catch-alls.',
|
|
59695
|
+
writeInstead: '.*|.*|.*|.*',
|
|
59696
|
+
fixMatches: [
|
|
59697
|
+
'SuperDomain|host-01|AMQ|agent-01',
|
|
59698
|
+
'SuperDomain|web01|KFK|agent-02',
|
|
59699
|
+
],
|
|
59700
|
+
advice: 'Or anchor on the first segment: `SuperDomain|.*`.',
|
|
59701
|
+
example: { pattern: '.*', sourceName: 'SuperDomain|host-01|AMQ|agent-01', matches: false },
|
|
59702
|
+
},
|
|
59703
|
+
{
|
|
59704
|
+
id: 'bare-substring',
|
|
59705
|
+
appliesTo: 'sourceName',
|
|
59706
|
+
title: 'Part of a name',
|
|
59707
|
+
youMightWrite: 'host-01',
|
|
59708
|
+
whatHappens: 'Matching is full-string: a fragment of a source name matches nothing.',
|
|
59709
|
+
writeInstead: '.*host-01.*',
|
|
59710
|
+
fixMatches: [
|
|
59711
|
+
'SuperDomain|host-01|AMQ|agent-01',
|
|
59712
|
+
'SuperDomain|host-01|KFK|agent-02',
|
|
59713
|
+
],
|
|
59714
|
+
advice: 'Or spell the segments: `SuperDomain|host-01|.*`.',
|
|
59715
|
+
example: { pattern: 'host-01', sourceName: 'SuperDomain|host-01|AMQ|agent-01', matches: false },
|
|
59716
|
+
},
|
|
59717
|
+
{
|
|
59718
|
+
id: 'quoted-literal',
|
|
59719
|
+
appliesTo: 'sourceName',
|
|
59720
|
+
title: 'Quoting with \\Q…\\E',
|
|
59721
|
+
youMightWrite: '\\QSuperDomain|host-01|AMQ|agent-01\\E',
|
|
59722
|
+
whatHappens: 'The pipes inside the quote are escaped too, so the quoted text never matches.',
|
|
59723
|
+
writeInstead: 'SuperDomain|host-01|AMQ|agent-01',
|
|
59724
|
+
fixMatches: ['SuperDomain|host-01|AMQ|agent-01'],
|
|
59725
|
+
example: {
|
|
59726
|
+
pattern: '\\QSuperDomain|host-01|AMQ|agent-01\\E',
|
|
59727
|
+
sourceName: 'SuperDomain|host-01|AMQ|agent-01',
|
|
59728
|
+
matches: false,
|
|
59729
|
+
},
|
|
59730
|
+
},
|
|
59731
|
+
{
|
|
59732
|
+
id: 'unicode-property',
|
|
59733
|
+
appliesTo: 'sourceName',
|
|
59734
|
+
title: 'Unicode properties',
|
|
59735
|
+
youMightWrite: 'SuperDomain|\\pL.*|AMQ|.*',
|
|
59736
|
+
whatHappens: 'A Unicode property outside a character class does not survive the preprocessor.',
|
|
59737
|
+
writeInstead: 'SuperDomain|[\\pL].*|AMQ|.*',
|
|
59738
|
+
advice: 'Inside a class it works on the server (the local simulation cannot emulate it).',
|
|
59739
|
+
example: {
|
|
59740
|
+
pattern: 'SuperDomain|\\pL.*|AMQ|.*',
|
|
59741
|
+
sourceName: 'SuperDomain|host-01|AMQ|agent-01',
|
|
59742
|
+
matches: false,
|
|
59743
|
+
},
|
|
59744
|
+
},
|
|
59745
|
+
{
|
|
59746
|
+
id: 'nested-brackets',
|
|
59747
|
+
appliesTo: 'sourceName',
|
|
59748
|
+
title: 'Nested character classes',
|
|
59749
|
+
youMightWrite: 'SuperDomain|host-[[:digit:]]|.*',
|
|
59750
|
+
intent: 'or `[a-z&&[^b]]`',
|
|
59751
|
+
whatHappens: 'A character class ends at the first `]`, so nested classes break the pattern.',
|
|
59752
|
+
writeInstead: 'SuperDomain|host-[0-9]|.*',
|
|
59753
|
+
fixMatches: [
|
|
59754
|
+
'SuperDomain|host-1|AMQ|agent-01',
|
|
59755
|
+
'SuperDomain|host-7|KFK|agent-02',
|
|
59756
|
+
],
|
|
59757
|
+
},
|
|
59758
|
+
{
|
|
59759
|
+
id: 'unbalanced',
|
|
59760
|
+
appliesTo: 'sourceName',
|
|
59761
|
+
title: 'Patterns that do not compile',
|
|
59762
|
+
youMightWrite: 'SuperDomain|host-[ab|.*',
|
|
59763
|
+
whatHappens: 'An unparseable pattern matches nothing, and the API still answers HTTP 200 with an empty preview — no error is reported.',
|
|
59764
|
+
writeInstead: 'SuperDomain|host-[ab]|.*',
|
|
59765
|
+
fixMatches: [
|
|
59766
|
+
'SuperDomain|host-a|AMQ|agent-a',
|
|
59767
|
+
'SuperDomain|host-b|KFK|agent-b',
|
|
59768
|
+
],
|
|
59769
|
+
example: { pattern: 'SuperDomain|host-[ab|.*', sourceName: 'SuperDomain|host-a|AMQ|agent-a', matches: false },
|
|
59770
|
+
},
|
|
59771
|
+
{
|
|
59772
|
+
id: 'parent-folder-required',
|
|
59773
|
+
appliesTo: 'attributeParentFolder',
|
|
59774
|
+
youMightWrite: '(unset)',
|
|
59775
|
+
intent: 'a rule with only `sourceName`, maybe `attributeName`',
|
|
59776
|
+
whatHappens: 'The API accepts it, but it matches zero metrics.',
|
|
59777
|
+
advice: 'Always set `attributeParentFolder` — it anchors matching and the external ID.',
|
|
59778
|
+
},
|
|
59779
|
+
{
|
|
59780
|
+
id: 'parent-folder-prefix',
|
|
59781
|
+
appliesTo: 'attributeParentFolder',
|
|
59782
|
+
youMightWrite: 'Queue',
|
|
59783
|
+
intent: 'expecting only the folder `Queue`',
|
|
59784
|
+
whatHappens: 'The folder is a string prefix: the server derives `attributeName` as `<folder>.*`, so `Queue` also picks up `Queues|…` and `QueueStats|…`.',
|
|
59785
|
+
advice: 'Name sibling folders so none is a prefix of another — `attributeName` does not narrow it.',
|
|
59786
|
+
},
|
|
59787
|
+
{
|
|
59788
|
+
id: 'parent-folder-dot',
|
|
59789
|
+
appliesTo: 'attributeParentFolder',
|
|
59790
|
+
youMightWrite: 'JMX|Default|org.apache.activemq',
|
|
59791
|
+
intent: 'the folder right above the MBeans you want',
|
|
59792
|
+
whatHappens: 'Measured 2026-09-24: parent folders containing a `.` (`JMX|Default|java.nio`, `…|org.apache.activemq`) matched no metrics, while `JMX|Default` and the dot-free `Agents|localhost|Infrastructure` did.',
|
|
59793
|
+
writeInstead: 'JMX|Default',
|
|
59794
|
+
advice: 'Stop the parent before the dotted segment, raise `nest_levels`, and narrow with an attribute filter.',
|
|
59795
|
+
},
|
|
59796
|
+
{
|
|
59797
|
+
id: 'attribute-name-ignored',
|
|
59798
|
+
appliesTo: 'attributeName',
|
|
59799
|
+
youMightWrite: 'Queues|DLQ.*',
|
|
59800
|
+
intent: 'to narrow the rule to one queue',
|
|
59801
|
+
whatHappens: 'Measured 2026-09-24: a hand-set `attributeName` did not narrow the preview in any form — literal, regex, pipe escaped or not. The server fills it with `<folder>.*` when omitted.',
|
|
59802
|
+
advice: 'Narrow with the `attribute_*` / `metric_*` filters, or a deeper `attributeParentFolder`.',
|
|
59803
|
+
},
|
|
59804
|
+
{
|
|
59805
|
+
id: 'attribute-filters-relative',
|
|
59806
|
+
appliesTo: 'filters',
|
|
59807
|
+
youMightWrite: 'attribute_excl_filter: ["Queues|DLQ"]',
|
|
59808
|
+
intent: 'the full folder path',
|
|
59809
|
+
whatHappens: 'Attribute filters are tested against the folder segments **from the nest level down** — each segment on its own and those segments joined with `|` — never against the parent folder or the segments above the nest level; with `nest_levels` 0 they match nothing. `metric_*` filters see the metric name after `:`. Exact filters compare whole strings (`Rat` does not match `Rate`); `_regex` filters are full-match. Measured on two tenants 2026-09-24; not every probe fits, so check the preview.',
|
|
59810
|
+
writeInstead: 'attribute_excl_filter: ["DLQ"]',
|
|
59811
|
+
advice: 'Filter on a segment at or below the nest level, e.g. `destinationType=Queue`.',
|
|
59812
|
+
},
|
|
59813
|
+
{
|
|
59814
|
+
id: 'external-id-format',
|
|
59815
|
+
appliesTo: 'externalIdFormat',
|
|
59816
|
+
youMightWrite: 'X|${sourceName}|${attributeParentFolder}|${nest_levels}',
|
|
59817
|
+
whatHappens: 'The save is rejected (HTTP 500): only the three substitutes `${sourceName}`, `${attributeParentFolder}`, `${nest_levels}`, each once, joined by `|`. A reordering works and reorders the external ID after `<layer>:TC|`.',
|
|
59818
|
+
writeInstead: '${attributeParentFolder}|${sourceName}|${nest_levels}',
|
|
59819
|
+
advice: 'Or leave it unset.',
|
|
59820
|
+
},
|
|
59821
|
+
{
|
|
59822
|
+
id: 'custom-attribute-standard-name',
|
|
59823
|
+
appliesTo: 'customAttributes',
|
|
59824
|
+
youMightWrite: '"host": "${ fn:part(sourceName, 2) }"',
|
|
59825
|
+
intent: 'as in the vendor documentation',
|
|
59826
|
+
whatHappens: 'Every vertex already carries `host`, `process`, `agent`, `agentDomain`, `agentName`, `product`, `name`, `type`, `resourceType`, `configRuleId` and `createdBy`, set from the source path and the rule. A custom attribute with one of those names is silently dropped — the standard value wins (measured 2026-09-24).',
|
|
59827
|
+
writeInstead: '"broker": "${ fn:part(sourceName, 2) }"',
|
|
59828
|
+
},
|
|
59829
|
+
{
|
|
59830
|
+
id: 'custom-attribute-reserved-name',
|
|
59831
|
+
appliesTo: 'customAttributes',
|
|
59832
|
+
youMightWrite: '"name": "${ fn:part(attributeName, 1) }"',
|
|
59833
|
+
whatHappens: 'The save is rejected (HTTP 500) for these keys: `name`, `type`, `createdBy`, `layer`, `source_product`, `ACNId`, `SourceProduct`, `serviceNames`, `internal::serviceNames`, `external_ids`, `vertexLevel`, the `dx_*` / `acn*` / `Other*` network keys, and the empty key.',
|
|
59834
|
+
advice: 'Pick another key, e.g. `queue_name`; the vertex name itself comes from `vertexNameIndex`.',
|
|
59835
|
+
},
|
|
59836
|
+
{
|
|
59837
|
+
id: 'nest-levels',
|
|
59838
|
+
appliesTo: 'nest_levels',
|
|
59839
|
+
youMightWrite: '3',
|
|
59840
|
+
intent: 'with metrics at different depths under the parent, e.g. `Agents:PLA Devices` next to `Agents|host|agent|plugin:Status`',
|
|
59841
|
+
whatHappens: 'Each level adds the next folder below the parent to the external ID, so distinct paths at that depth become distinct vertices and deeper metrics collapse onto them. A metric with FEWER folders below the parent than `nest_levels` is matched — the preview lists it — but builds no vertex (measured 2026-09-24). 0 gives one vertex per source and parent folder.',
|
|
59842
|
+
advice: 'Pick the depth where the thing you want as a vertex lives; metrics above it need their own rule with a smaller `nest_levels` (on a different parent folder, so rules do not overlap).',
|
|
59843
|
+
},
|
|
59844
|
+
{
|
|
59845
|
+
id: 'vertex-name-index',
|
|
59846
|
+
appliesTo: 'vertexNameIndex',
|
|
59847
|
+
youMightWrite: '3',
|
|
59848
|
+
intent: 'expecting the host name',
|
|
59849
|
+
whatHappens: 'The name is the last N pipe segments of the external ID `<layer>:TC|<sourceName>|<folder>[|nested]`. `1` is the last segment; N at or above the segment count gives the whole ID after the layer, starting with `TC|`.',
|
|
59850
|
+
writeInstead: '1',
|
|
59851
|
+
advice: 'Choose `nest_levels` so the last segment is the thing you want named.',
|
|
59852
|
+
},
|
|
59853
|
+
];
|
|
59313
59854
|
|
|
59314
59855
|
/** Topology Creator's own per-rule processing cap. */
|
|
59315
59856
|
const TC_METRIC_CAP = 10000;
|
|
@@ -59320,6 +59861,7 @@ function translateRuleToMmQuery(rule, clamp = TC_METRIC_CAP) {
|
|
|
59320
59861
|
sourceNameSpecifier: {
|
|
59321
59862
|
op: 'REGEX',
|
|
59322
59863
|
pattern: tcSourceNameToMmPattern(rule.sourceName),
|
|
59864
|
+
ignoreCase: true,
|
|
59323
59865
|
},
|
|
59324
59866
|
folderNameSpecifier: { op: 'ALL' },
|
|
59325
59867
|
attributeNameSpecifier: { op: 'ALL' },
|
|
@@ -59969,8 +60511,16 @@ function splitAttributePath(attributeName) {
|
|
|
59969
60511
|
function folderUnderParent(folderPath, parent) {
|
|
59970
60512
|
return folderPath === parent || folderPath.startsWith(`${parent}|`);
|
|
59971
60513
|
}
|
|
59972
|
-
|
|
59973
|
-
|
|
60514
|
+
/**
|
|
60515
|
+
* EMPIRICAL (construct matrix, 2026-09-04): with no explicit attributeName the
|
|
60516
|
+
* server derives `attributeName = "<parent>.*"`, so the parent folder is a
|
|
60517
|
+
* STRING PREFIX — folder `Queue` also admits `Queues|…` and `QueueStats|…`.
|
|
60518
|
+
*/
|
|
60519
|
+
function folderMatchesDerivedPrefix(attributeName, parent) {
|
|
60520
|
+
return attributeName.startsWith(parent);
|
|
60521
|
+
}
|
|
60522
|
+
function applyFilters(values, exact, regex, exclExact, exclRegex) {
|
|
60523
|
+
const matchesOne = (value, pattern, isRegex) => {
|
|
59974
60524
|
if (!isRegex)
|
|
59975
60525
|
return value === pattern;
|
|
59976
60526
|
try {
|
|
@@ -59982,6 +60532,8 @@ function applyFilters(value, exact, regex, exclExact, exclRegex) {
|
|
|
59982
60532
|
throw err;
|
|
59983
60533
|
}
|
|
59984
60534
|
};
|
|
60535
|
+
const matches = (pattern, isRegex) => values.some((v) => matchesOne(v, pattern, isRegex));
|
|
60536
|
+
const value = values.length === 1 ? values[0] : values.join(' / ');
|
|
59985
60537
|
const incl = [
|
|
59986
60538
|
...(exact ?? []).map((p) => ({ p, r: false })),
|
|
59987
60539
|
...(regex ?? []).map((p) => ({ p, r: true })),
|
|
@@ -59998,16 +60550,144 @@ function applyFilters(value, exact, regex, exclExact, exclRegex) {
|
|
|
59998
60550
|
return { pass: false, detail: `"${value}" hit exclude filter "${hit.p}"` };
|
|
59999
60551
|
return { pass: true };
|
|
60000
60552
|
}
|
|
60001
|
-
/**
|
|
60553
|
+
/**
|
|
60554
|
+
* Attributes the Topology Creator stamps on every vertex it creates, measured
|
|
60555
|
+
* on THE_LABORATORY and ITOM-DX-DEMO-DEV (2026-09-24). All come from the
|
|
60556
|
+
* matched source path and the rule — never from the metric's own attribute
|
|
60557
|
+
* map. `agentName` is the PROCESS segment (as observed, not the agent).
|
|
60558
|
+
* A customAttribute with one of these names is silently dropped: the standard
|
|
60559
|
+
* value wins. (Long-lived vertices later also carry platform-added ACNId and
|
|
60560
|
+
* SourceProduct; the rule does not set those.)
|
|
60561
|
+
*/
|
|
60562
|
+
const TC_STANDARD_ATTRIBUTE_KEYS = [
|
|
60563
|
+
'agent',
|
|
60564
|
+
'agentDomain',
|
|
60565
|
+
'agentName',
|
|
60566
|
+
'configRuleId',
|
|
60567
|
+
'createdBy',
|
|
60568
|
+
'host',
|
|
60569
|
+
'name',
|
|
60570
|
+
'process',
|
|
60571
|
+
'product',
|
|
60572
|
+
'resourceType',
|
|
60573
|
+
'type',
|
|
60574
|
+
];
|
|
60575
|
+
/**
|
|
60576
|
+
* customAttributes keys the save API rejects (HTTP 500, message listing them —
|
|
60577
|
+
* captured 2026-09-24). The empty key is rejected too.
|
|
60578
|
+
*/
|
|
60579
|
+
const TC_RESERVED_CUSTOM_ATTRIBUTE_KEYS = [
|
|
60580
|
+
'',
|
|
60581
|
+
'acn_loganalytics_key',
|
|
60582
|
+
'OtherNetworkAddresses',
|
|
60583
|
+
'internal::serviceNames',
|
|
60584
|
+
'type',
|
|
60585
|
+
'serviceNames',
|
|
60586
|
+
'acnOtherHostNames',
|
|
60587
|
+
'external_ids',
|
|
60588
|
+
'layer',
|
|
60589
|
+
'dx_hostname_list',
|
|
60590
|
+
'OtherMacAddrs',
|
|
60591
|
+
'ACNId',
|
|
60592
|
+
'createdBy',
|
|
60593
|
+
'source_product',
|
|
60594
|
+
'dx_hostname',
|
|
60595
|
+
'dx_ip_address_list',
|
|
60596
|
+
'name',
|
|
60597
|
+
'SourceProduct',
|
|
60598
|
+
'acnHostName',
|
|
60599
|
+
'dx_mac_address_list',
|
|
60600
|
+
'vertexLevel',
|
|
60601
|
+
];
|
|
60602
|
+
/** The standard attributes a vertex gets from its source path, name and rule. */
|
|
60603
|
+
function standardVertexAttributes(rule, sourceName, vertexName) {
|
|
60604
|
+
const seg = sourceName.split('|');
|
|
60605
|
+
const out = {};
|
|
60606
|
+
if (seg.length > 1)
|
|
60607
|
+
out['agent'] = seg.slice(1).join('|');
|
|
60608
|
+
if (seg[0] !== undefined)
|
|
60609
|
+
out['agentDomain'] = seg[0];
|
|
60610
|
+
if (seg[2] !== undefined)
|
|
60611
|
+
out['agentName'] = seg[2];
|
|
60612
|
+
out['configRuleId'] = rule.ruleId ?? '(assigned when the rule is saved)';
|
|
60613
|
+
out['createdBy'] = 'OITopologyCreator';
|
|
60614
|
+
if (seg[1] !== undefined)
|
|
60615
|
+
out['host'] = seg[1];
|
|
60616
|
+
out['name'] = vertexName;
|
|
60617
|
+
if (seg[2] !== undefined)
|
|
60618
|
+
out['process'] = seg[2];
|
|
60619
|
+
out['product'] = rule.source_product ?? 'Application Performance Management';
|
|
60620
|
+
out['resourceType'] = rule.type;
|
|
60621
|
+
out['type'] = rule.type;
|
|
60622
|
+
return out;
|
|
60623
|
+
}
|
|
60624
|
+
/** customAttributes keys the server rejects at save, and those a standard attribute overrides. */
|
|
60625
|
+
function customAttributeKeyIssues(customAttributes) {
|
|
60626
|
+
const keys = Object.keys(customAttributes ?? {});
|
|
60627
|
+
const reserved = keys.filter((k) => TC_RESERVED_CUSTOM_ATTRIBUTE_KEYS.includes(k.trim()));
|
|
60628
|
+
const shadowed = keys.filter((k) => !reserved.includes(k) && TC_STANDARD_ATTRIBUTE_KEYS.includes(k));
|
|
60629
|
+
return { reserved, shadowed };
|
|
60630
|
+
}
|
|
60631
|
+
const FILTER_KEYS = [
|
|
60632
|
+
'attribute_incl_filter',
|
|
60633
|
+
'attribute_incl_filter_regex',
|
|
60634
|
+
'attribute_excl_filter',
|
|
60635
|
+
'attribute_excl_filter_regex',
|
|
60636
|
+
];
|
|
60637
|
+
/**
|
|
60638
|
+
* What attribute_* filters are tested against. EMPIRICAL (demo-dev,
|
|
60639
|
+
* 2026-09-24, preview): each folder segment from the nest_levels-th segment
|
|
60640
|
+
* below the parent to the end, plus those segments joined with "|"; a
|
|
60641
|
+
* filter passes when it full-matches any of them. With nest_levels 2 a
|
|
60642
|
+
* filter on the 2nd segment matched and one on the 1st did not; with 0
|
|
60643
|
+
* nothing matched. Not every probe fits (a regex alternation "a|b" matched
|
|
60644
|
+
* nothing) — the server preview stays authoritative for attribute filters.
|
|
60645
|
+
*/
|
|
60646
|
+
function attributeFilterTargets(folderPath, parent, nestLevels) {
|
|
60647
|
+
if (nestLevels < 1)
|
|
60648
|
+
return [];
|
|
60649
|
+
const below = folderPath.split('|').slice(parent.split('|').length);
|
|
60650
|
+
const from = below.slice(nestLevels - 1);
|
|
60651
|
+
if (from.length === 0)
|
|
60652
|
+
return [];
|
|
60653
|
+
return from.length === 1 ? from : [...from, from.join('|')];
|
|
60654
|
+
}
|
|
60655
|
+
/**
|
|
60656
|
+
* The server accepts an externalIdFormat only as the three substitutes
|
|
60657
|
+
* `${sourceName}`, `${attributeParentFolder}`, `${nest_levels}` joined by
|
|
60658
|
+
* "|", each once, in any order; anything else is rejected at save (HTTP 500,
|
|
60659
|
+
* measured 2026-09-24). Returns the order, or null when the server would
|
|
60660
|
+
* reject the format.
|
|
60661
|
+
*/
|
|
60662
|
+
function parseExternalIdFormat(format) {
|
|
60663
|
+
if (!format)
|
|
60664
|
+
return ['sourceName', 'attributeParentFolder', 'nest_levels'];
|
|
60665
|
+
const parts = format.split('|').map((p) => p.trim());
|
|
60666
|
+
const names = parts.map((p) => /^\$\{(sourceName|attributeParentFolder|nest_levels)\}$/.exec(p)?.[1]);
|
|
60667
|
+
if (names.length !== 3 || names.some((n) => n === undefined) || new Set(names).size !== 3)
|
|
60668
|
+
return null;
|
|
60669
|
+
return names;
|
|
60670
|
+
}
|
|
60671
|
+
/**
|
|
60672
|
+
* External-ID formation: `<layer>:TC|` followed by the three parts in the
|
|
60673
|
+
* rule's externalIdFormat order (default sourceName, parent folder, nested).
|
|
60674
|
+
*/
|
|
60002
60675
|
function formExternalId(rule, metric) {
|
|
60003
60676
|
const parent = rule.attributeParentFolder ?? '';
|
|
60004
60677
|
const { folderPath } = splitAttributePath(metric.attributeName);
|
|
60005
|
-
|
|
60006
|
-
|
|
60007
|
-
|
|
60678
|
+
// Nested folders are taken by SEGMENT INDEX below the parent (a prefix-leaked
|
|
60679
|
+
// sibling folder collapses onto the same id — measured 2026-09-04).
|
|
60680
|
+
const beyond = folderPath.split('|').slice(parent.split('|').length);
|
|
60008
60681
|
const nested = beyond.slice(0, Math.max(0, rule.nest_levels));
|
|
60009
|
-
const
|
|
60010
|
-
|
|
60682
|
+
const values = {
|
|
60683
|
+
sourceName: metric.sourceName,
|
|
60684
|
+
attributeParentFolder: parent,
|
|
60685
|
+
nest_levels: nested.length > 0 ? nested.join('|') : undefined,
|
|
60686
|
+
};
|
|
60687
|
+
const order = parseExternalIdFormat(rule.externalIdFormat) ?? ['sourceName', 'attributeParentFolder', 'nest_levels'];
|
|
60688
|
+
const body = order.map((p) => values[p]).filter((v) => v !== undefined).join('|');
|
|
60689
|
+
// Real vertices carry `TC|` right after the layer (measured 2026-09-01).
|
|
60690
|
+
return `${rule.layer}:TC|${body}`;
|
|
60011
60691
|
}
|
|
60012
60692
|
/** Vertex-name derivation: last N pipe-segments of the id minus "<layer>:". */
|
|
60013
60693
|
function deriveVertexName(externalId, layer, vertexNameIndex) {
|
|
@@ -60031,14 +60711,39 @@ function projectRule(rule, metrics) {
|
|
|
60031
60711
|
return { vertices: [], matchedCount: 0, rejected, warnings };
|
|
60032
60712
|
}
|
|
60033
60713
|
if (rule.externalIdFormat &&
|
|
60034
|
-
rule.externalIdFormat !== DEFAULT_EXTERNAL_ID_FORMAT
|
|
60035
|
-
|
|
60036
|
-
|
|
60037
|
-
|
|
60038
|
-
|
|
60714
|
+
rule.externalIdFormat !== DEFAULT_EXTERNAL_ID_FORMAT &&
|
|
60715
|
+
parseExternalIdFormat(rule.externalIdFormat) === null) {
|
|
60716
|
+
warnings.push(`externalIdFormat "${rule.externalIdFormat}" will be rejected on save — only the three substitutes \${sourceName}, \${attributeParentFolder}, \${nest_levels} joined by "|" (any order) are accepted; projected with the default order.`);
|
|
60717
|
+
}
|
|
60718
|
+
const derivedAttributeName = `${parent.replace(/\|/g, '\\|')}.*`;
|
|
60719
|
+
if (rule.attributeName && rule.attributeName !== derivedAttributeName && rule.attributeName !== `${parent}.*`) {
|
|
60720
|
+
warnings.push('attributeName is set, but it did not narrow the server preview in any form (literal, regex, escaped — measured 2026-09-24); the local projection does not apply it.');
|
|
60721
|
+
}
|
|
60722
|
+
const compiled = compileTcSourceName(rule.sourceName);
|
|
60723
|
+
if (!compiled.ok)
|
|
60724
|
+
warnings.push(compiled.message);
|
|
60725
|
+
const keyIssues = customAttributeKeyIssues(rule.customAttributes);
|
|
60726
|
+
if (keyIssues.reserved.length > 0) {
|
|
60727
|
+
warnings.push(`customAttributes ${keyIssues.reserved.map((k) => `"${k}"`).join(', ')} use reserved names — the server rejects the rule at save (HTTP 500).`);
|
|
60728
|
+
}
|
|
60729
|
+
if (keyIssues.shadowed.length > 0) {
|
|
60730
|
+
warnings.push(`customAttributes ${keyIssues.shadowed.map((k) => `"${k}"`).join(', ')} reuse standard vertex attribute names — the standard value wins and the custom one is dropped (measured). Rename them.`);
|
|
60731
|
+
}
|
|
60732
|
+
const standardKeys = new Set(TC_STANDARD_ATTRIBUTE_KEYS);
|
|
60733
|
+
const shadowedDynamic = new Set();
|
|
60734
|
+
if (FILTER_KEYS.some((k) => (rule[k] ?? []).length > 0)) {
|
|
60735
|
+
warnings.push('attribute filters are emulated from partial measurements (each folder segment from the nest level down, full-match) — trust the server preview for the exact filtered set.');
|
|
60736
|
+
}
|
|
60737
|
+
// EMPIRICAL (demo-dev 2026-09-24): parent folders with a "." in them
|
|
60738
|
+
// ("JMX|Default|java.nio", "…|org.apache.activemq") previewed 0 metrics
|
|
60739
|
+
// while "JMX|Default" and the dot-free "Agents|localhost|Infrastructure"
|
|
60740
|
+
// matched.
|
|
60741
|
+
const dottedParent = parent.includes('.');
|
|
60742
|
+
if (dottedParent) {
|
|
60743
|
+
warnings.push(`attributeParentFolder "${parent}" contains a "." — such parent folders matched no metrics on the server (measured). Stop the parent before the dotted segment and raise nest_levels.`);
|
|
60039
60744
|
}
|
|
60040
60745
|
for (const metric of metrics) {
|
|
60041
|
-
if (!
|
|
60746
|
+
if (!compiled.ok || !compiled.regex.test(metric.sourceName)) {
|
|
60042
60747
|
rejected.push({
|
|
60043
60748
|
id: metric.id,
|
|
60044
60749
|
stage: 'sourceName',
|
|
@@ -60047,7 +60752,9 @@ function projectRule(rule, metrics) {
|
|
|
60047
60752
|
continue;
|
|
60048
60753
|
}
|
|
60049
60754
|
const { folderPath, metricName } = splitAttributePath(metric.attributeName);
|
|
60050
|
-
|
|
60755
|
+
const underParent = !dottedParent && folderUnderParent(folderPath, parent);
|
|
60756
|
+
const leaked = !dottedParent && !underParent && folderMatchesDerivedPrefix(metric.attributeName, parent);
|
|
60757
|
+
if (!underParent && !leaked) {
|
|
60051
60758
|
rejected.push({
|
|
60052
60759
|
id: metric.id,
|
|
60053
60760
|
stage: 'attributeParentFolder',
|
|
@@ -60055,44 +60762,50 @@ function projectRule(rule, metrics) {
|
|
|
60055
60762
|
});
|
|
60056
60763
|
continue;
|
|
60057
60764
|
}
|
|
60058
|
-
if (
|
|
60059
|
-
|
|
60060
|
-
|
|
60061
|
-
|
|
60062
|
-
// for attributeName regexes (calibration C-item).
|
|
60063
|
-
ok = javaFullMatch(metric.attributeName, rule.attributeName.replace(/\|/g, '\\|'));
|
|
60064
|
-
}
|
|
60065
|
-
catch (err) {
|
|
60066
|
-
warnings.push(`attributeName regex error: ${err.message}`);
|
|
60067
|
-
}
|
|
60068
|
-
if (!ok) {
|
|
60069
|
-
rejected.push({
|
|
60070
|
-
id: metric.id,
|
|
60071
|
-
stage: 'attributeName',
|
|
60072
|
-
detail: `"${metric.attributeName}" !~ "${rule.attributeName}"`,
|
|
60073
|
-
});
|
|
60074
|
-
continue;
|
|
60075
|
-
}
|
|
60765
|
+
if (leaked) {
|
|
60766
|
+
const msg = `attributeParentFolder "${parent}" is a string prefix: sibling folders such as "${folderPath.split('|')[0]}" match too — name sibling folders so none is a prefix of another.`;
|
|
60767
|
+
if (!warnings.includes(msg))
|
|
60768
|
+
warnings.push(msg);
|
|
60076
60769
|
}
|
|
60077
|
-
const attrVerdict = applyFilters(folderPath, rule.attribute_incl_filter, rule.attribute_incl_filter_regex, rule.attribute_excl_filter, rule.attribute_excl_filter_regex);
|
|
60770
|
+
const attrVerdict = applyFilters(attributeFilterTargets(folderPath, parent, rule.nest_levels), rule.attribute_incl_filter, rule.attribute_incl_filter_regex, rule.attribute_excl_filter, rule.attribute_excl_filter_regex);
|
|
60078
60771
|
if (!attrVerdict.pass) {
|
|
60079
60772
|
rejected.push({ id: metric.id, stage: 'attribute_filters', detail: attrVerdict.detail });
|
|
60080
60773
|
continue;
|
|
60081
60774
|
}
|
|
60082
|
-
const metricVerdict = applyFilters(metricName, rule.metric_incl_filter, rule.metric_incl_filter_regex, rule.metric_excl_filter, rule.metric_excl_filter_regex);
|
|
60775
|
+
const metricVerdict = applyFilters([metricName], rule.metric_incl_filter, rule.metric_incl_filter_regex, rule.metric_excl_filter, rule.metric_excl_filter_regex);
|
|
60083
60776
|
if (!metricVerdict.pass) {
|
|
60084
60777
|
rejected.push({ id: metric.id, stage: 'metric_filters', detail: metricVerdict.detail });
|
|
60085
60778
|
continue;
|
|
60086
60779
|
}
|
|
60780
|
+
// EMPIRICAL (THE_LABORATORY, 2026-09-24): a metric with fewer folders below
|
|
60781
|
+
// the parent than nest_levels is MATCHED (the server preview lists it) but
|
|
60782
|
+
// builds NO vertex — e.g. "Agents:PLA Devices" under parent "Agents" with
|
|
60783
|
+
// nest_levels 3. Deeper metrics collapse onto the vertex at the nest depth.
|
|
60784
|
+
const depth = folderPath.split('|').length - parent.split('|').length;
|
|
60785
|
+
if (depth < rule.nest_levels) {
|
|
60786
|
+
rejected.push({
|
|
60787
|
+
id: metric.id,
|
|
60788
|
+
stage: 'nest_levels',
|
|
60789
|
+
detail: `"${folderPath}" has ${depth} folder(s) below "${parent}", fewer than nest_levels ${rule.nest_levels} — matched, but no vertex is built`,
|
|
60790
|
+
});
|
|
60791
|
+
continue;
|
|
60792
|
+
}
|
|
60087
60793
|
matchedCount++;
|
|
60088
|
-
const externalId = formExternalId({
|
|
60794
|
+
const externalId = formExternalId({
|
|
60795
|
+
layer: rule.layer,
|
|
60796
|
+
attributeParentFolder: parent,
|
|
60797
|
+
nest_levels: rule.nest_levels,
|
|
60798
|
+
externalIdFormat: rule.externalIdFormat,
|
|
60799
|
+
}, metric);
|
|
60089
60800
|
let vertex = byExternalId.get(externalId);
|
|
60090
60801
|
if (!vertex) {
|
|
60802
|
+
const name = deriveVertexName(externalId, rule.layer, rule.vertexNameIndex);
|
|
60091
60803
|
vertex = {
|
|
60092
60804
|
externalId,
|
|
60093
|
-
name
|
|
60805
|
+
name,
|
|
60094
60806
|
type: rule.type,
|
|
60095
60807
|
layer: rule.layer,
|
|
60808
|
+
standardAttributes: standardVertexAttributes(rule, metric.sourceName, name),
|
|
60096
60809
|
customAttributes: {},
|
|
60097
60810
|
attributeConflicts: {},
|
|
60098
60811
|
metrics: [],
|
|
@@ -60110,6 +60823,11 @@ function projectRule(rule, metrics) {
|
|
|
60110
60823
|
const { attributes, traces } = projectCustomAttributes(rule.customAttributes ?? {}, metric);
|
|
60111
60824
|
vertex.traces[metric.id] = traces;
|
|
60112
60825
|
for (const [key, value] of Object.entries(attributes)) {
|
|
60826
|
+
if (standardKeys.has(key)) {
|
|
60827
|
+
if (!(key in (rule.customAttributes ?? {})))
|
|
60828
|
+
shadowedDynamic.add(key);
|
|
60829
|
+
continue;
|
|
60830
|
+
}
|
|
60113
60831
|
const existing = vertex.customAttributes[key];
|
|
60114
60832
|
if (existing !== undefined && existing !== value) {
|
|
60115
60833
|
const conflicts = vertex.attributeConflicts[key] ?? [existing];
|
|
@@ -60117,11 +60835,16 @@ function projectRule(rule, metrics) {
|
|
|
60117
60835
|
conflicts.push(value);
|
|
60118
60836
|
vertex.attributeConflicts[key] = conflicts;
|
|
60119
60837
|
}
|
|
60120
|
-
//
|
|
60121
|
-
//
|
|
60122
|
-
|
|
60838
|
+
// First value wins (C8: the vertex kept the first-registered metric's
|
|
60839
|
+
// value, stable over 60 s — measured once, 2026-09-24); conflicts are
|
|
60840
|
+
// surfaced either way.
|
|
60841
|
+
if (existing === undefined)
|
|
60842
|
+
vertex.customAttributes[key] = value;
|
|
60123
60843
|
}
|
|
60124
60844
|
}
|
|
60845
|
+
if (shadowedDynamic.size > 0) {
|
|
60846
|
+
warnings.push(`templated customAttribute keys evaluated to standard vertex attribute names (${[...shadowedDynamic].map((k) => `"${k}"`).join(', ')}) — those values are dropped; the standard value wins.`);
|
|
60847
|
+
}
|
|
60125
60848
|
return {
|
|
60126
60849
|
vertices: [...byExternalId.values()],
|
|
60127
60850
|
matchedCount,
|
|
@@ -60129,17 +60852,6 @@ function projectRule(rule, metrics) {
|
|
|
60129
60852
|
warnings,
|
|
60130
60853
|
};
|
|
60131
60854
|
}
|
|
60132
|
-
function safeTcSourceMatch(sourceName, pattern, warnings) {
|
|
60133
|
-
try {
|
|
60134
|
-
return tcSourceNameMatches(sourceName, pattern);
|
|
60135
|
-
}
|
|
60136
|
-
catch (err) {
|
|
60137
|
-
const msg = `sourceName pattern error: ${err.message}`;
|
|
60138
|
-
if (!warnings.includes(msg))
|
|
60139
|
-
warnings.push(msg);
|
|
60140
|
-
return false;
|
|
60141
|
-
}
|
|
60142
|
-
}
|
|
60143
60855
|
/**
|
|
60144
60856
|
* Bounds the per-vertex detail (`metrics` and their `traces`) to the first
|
|
60145
60857
|
* `limit` contributing metrics. Grouping and counts are untouched —
|
|
@@ -60167,6 +60879,466 @@ function capVertexDetail(projection, limit) {
|
|
|
60167
60879
|
};
|
|
60168
60880
|
}
|
|
60169
60881
|
|
|
60882
|
+
/**
|
|
60883
|
+
* The sourceName calibration corpus: the 23-case battery (five sources) and
|
|
60884
|
+
* the 22-rule construct matrix (twelve sources) measured against DXO2 26.8.2
|
|
60885
|
+
* on two tenants (2026-09-01/04). `expected` lists the source ids the SERVER
|
|
60886
|
+
* matched. The offline test checks the local engine against these; the live
|
|
60887
|
+
* suite and the matrix driver re-measure the server against them. `token`
|
|
60888
|
+
* makes source names run-unique — a metric identity that aged out cannot be
|
|
60889
|
+
* registered again, so a live run always mints a fresh token.
|
|
60890
|
+
*/
|
|
60891
|
+
const escapePipes = (s) => s.replace(/\|/g, '\\|');
|
|
60892
|
+
function sourceNameBattery(token) {
|
|
60893
|
+
const T = token;
|
|
60894
|
+
const sources = {
|
|
60895
|
+
a: `SuperDomain|${T}-host-a|AMQ|${T}-agent-a`,
|
|
60896
|
+
b: `SuperDomain|${T}-host-b|AMQ|${T}-agent-b`,
|
|
60897
|
+
c: `SuperDomain|${T}-host-c|KFK|${T}-agent-c`,
|
|
60898
|
+
d: `SuperDomain|${T}-host-d (v)|AMQ|${T}-agent-d`,
|
|
60899
|
+
e: `SuperDomain|${T}-HOST-E|amq|${T}-AGENT-E`,
|
|
60900
|
+
};
|
|
60901
|
+
const legacyFull = `SuperDomain|${T}-host-.*|AMQ|${T}-agent-.*`;
|
|
60902
|
+
const cases = [
|
|
60903
|
+
{ id: 'control', construct: 'freshness control', sourceName: `.*${T}-host-[ab].*`, expected: ['a', 'b'] },
|
|
60904
|
+
{ id: 'legacy-full', construct: 'four segments, plain pipes', sourceName: legacyFull, expected: ['a', 'b', 'd', 'e'] },
|
|
60905
|
+
{ id: 'legacy-prefix', construct: 'two segments + .*', sourceName: `SuperDomain|${T}-host-.*`, expected: ['a', 'b', 'c', 'd', 'e'] },
|
|
60906
|
+
{ id: 'escaped-full', construct: 'user-escaped \\|', sourceName: escapePipes(legacyFull), expected: [] },
|
|
60907
|
+
{
|
|
60908
|
+
id: 'alternation',
|
|
60909
|
+
construct: 'two escaped names joined by |',
|
|
60910
|
+
sourceName: `${escapePipes(sources.a)}|${escapePipes(sources.c)}`,
|
|
60911
|
+
expected: [],
|
|
60912
|
+
},
|
|
60913
|
+
{
|
|
60914
|
+
id: 'group-alt-escaped',
|
|
60915
|
+
construct: '(a|b) with escaped outer pipes',
|
|
60916
|
+
sourceName: `${escapePipes(`SuperDomain|${T}-host-`)}(a|b)${escapePipes('|AMQ|')}.*`,
|
|
60917
|
+
expected: ['a', 'b', 'c', 'd', 'e'],
|
|
60918
|
+
},
|
|
60919
|
+
{ id: 'anchored', construct: '^…$ around an escaped name', sourceName: `^${escapePipes(sources.b)}$`, expected: [] },
|
|
60920
|
+
{ id: 'bare', construct: 'bare substring', sourceName: `${T}-host-a`, expected: [] },
|
|
60921
|
+
{ id: 'quoted', construct: '\\Q…\\E around a raw name', sourceName: `\\Q${sources.a}\\E`, expected: [] },
|
|
60922
|
+
{
|
|
60923
|
+
id: 'unbalanced-paren-escaped',
|
|
60924
|
+
construct: 'escaped pipe + lone (',
|
|
60925
|
+
sourceName: `${escapePipes(`SuperDomain|${T}-host-`)}(`,
|
|
60926
|
+
expected: [],
|
|
60927
|
+
},
|
|
60928
|
+
{
|
|
60929
|
+
id: 'group-alt-unescaped',
|
|
60930
|
+
construct: '(a|b) with plain outer pipes',
|
|
60931
|
+
sourceName: `SuperDomain|${T}-host-(a|b)|AMQ|.*`,
|
|
60932
|
+
expected: ['a', 'b'],
|
|
60933
|
+
},
|
|
60934
|
+
{
|
|
60935
|
+
id: 'literal-parens',
|
|
60936
|
+
construct: 'parentheses without a pipe are literal',
|
|
60937
|
+
sourceName: `SuperDomain|${T}-host-d (v)|AMQ|.*`,
|
|
60938
|
+
expected: ['d'],
|
|
60939
|
+
},
|
|
60940
|
+
{
|
|
60941
|
+
id: 'parens-pipe-trap',
|
|
60942
|
+
construct: '(v|w) no longer matches a literal (v)',
|
|
60943
|
+
sourceName: `SuperDomain|${T}-host-d (v|w)|AMQ|.*`,
|
|
60944
|
+
expected: [],
|
|
60945
|
+
},
|
|
60946
|
+
{ id: 'plus-literal', construct: '[ab]+ — plus is literal', sourceName: `SuperDomain|${T}-host-[ab]+|AMQ|.*`, expected: [] },
|
|
60947
|
+
{ id: 'brace-literal', construct: '[a-c]{1} — braces are literal', sourceName: `SuperDomain|${T}-host-[a-c]{1}|.*`, expected: [] },
|
|
60948
|
+
{ id: 'optional-literal', construct: 'ax? — question mark is literal', sourceName: `SuperDomain|${T}-host-ax?|AMQ|.*`, expected: [] },
|
|
60949
|
+
{ id: 'star-dropped', construct: 'a** — bare stars are dropped', sourceName: `SuperDomain|${T}-host-a**|AMQ|.*`, expected: ['a'] },
|
|
60950
|
+
{
|
|
60951
|
+
id: 'case-flip',
|
|
60952
|
+
construct: 'upper-case pattern, lower-case source',
|
|
60953
|
+
sourceName: `SUPERDOMAIN|${T}-HOST-A|amq|${T}-Agent-A`,
|
|
60954
|
+
expected: ['a'],
|
|
60955
|
+
},
|
|
60956
|
+
{
|
|
60957
|
+
id: 'case-source',
|
|
60958
|
+
construct: 'lower-case pattern, upper-case source',
|
|
60959
|
+
sourceName: `SuperDomain|${T}-host-e|AMQ|.*`,
|
|
60960
|
+
expected: ['e'],
|
|
60961
|
+
},
|
|
60962
|
+
{
|
|
60963
|
+
id: 'brace-inside-pipe-group',
|
|
60964
|
+
construct: '{1} stays literal inside (…|…)',
|
|
60965
|
+
sourceName: `SuperDomain|${T}-host-([ab]{1}|c)|.*`,
|
|
60966
|
+
expected: ['c'],
|
|
60967
|
+
},
|
|
60968
|
+
{
|
|
60969
|
+
id: 'dot-matches-pipe',
|
|
60970
|
+
construct: '. in place of |',
|
|
60971
|
+
sourceName: `SuperDomain.${T}-host-a.AMQ.${T}-agent-a`,
|
|
60972
|
+
expected: ['a'],
|
|
60973
|
+
},
|
|
60974
|
+
{ id: 'invalid-bracket', construct: 'unclosed [ — silent no-match', sourceName: `SuperDomain|${T}-host-[`, expected: [] },
|
|
60975
|
+
{ id: 'wildcard-only', construct: 'only wildcards — refused', sourceName: '.*', expected: [] },
|
|
60976
|
+
];
|
|
60977
|
+
return { sources, cases };
|
|
60978
|
+
}
|
|
60979
|
+
function sourceNameMatrix(token) {
|
|
60980
|
+
const T = token;
|
|
60981
|
+
const sources = {
|
|
60982
|
+
web01: `SuperDomain|${T}-web01|AMQ|${T}-agent-web01`,
|
|
60983
|
+
web02: `SuperDomain|${T}-web02|AMQ|${T}-agent-web02`,
|
|
60984
|
+
web10: `SuperDomain|${T}-web10|AMQ|${T}-agent-web10`,
|
|
60985
|
+
web1: `SuperDomain|${T}-web1|AMQ|${T}-agent-web1`,
|
|
60986
|
+
WEB03: `SuperDomain|${T}-WEB03|amq|${T}-AGENT-WEB03`,
|
|
60987
|
+
db1: `SuperDomain|${T}-db1|KFK|${T}-agent-db1`,
|
|
60988
|
+
db22: `SuperDomain|${T}-db22|KFK|${T}-agent-db22`,
|
|
60989
|
+
app: `SuperDomain|${T}-app|Tomcat|${T}-agent-app`,
|
|
60990
|
+
'app-prod': `SuperDomain|${T}-app|Tomcat (Prod)|${T}-agent-app-prod`,
|
|
60991
|
+
'cache-a': `SuperDomain|${T}-cache|AMQ|${T}-agent-cache-a`,
|
|
60992
|
+
'cache-aa': `SuperDomain|${T}-cache|AMQ|${T}-agent-cache-aa`,
|
|
60993
|
+
'cache-aaa': `SuperDomain|${T}-cache|AMQ|${T}-agent-cache-aaa`,
|
|
60994
|
+
};
|
|
60995
|
+
const ALL = Object.keys(sources);
|
|
60996
|
+
const cases = [
|
|
60997
|
+
{
|
|
60998
|
+
id: 'class-digits',
|
|
60999
|
+
construct: '[0-9][0-9] character classes (+ case-insensitivity)',
|
|
61000
|
+
sourceName: `SuperDomain|${T}-web[0-9][0-9]|AMQ|.*`,
|
|
61001
|
+
expected: ['web01', 'web02', 'web10', 'WEB03'],
|
|
61002
|
+
},
|
|
61003
|
+
{ id: 'brace-quantifier', construct: '{2} brace quantifier', sourceName: `SuperDomain|${T}-web[0-9]{2}|AMQ|.*`, expected: [] },
|
|
61004
|
+
{ id: 'plus-quantifier', construct: 'a+ plus quantifier', sourceName: `SuperDomain|${T}-cache|AMQ|${T}-agent-cache-a+`, expected: [] },
|
|
61005
|
+
{
|
|
61006
|
+
id: 'star-bare',
|
|
61007
|
+
construct: 'aa* bare star (server drops a bare *)',
|
|
61008
|
+
sourceName: `SuperDomain|${T}-cache|AMQ|${T}-agent-cache-aa*`,
|
|
61009
|
+
expected: ['cache-aa'],
|
|
61010
|
+
},
|
|
61011
|
+
{
|
|
61012
|
+
id: 'dot-star',
|
|
61013
|
+
construct: 'a.* dot-star',
|
|
61014
|
+
sourceName: `SuperDomain|${T}-cache|AMQ|${T}-agent-cache-a.*`,
|
|
61015
|
+
expected: ['cache-a', 'cache-aa', 'cache-aaa'],
|
|
61016
|
+
},
|
|
61017
|
+
{
|
|
61018
|
+
id: 'dot-single',
|
|
61019
|
+
construct: 'a. single-char wildcard',
|
|
61020
|
+
sourceName: `SuperDomain|${T}-cache|AMQ|${T}-agent-cache-a.`,
|
|
61021
|
+
expected: ['cache-aa'],
|
|
61022
|
+
},
|
|
61023
|
+
{ id: 'optional', construct: '0? optional quantifier', sourceName: `SuperDomain|${T}-web0?1|AMQ|.*`, expected: [] },
|
|
61024
|
+
{ id: 'backslash-d', construct: '\\d digit class', sourceName: `SuperDomain|${T}-db\\d|KFK|.*`, expected: ['db1'] },
|
|
61025
|
+
{ id: 'backslash-d-plus', construct: '\\d+ digit class + quantifier', sourceName: `SuperDomain|${T}-db\\d+|KFK|.*`, expected: [] },
|
|
61026
|
+
{
|
|
61027
|
+
id: 'group-alt-process',
|
|
61028
|
+
construct: '(AMQ|KFK) group alternation, process segment',
|
|
61029
|
+
sourceName: `SuperDomain|${T}-.*|(AMQ|KFK)|.*`,
|
|
61030
|
+
expected: ['web01', 'web02', 'web10', 'web1', 'WEB03', 'db1', 'db22', 'cache-a', 'cache-aa', 'cache-aaa'],
|
|
61031
|
+
},
|
|
61032
|
+
{
|
|
61033
|
+
id: 'group-alt-host',
|
|
61034
|
+
construct: '(db1|app) group alternation, host segment',
|
|
61035
|
+
sourceName: `SuperDomain|${T}-(db1|app)|.*`,
|
|
61036
|
+
expected: ['db1', 'app', 'app-prod'],
|
|
61037
|
+
},
|
|
61038
|
+
{
|
|
61039
|
+
id: 'group-alt-agent',
|
|
61040
|
+
construct: '(a|aaa) group alternation, agent segment',
|
|
61041
|
+
sourceName: `SuperDomain|${T}-cache|AMQ|${T}-agent-cache-(a|aaa)`,
|
|
61042
|
+
expected: ['cache-a', 'cache-aaa'],
|
|
61043
|
+
},
|
|
61044
|
+
{
|
|
61045
|
+
id: 'nested-group',
|
|
61046
|
+
construct: '((web|db)1) nested group',
|
|
61047
|
+
sourceName: `SuperDomain|${T}-((web|db)1)|.*`,
|
|
61048
|
+
expected: ['web1', 'db1'],
|
|
61049
|
+
},
|
|
61050
|
+
{
|
|
61051
|
+
id: 'literal-parens',
|
|
61052
|
+
construct: '(Prod) parentheses with no pipe = literal',
|
|
61053
|
+
sourceName: `SuperDomain|${T}-app|Tomcat (Prod)|.*`,
|
|
61054
|
+
expected: ['app-prod'],
|
|
61055
|
+
},
|
|
61056
|
+
{
|
|
61057
|
+
id: 'parens-pipe-trap',
|
|
61058
|
+
construct: '(Prod|Dev) becomes a group, no longer matches literal parens',
|
|
61059
|
+
sourceName: `SuperDomain|${T}-app|Tomcat (Prod|Dev)|.*`,
|
|
61060
|
+
expected: [],
|
|
61061
|
+
},
|
|
61062
|
+
{
|
|
61063
|
+
id: 'escaped-pipes',
|
|
61064
|
+
construct: 'user-escaped \\| (breaks)',
|
|
61065
|
+
sourceName: `SuperDomain\\|${T}-web01\\|AMQ\\|.*`,
|
|
61066
|
+
expected: ALL,
|
|
61067
|
+
},
|
|
61068
|
+
{
|
|
61069
|
+
id: 'case-flip',
|
|
61070
|
+
construct: 'case-insensitive match',
|
|
61071
|
+
sourceName: `superdomain|${T}-WEB01|amq|${T}-Agent-Web01`,
|
|
61072
|
+
expected: ['web01'],
|
|
61073
|
+
},
|
|
61074
|
+
{ id: 'anchors', construct: '^ … $ anchors', sourceName: `^SuperDomain|${T}-db.*$`, expected: ['db1', 'db22'] },
|
|
61075
|
+
{
|
|
61076
|
+
id: 'top-level-alternation',
|
|
61077
|
+
construct: 'two full names joined by top-level |',
|
|
61078
|
+
sourceName: `SuperDomain|${T}-db1|KFK|${T}-agent-db1|SuperDomain|${T}-app|Tomcat|${T}-agent-app`,
|
|
61079
|
+
expected: [],
|
|
61080
|
+
},
|
|
61081
|
+
{
|
|
61082
|
+
id: 'prefix-only',
|
|
61083
|
+
construct: 'host prefix + .*',
|
|
61084
|
+
sourceName: `SuperDomain|${T}-web.*`,
|
|
61085
|
+
expected: ['web01', 'web02', 'web10', 'web1', 'WEB03'],
|
|
61086
|
+
},
|
|
61087
|
+
{
|
|
61088
|
+
id: 'dot-matches-pipe',
|
|
61089
|
+
construct: '. in place of | (dot matches pipe)',
|
|
61090
|
+
sourceName: `SuperDomain.${T}-db1.KFK.${T}-agent-db1`,
|
|
61091
|
+
expected: ['db1'],
|
|
61092
|
+
},
|
|
61093
|
+
{
|
|
61094
|
+
id: 'class-negation',
|
|
61095
|
+
construct: '[^0] negated class',
|
|
61096
|
+
sourceName: `SuperDomain|${T}-web[^0].*|AMQ|.*`,
|
|
61097
|
+
expected: ['web10', 'web1'],
|
|
61098
|
+
},
|
|
61099
|
+
];
|
|
61100
|
+
return { sources, cases };
|
|
61101
|
+
}
|
|
61102
|
+
|
|
61103
|
+
const SEVERITY_ORDER = { error: 0, warning: 1, info: 2 };
|
|
61104
|
+
function scan(p) {
|
|
61105
|
+
const s = {
|
|
61106
|
+
escapedPipes: [],
|
|
61107
|
+
escapedParens: [],
|
|
61108
|
+
quoted: [],
|
|
61109
|
+
propertyOutsideClass: [],
|
|
61110
|
+
propertyInsideClass: [],
|
|
61111
|
+
nestedBrackets: [],
|
|
61112
|
+
quantifiers: [],
|
|
61113
|
+
braces: [],
|
|
61114
|
+
bareStars: [],
|
|
61115
|
+
topLevelPipes: [],
|
|
61116
|
+
upperOrLowerClass: [],
|
|
61117
|
+
literalParens: [],
|
|
61118
|
+
};
|
|
61119
|
+
const groups = pipeGroupRanges(p);
|
|
61120
|
+
const inGroup = (i) => groups.some(([a, b]) => i >= a && i <= b);
|
|
61121
|
+
let inClass = false;
|
|
61122
|
+
let depth = 0;
|
|
61123
|
+
for (let i = 0; i < p.length; i++) {
|
|
61124
|
+
const c = p[i];
|
|
61125
|
+
if (c === '\\') {
|
|
61126
|
+
const n = p[i + 1];
|
|
61127
|
+
if (n === '|')
|
|
61128
|
+
s.escapedPipes.push(i);
|
|
61129
|
+
else if (n === '(' || n === ')')
|
|
61130
|
+
s.escapedParens.push(i);
|
|
61131
|
+
else if (n === 'Q')
|
|
61132
|
+
s.quoted.push(i);
|
|
61133
|
+
else if (n === 'p' || n === 'P')
|
|
61134
|
+
(inClass ? s.propertyInsideClass : s.propertyOutsideClass).push(i);
|
|
61135
|
+
i++;
|
|
61136
|
+
continue;
|
|
61137
|
+
}
|
|
61138
|
+
if (inClass) {
|
|
61139
|
+
if (c === '[')
|
|
61140
|
+
s.nestedBrackets.push(i);
|
|
61141
|
+
else if (c === ']')
|
|
61142
|
+
inClass = false;
|
|
61143
|
+
continue;
|
|
61144
|
+
}
|
|
61145
|
+
if (c === '[') {
|
|
61146
|
+
inClass = true;
|
|
61147
|
+
if (/^\[\^?[A-Z]-[A-Z]/.test(p.slice(i)) || /^\[\^?[a-z]-[a-z]/.test(p.slice(i)))
|
|
61148
|
+
s.upperOrLowerClass.push(i);
|
|
61149
|
+
continue;
|
|
61150
|
+
}
|
|
61151
|
+
if (c === '(') {
|
|
61152
|
+
depth++;
|
|
61153
|
+
if (!inGroup(i))
|
|
61154
|
+
s.literalParens.push(i);
|
|
61155
|
+
continue;
|
|
61156
|
+
}
|
|
61157
|
+
if (c === ')') {
|
|
61158
|
+
depth = Math.max(0, depth - 1);
|
|
61159
|
+
continue;
|
|
61160
|
+
}
|
|
61161
|
+
if (c === '+' || (c === '?' && p[i - 1] !== '('))
|
|
61162
|
+
s.quantifiers.push(i);
|
|
61163
|
+
else if (c === '{') {
|
|
61164
|
+
const close = p.indexOf('}', i);
|
|
61165
|
+
s.braces.push({ start: i, end: close === -1 ? i + 1 : close + 1 });
|
|
61166
|
+
}
|
|
61167
|
+
else if (c === '*' && p[i - 1] !== '.')
|
|
61168
|
+
s.bareStars.push(i);
|
|
61169
|
+
else if (c === '|' && depth === 0)
|
|
61170
|
+
s.topLevelPipes.push(i);
|
|
61171
|
+
}
|
|
61172
|
+
return s;
|
|
61173
|
+
}
|
|
61174
|
+
function topLevelSegments(p, pipes) {
|
|
61175
|
+
const out = [];
|
|
61176
|
+
let from = 0;
|
|
61177
|
+
for (const i of pipes) {
|
|
61178
|
+
out.push(p.slice(from, i));
|
|
61179
|
+
from = i + 1;
|
|
61180
|
+
}
|
|
61181
|
+
out.push(p.slice(from));
|
|
61182
|
+
return out;
|
|
61183
|
+
}
|
|
61184
|
+
/** `X{n}` → X repeated n times, for a class, a `\x` escape, or a single character (n ≤ 9). */
|
|
61185
|
+
function expandBraces(p) {
|
|
61186
|
+
const re = /(\[[^\]]*\]|\\[a-zA-Z]|[^\\[\](){}|+?*.])\{([1-9])\}/g;
|
|
61187
|
+
if (!re.test(p))
|
|
61188
|
+
return undefined;
|
|
61189
|
+
return p.replace(re, (_m, atom, n) => atom.repeat(Number(n)));
|
|
61190
|
+
}
|
|
61191
|
+
function lintSourceName(pattern) {
|
|
61192
|
+
if (!pattern)
|
|
61193
|
+
return [];
|
|
61194
|
+
const hints = [];
|
|
61195
|
+
const s = scan(pattern);
|
|
61196
|
+
const at = (i, len = 2) => ({ start: i, end: i + len });
|
|
61197
|
+
if (isWildcardOnlySourceName(pattern)) {
|
|
61198
|
+
hints.push({
|
|
61199
|
+
ruleId: 'wildcard-only',
|
|
61200
|
+
severity: 'error',
|
|
61201
|
+
message: 'A pattern made only of wildcards matches nothing — the server refuses catch-alls.',
|
|
61202
|
+
span: { start: 0, end: pattern.length },
|
|
61203
|
+
suggestion: '.*|.*|.*|.*',
|
|
61204
|
+
});
|
|
61205
|
+
return hints;
|
|
61206
|
+
}
|
|
61207
|
+
if (s.escapedPipes.length > 0) {
|
|
61208
|
+
hints.push({
|
|
61209
|
+
ruleId: 'escaped-pipe',
|
|
61210
|
+
severity: 'error',
|
|
61211
|
+
message: 'Do not escape pipes: the server escapes them itself, so \\| becomes a literal backslash plus real alternation.',
|
|
61212
|
+
span: at(s.escapedPipes[0]),
|
|
61213
|
+
suggestion: pattern.replace(/\\\|/g, '|'),
|
|
61214
|
+
});
|
|
61215
|
+
}
|
|
61216
|
+
if (s.escapedParens.length > 0) {
|
|
61217
|
+
hints.push({
|
|
61218
|
+
ruleId: 'escaped-paren',
|
|
61219
|
+
severity: 'error',
|
|
61220
|
+
message: 'Do not escape parentheses: parentheses without a | inside are already literal, and \\( breaks the match.',
|
|
61221
|
+
span: at(s.escapedParens[0]),
|
|
61222
|
+
suggestion: pattern.replace(/\\([()])/g, '$1'),
|
|
61223
|
+
});
|
|
61224
|
+
}
|
|
61225
|
+
if (s.quoted.length > 0) {
|
|
61226
|
+
hints.push({
|
|
61227
|
+
ruleId: 'quoted-literal',
|
|
61228
|
+
severity: 'error',
|
|
61229
|
+
message: '\\Q…\\E never matches: the pipes inside the quote are escaped too. Write the name plainly.',
|
|
61230
|
+
span: at(s.quoted[0]),
|
|
61231
|
+
suggestion: pattern.replace(/\\Q/g, '').replace(/\\E/g, ''),
|
|
61232
|
+
});
|
|
61233
|
+
}
|
|
61234
|
+
if (s.propertyOutsideClass.length > 0) {
|
|
61235
|
+
const i = s.propertyOutsideClass[0];
|
|
61236
|
+
hints.push({
|
|
61237
|
+
ruleId: 'unicode-property',
|
|
61238
|
+
severity: 'error',
|
|
61239
|
+
message: 'A Unicode property (\\pL) only works inside a character class: write [\\pL].',
|
|
61240
|
+
span: at(i, 3),
|
|
61241
|
+
suggestion: pattern.replace(/\\([pP])(\{[^}]*\}|[A-Za-z])/g, (m, _p, _n, off) => s.propertyOutsideClass.includes(off) ? `[${m}]` : m),
|
|
61242
|
+
});
|
|
61243
|
+
}
|
|
61244
|
+
if (s.nestedBrackets.length > 0) {
|
|
61245
|
+
hints.push({
|
|
61246
|
+
ruleId: 'nested-brackets',
|
|
61247
|
+
severity: 'error',
|
|
61248
|
+
message: 'A character class ends at the first ] — nested classes ([[:digit:]], [a-z&&[^b]]) break the pattern.',
|
|
61249
|
+
span: at(s.nestedBrackets[0], 1),
|
|
61250
|
+
});
|
|
61251
|
+
}
|
|
61252
|
+
const compiled = compileTcSourceName(pattern);
|
|
61253
|
+
if (!compiled.ok && compiled.reason === 'invalid' && s.nestedBrackets.length === 0) {
|
|
61254
|
+
hints.push({
|
|
61255
|
+
ruleId: 'unbalanced',
|
|
61256
|
+
severity: 'error',
|
|
61257
|
+
message: 'This pattern does not compile, so it matches nothing — and the server reports no error. Check every [ and (.',
|
|
61258
|
+
});
|
|
61259
|
+
}
|
|
61260
|
+
if (s.quantifiers.length > 0 || s.braces.length > 0) {
|
|
61261
|
+
const first = Math.min(...s.quantifiers, ...s.braces.map((b) => b.start));
|
|
61262
|
+
const expanded = expandBraces(pattern);
|
|
61263
|
+
hints.push({
|
|
61264
|
+
ruleId: 'quantifier-literal',
|
|
61265
|
+
severity: 'warning',
|
|
61266
|
+
message: '+, ? and {n} are literal characters here (inside (…|…) groups too). Repeat the class instead ([0-9][0-9]), use .* for "one or more", or a (x|y) group for "optional".',
|
|
61267
|
+
span: at(first, 1),
|
|
61268
|
+
...(expanded !== undefined ? { suggestion: expanded } : {}),
|
|
61269
|
+
});
|
|
61270
|
+
}
|
|
61271
|
+
if (s.bareStars.length > 0) {
|
|
61272
|
+
let offset = 0;
|
|
61273
|
+
let suggestion = pattern;
|
|
61274
|
+
for (const i of s.bareStars) {
|
|
61275
|
+
suggestion = `${suggestion.slice(0, i + offset)}.${suggestion.slice(i + offset)}`;
|
|
61276
|
+
offset++;
|
|
61277
|
+
}
|
|
61278
|
+
hints.push({
|
|
61279
|
+
ruleId: 'bare-star',
|
|
61280
|
+
severity: 'warning',
|
|
61281
|
+
message: 'A * that does not follow a . is dropped (aa* means aa). Write .* for "anything".',
|
|
61282
|
+
span: at(s.bareStars[0], 1),
|
|
61283
|
+
suggestion,
|
|
61284
|
+
});
|
|
61285
|
+
}
|
|
61286
|
+
const segments = topLevelSegments(pattern, s.topLevelPipes);
|
|
61287
|
+
const first = segments[0] ?? '';
|
|
61288
|
+
if (segments.length > 4 && first && segments.slice(1).some((seg) => seg.toLowerCase() === first.toLowerCase())) {
|
|
61289
|
+
hints.push({
|
|
61290
|
+
ruleId: 'top-level-alternation',
|
|
61291
|
+
severity: 'warning',
|
|
61292
|
+
message: 'A | outside parentheses is a literal pipe, so these joined names form one long name. Alternate inside one segment, e.g. SuperDomain|(host-a|host-b)|…, or write two rules.',
|
|
61293
|
+
span: at(s.topLevelPipes[3] ?? 0, 1),
|
|
61294
|
+
});
|
|
61295
|
+
}
|
|
61296
|
+
const hasRegex = /[.[\]^$\\(]/.test(pattern);
|
|
61297
|
+
if (!hasRegex && segments.length < 4) {
|
|
61298
|
+
hints.push({
|
|
61299
|
+
ruleId: 'bare-substring',
|
|
61300
|
+
severity: 'warning',
|
|
61301
|
+
message: 'Matching is full-string: a fragment of a source name matches nothing.',
|
|
61302
|
+
span: { start: 0, end: pattern.length },
|
|
61303
|
+
suggestion: /^superdomain\|/i.test(pattern) ? `${pattern}|.*` : `.*${pattern}.*`,
|
|
61304
|
+
});
|
|
61305
|
+
}
|
|
61306
|
+
if (pipeGroupRanges(pattern).length > 0) {
|
|
61307
|
+
hints.push({
|
|
61308
|
+
ruleId: 'parens-pipe-trap',
|
|
61309
|
+
severity: 'info',
|
|
61310
|
+
message: '(x|y) is alternation — and those parentheses no longer match literal parentheses in a name ("Tomcat (Prod|Dev)" does not match "Tomcat (Prod)").',
|
|
61311
|
+
span: at(pipeGroupRanges(pattern)[0][0], 1),
|
|
61312
|
+
});
|
|
61313
|
+
}
|
|
61314
|
+
if (s.literalParens.length > 0) {
|
|
61315
|
+
hints.push({
|
|
61316
|
+
ruleId: 'literal-parens',
|
|
61317
|
+
severity: 'info',
|
|
61318
|
+
message: 'Parentheses without a | inside are literal characters; regex inside them is not honoured.',
|
|
61319
|
+
span: at(s.literalParens[0], 1),
|
|
61320
|
+
});
|
|
61321
|
+
}
|
|
61322
|
+
if (s.upperOrLowerClass.length > 0) {
|
|
61323
|
+
hints.push({
|
|
61324
|
+
ruleId: 'case-insensitive',
|
|
61325
|
+
severity: 'info',
|
|
61326
|
+
message: 'Matching ignores case: [A-Z] and [a-z] both match either case.',
|
|
61327
|
+
span: at(s.upperOrLowerClass[0], 1),
|
|
61328
|
+
});
|
|
61329
|
+
}
|
|
61330
|
+
if (s.propertyInsideClass.length > 0) {
|
|
61331
|
+
hints.push({
|
|
61332
|
+
ruleId: 'unicode-property',
|
|
61333
|
+
severity: 'info',
|
|
61334
|
+
message: 'The server honours [\\pL]-style classes; the local simulation cannot, so trust the server preview for this rule.',
|
|
61335
|
+
span: at(s.propertyInsideClass[0], 3),
|
|
61336
|
+
});
|
|
61337
|
+
}
|
|
61338
|
+
return hints.sort((a, b) => SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity] ||
|
|
61339
|
+
(a.span?.start ?? -1) - (b.span?.start ?? -1));
|
|
61340
|
+
}
|
|
61341
|
+
|
|
60170
61342
|
exports.LogIngest = void 0;
|
|
60171
61343
|
(function (LogIngest) {
|
|
60172
61344
|
/**
|
|
@@ -87358,6 +88530,8 @@ exports.ItsmChannelSchema = ItsmChannelSchema;
|
|
|
87358
88530
|
exports.ItsmPropertySchema = ItsmPropertySchema;
|
|
87359
88531
|
exports.ItsmTestConnectionRequestSchema = ItsmTestConnectionRequestSchema;
|
|
87360
88532
|
exports.ItsmTestConnectionResponseSchema = ItsmTestConnectionResponseSchema;
|
|
88533
|
+
exports.JEXL_CONTEXT_CATALOG = JEXL_CONTEXT_CATALOG;
|
|
88534
|
+
exports.JEXL_SAMPLE_CONTEXT = JEXL_SAMPLE_CONTEXT;
|
|
87361
88535
|
exports.JavaRegexError = JavaRegexError;
|
|
87362
88536
|
exports.JexlEvalError = JexlEvalError;
|
|
87363
88537
|
exports.JexlSyntaxError = JexlSyntaxError;
|
|
@@ -87462,6 +88636,7 @@ exports.RevokeTokensResponseSchema = RevokeTokensResponseSchema;
|
|
|
87462
88636
|
exports.SLIService = SLIService;
|
|
87463
88637
|
exports.SLI_DERIVED_METRIC_SOURCE = SLI_DERIVED_METRIC_SOURCE;
|
|
87464
88638
|
exports.SMTP_DEFAULT_TEMPLATES = SMTP_DEFAULT_TEMPLATES;
|
|
88639
|
+
exports.SOURCENAME_DIALECT_CATALOG = SOURCENAME_DIALECT_CATALOG;
|
|
87465
88640
|
exports.SQLService = SQLService;
|
|
87466
88641
|
exports.ServiceDeskFieldSchema = ServiceDeskFieldSchema;
|
|
87467
88642
|
exports.ServiceDeskFieldsResponseSchema = ServiceDeskFieldsResponseSchema;
|
|
@@ -87537,6 +88712,8 @@ exports.StoredCriteriaSchema = StoredCriteriaSchema;
|
|
|
87537
88712
|
exports.TAGS_ATTRIBUTE_KEY = TAGS_ATTRIBUTE_KEY;
|
|
87538
88713
|
exports.TASService = TASService;
|
|
87539
88714
|
exports.TC_METRIC_CAP = TC_METRIC_CAP;
|
|
88715
|
+
exports.TC_RESERVED_CUSTOM_ATTRIBUTE_KEYS = TC_RESERVED_CUSTOM_ATTRIBUTE_KEYS;
|
|
88716
|
+
exports.TC_STANDARD_ATTRIBUTE_KEYS = TC_STANDARD_ATTRIBUTE_KEYS;
|
|
87540
88717
|
exports.TICKET_ENRICHMENT_ALARM_TYPES = TICKET_ENRICHMENT_ALARM_TYPES;
|
|
87541
88718
|
exports.TICKET_ENRICHMENT_FIELD_CODES = TICKET_ENRICHMENT_FIELD_CODES;
|
|
87542
88719
|
exports.TasAddFlowsFilterSchema = TasAddFlowsFilterSchema;
|
|
@@ -87714,6 +88891,7 @@ exports.apiTokenList = apiTokenList;
|
|
|
87714
88891
|
exports.apiTokenUpdate = apiTokenUpdate;
|
|
87715
88892
|
exports.appendSli = appendSli;
|
|
87716
88893
|
exports.appendSloTriplet = appendSloTriplet;
|
|
88894
|
+
exports.attributeFilterTargets = attributeFilterTargets;
|
|
87717
88895
|
exports.authHeaderValue = authHeaderValue;
|
|
87718
88896
|
exports.buildAlarmFilterUpdateBody = buildAlarmFilterUpdateBody;
|
|
87719
88897
|
exports.buildAlarmQueueFilterExpression = buildAlarmQueueFilterExpression;
|
|
@@ -87733,6 +88911,7 @@ exports.capVertexDetail = capVertexDetail;
|
|
|
87733
88911
|
exports.checkGet = checkGet;
|
|
87734
88912
|
exports.chunkPayloads = chunkPayloads;
|
|
87735
88913
|
exports.classifyIngestionError = classifyIngestionError;
|
|
88914
|
+
exports.compileTcSourceName = compileTcSourceName;
|
|
87736
88915
|
exports.composeMetricTypeBits = composeMetricTypeBits;
|
|
87737
88916
|
exports.contactActivate = contactActivate;
|
|
87738
88917
|
exports.contactDelete = contactDelete;
|
|
@@ -87751,6 +88930,7 @@ exports.createCurlCommand = createCurlCommand;
|
|
|
87751
88930
|
exports.createCurlScript = createCurlScript;
|
|
87752
88931
|
exports.createPostmanRequest = createPostmanRequest;
|
|
87753
88932
|
exports.createServiceMonolith = createServiceMonolith;
|
|
88933
|
+
exports.customAttributeKeyIssues = customAttributeKeyIssues;
|
|
87754
88934
|
exports.decodeMetricTypeBits = decodeMetricTypeBits;
|
|
87755
88935
|
exports.defaultItsmPropertyList = defaultItsmPropertyList;
|
|
87756
88936
|
exports.defaultRuleName = defaultRuleName;
|
|
@@ -87812,6 +88992,7 @@ exports.isProductProvisioned = isProductProvisioned;
|
|
|
87812
88992
|
exports.isTemplate = isTemplate;
|
|
87813
88993
|
exports.isTenantToken = isTenantToken;
|
|
87814
88994
|
exports.isUserToken = isUserToken;
|
|
88995
|
+
exports.isWildcardOnlySourceName = isWildcardOnlySourceName;
|
|
87815
88996
|
exports.itsmMapToProperties = itsmMapToProperties;
|
|
87816
88997
|
exports.itsmPropertiesToMap = itsmPropertiesToMap;
|
|
87817
88998
|
exports.javaFullMatch = javaFullMatch;
|
|
@@ -87819,6 +89000,7 @@ exports.javaRegexToJs = javaRegexToJs;
|
|
|
87819
89000
|
exports.javaReplaceAll = javaReplaceAll;
|
|
87820
89001
|
exports.javaReplaceFirst = javaReplaceFirst;
|
|
87821
89002
|
exports.javaSplit = javaSplit;
|
|
89003
|
+
exports.lintSourceName = lintSourceName;
|
|
87822
89004
|
exports.listDataStoreSchemaOps = listDataStoreSchemaOps;
|
|
87823
89005
|
exports.listSlis = listSlis;
|
|
87824
89006
|
exports.locationsCreate = locationsCreate;
|
|
@@ -87870,9 +89052,11 @@ exports.oauthTokenCognateDeleteCurrent = oauthTokenCognateDeleteCurrent;
|
|
|
87870
89052
|
exports.oauthTokenDelete = oauthTokenDelete;
|
|
87871
89053
|
exports.oauthTokenDeleteCurrent = oauthTokenDeleteCurrent;
|
|
87872
89054
|
exports.parseExpression = parseExpression;
|
|
89055
|
+
exports.parseExternalIdFormat = parseExternalIdFormat;
|
|
87873
89056
|
exports.parseFilter = parseFilter;
|
|
87874
89057
|
exports.parseSaasGateway = parseSaasGateway;
|
|
87875
89058
|
exports.parseServiceNowUrl = parseServiceNowUrl;
|
|
89059
|
+
exports.pipeGroupRanges = pipeGroupRanges;
|
|
87876
89060
|
exports.planEnrichmentReorder = planEnrichmentReorder;
|
|
87877
89061
|
exports.policyCategoryGuard = policyCategoryGuard;
|
|
87878
89062
|
exports.policyFieldBounds = policyFieldBounds;
|
|
@@ -87900,8 +89084,11 @@ exports.sleep = sleep;
|
|
|
87900
89084
|
exports.sliHumanName = sliHumanName;
|
|
87901
89085
|
exports.sloTripletFor = sloTripletFor;
|
|
87902
89086
|
exports.sortRulesByPriority = sortRulesByPriority;
|
|
89087
|
+
exports.sourceNameBattery = sourceNameBattery;
|
|
89088
|
+
exports.sourceNameMatrix = sourceNameMatrix;
|
|
87903
89089
|
exports.splitAttributePath = splitAttributePath;
|
|
87904
89090
|
exports.splitTemplate = splitTemplate;
|
|
89091
|
+
exports.standardVertexAttributes = standardVertexAttributes;
|
|
87905
89092
|
exports.stationDelete = stationDelete;
|
|
87906
89093
|
exports.stationsAgentType = stationsAgentType;
|
|
87907
89094
|
exports.stationsCreate = stationsCreate;
|
|
@@ -87919,6 +89106,7 @@ exports.statistic = statistic;
|
|
|
87919
89106
|
exports.summarizeDataStoreSchema = summarizeDataStoreSchema;
|
|
87920
89107
|
exports.tagsGetAll = tagsGetAll;
|
|
87921
89108
|
exports.tcSourceNameMatches = tcSourceNameMatches;
|
|
89109
|
+
exports.tcSourceNameToJavaRegex = tcSourceNameToJavaRegex;
|
|
87922
89110
|
exports.tcSourceNameToMmPattern = tcSourceNameToMmPattern;
|
|
87923
89111
|
exports.templateUsage = templateUsage;
|
|
87924
89112
|
exports.tenantConfigAttribute = tenantConfigAttribute;
|