Skip to content

Commit 93569d9

Browse files
authored
Issue SchemaStore#5403: Update MetricsHub connector json schema (SchemaStore#5404)
- Included FileSource and EventLogSource in both metricshub.json and metricshub-connector.json. - Added tests for both cases. - Tested.
1 parent 292bebf commit 93569d9

4 files changed

Lines changed: 205 additions & 0 deletions

File tree

src/schemas/json/metricshub-connector.json

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,105 @@
554554
"$ref": "#/definitions/resultContent"
555555
}
556556
}
557+
},
558+
{
559+
"properties": {
560+
"type": {
561+
"type": "string",
562+
"const": "eventLog"
563+
},
564+
"forceSerialization": {
565+
"type": "boolean"
566+
},
567+
"computes": {
568+
"$ref": "#/definitions/computes"
569+
},
570+
"executeForEachEntryOf": {
571+
"$ref": "#/definitions/executeForEachEntryOf"
572+
},
573+
"logName": {
574+
"type": "string",
575+
"description": "Windows Event Log name"
576+
},
577+
"eventIds": {
578+
"type": "array",
579+
"description": "List of event IDs to filter",
580+
"items": {
581+
"type": "string"
582+
}
583+
},
584+
"sources": {
585+
"type": "array",
586+
"description": "List of event sources to filter",
587+
"items": {
588+
"type": "string"
589+
}
590+
},
591+
"levels": {
592+
"type": "array",
593+
"description": "List of event log levels to filter. Accepts level names (e.g., 'error', 'warn', 'info', 'success', 'failure') or numeric codes (1-5).",
594+
"items": {
595+
"oneOf": [
596+
{
597+
"type": "string"
598+
},
599+
{
600+
"type": "integer",
601+
"minimum": 1,
602+
"maximum": 5
603+
}
604+
]
605+
}
606+
},
607+
"maxEventsPerPoll": {
608+
"type": "integer",
609+
"description": "Maximum number of events to retrieve per poll (default: 50, -1 for unlimited)",
610+
"default": 50
611+
}
612+
}
613+
},
614+
{
615+
"properties": {
616+
"type": {
617+
"type": "string",
618+
"const": "file"
619+
},
620+
"forceSerialization": {
621+
"type": "boolean"
622+
},
623+
"computes": {
624+
"$ref": "#/definitions/computes"
625+
},
626+
"executeForEachEntryOf": {
627+
"$ref": "#/definitions/executeForEachEntryOf"
628+
},
629+
"paths": {
630+
"type": "array",
631+
"description": "File path patterns to read (e.g., C:\\logs\\*.log, /var/log/app/*.log). Supports wildcards.",
632+
"items": {
633+
"type": "string"
634+
}
635+
},
636+
"maxSizePerPoll": {
637+
"oneOf": [
638+
{
639+
"type": "integer",
640+
"description": "Maximum number of bytes to read per polling cycle across all files (LOG mode). Use -1 for no limit. Default is 5 MB (5242880 bytes)."
641+
},
642+
{
643+
"type": "string",
644+
"description": "Maximum size per poll as a string (e.g., '5Mb', '10MB'). Supports size units."
645+
}
646+
],
647+
"default": 5242880
648+
},
649+
"mode": {
650+
"type": "string",
651+
"description": "Processing mode: LOG for incremental reading with cursors, or FLAT for full-file read on each poll (default: LOG).",
652+
"enum": ["LOG", "FLAT"],
653+
"default": "LOG"
654+
}
655+
}
557656
}
558657
]
559658
}

src/schemas/json/metricshub.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,49 @@
13001300
"default": 50
13011301
}
13021302
}
1303+
},
1304+
{
1305+
"properties": {
1306+
"type": {
1307+
"type": "string",
1308+
"const": "file"
1309+
},
1310+
"forceSerialization": {
1311+
"type": "boolean"
1312+
},
1313+
"computes": {
1314+
"$ref": "#/definitions/computes"
1315+
},
1316+
"executeForEachEntryOf": {
1317+
"$ref": "#/definitions/executeForEachEntryOf"
1318+
},
1319+
"paths": {
1320+
"type": "array",
1321+
"description": "File path patterns to read (e.g., C:\\logs\\*.log, /var/log/app/*.log). Supports wildcards.",
1322+
"items": {
1323+
"type": "string"
1324+
}
1325+
},
1326+
"maxSizePerPoll": {
1327+
"oneOf": [
1328+
{
1329+
"type": "integer",
1330+
"description": "Maximum number of bytes to read per polling cycle across all files (LOG mode). Use -1 for no limit. Default is 5 MB (5242880 bytes)."
1331+
},
1332+
{
1333+
"type": "string",
1334+
"description": "Maximum size per poll as a string (e.g., '5Mb', '10MB'). Supports size units."
1335+
}
1336+
],
1337+
"default": 5242880
1338+
},
1339+
"mode": {
1340+
"type": "string",
1341+
"description": "Processing mode: LOG for incremental reading with cursors, or FLAT for full-file read on each poll (default: LOG).",
1342+
"enum": ["LOG", "FLAT"],
1343+
"default": "LOG"
1344+
}
1345+
}
13031346
}
13041347
]
13051348
}

src/test/metricshub-connector/metricshub-connector.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,3 +802,47 @@ monitors:
802802
hw.status{hw.type="battery"}: $7
803803
legacyTextParameters:
804804
StatusInformation: $8
805+
event_log:
806+
simple:
807+
sources:
808+
systemEvents:
809+
type: eventLog
810+
logName: System
811+
eventIds: ['1001', '1002', '6008']
812+
sources: ['Microsoft-Windows-Kernel-General', 'EventLog']
813+
levels: [error, warning, 1, 2]
814+
maxEventsPerPoll: 100
815+
applicationEvents:
816+
type: eventLog
817+
logName: Application
818+
eventIds:
819+
- '1001'
820+
- '1002'
821+
levels:
822+
- information
823+
- warning
824+
- error
825+
maxEventsPerPoll: 50
826+
mapping:
827+
source: ${source::systemEvents}
828+
metrics:
829+
windows.event.count: $1
830+
file_log:
831+
simple:
832+
sources:
833+
logFileReader:
834+
type: file
835+
paths: ['C:\\logs\\*.log', '/var/log/app/*.log']
836+
mode: LOG
837+
maxSizePerPoll: 10485760
838+
flatFileReader:
839+
type: file
840+
paths:
841+
- '/var/log/system.log'
842+
- '/var/log/application.log'
843+
mode: FLAT
844+
maxSizePerPoll: '5Mb'
845+
mapping:
846+
source: ${source::logFileReader}
847+
metrics:
848+
log.lines.count: $1

src/test/metricshub/metricshub.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,3 +623,22 @@ resourceGroups:
623623
source: ${source::monitors.windowsEventLog.collect.sources.systemEvents}
624624
metrics:
625625
windows.event.count: $1
626+
fileLogMonitor:
627+
collect:
628+
sources:
629+
logFileReader:
630+
type: file
631+
paths: ['C:\\logs\\*.log', '/var/log/app/*.log'] # File path patterns with wildcards
632+
mode: LOG # LOG for incremental reading, FLAT for full-file read
633+
maxSizePerPoll: 10485760 # 10 MB per poll (can also use string like '10Mb')
634+
flatFileReader:
635+
type: file
636+
paths:
637+
- '/var/log/system.log'
638+
- '/var/log/application.log'
639+
mode: FLAT # Full-file read on each poll
640+
maxSizePerPoll: '5Mb' # String format with size unit
641+
mapping:
642+
source: ${source::monitors.fileLogMonitor.collect.sources.logFileReader}
643+
metrics:
644+
log.lines.count: $1

0 commit comments

Comments
 (0)