mirror of
https://github.com/google/santa.git
synced 2026-04-24 03:00:12 -04:00
Log type metrics (#1018)
* Add event log type to metrics * lint * PR Feedback
This commit is contained in:
@@ -47,6 +47,29 @@ static void RegisterModeMetric(SNTMetricSet *metricSet) {
|
||||
}];
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the event log type metric checking the config before reporting the status.
|
||||
*/
|
||||
static void RegisterEventLogType(SNTMetricSet *metricSet) {
|
||||
SNTMetricStringGauge *logType = [metricSet stringGaugeWithName:@"/santa/log_type"
|
||||
fieldNames:@[]
|
||||
helpText:@"Santa's log type"];
|
||||
|
||||
// create a callback that gets the current log type
|
||||
[metricSet registerCallback:^{
|
||||
switch ([[SNTConfigurator configurator] eventLogType]) {
|
||||
case SNTEventLogTypeProtobuf: [logType set:@"protobuf" forFieldValues:@[]]; break;
|
||||
case SNTEventLogTypeSyslog: [logType set:@"syslog" forFieldValues:@[]]; break;
|
||||
case SNTEventLogTypeNull: [logType set:@"null" forFieldValues:@[]]; break;
|
||||
case SNTEventLogTypeFilelog: [logType set:@"file" forFieldValues:@[]]; break;
|
||||
default:
|
||||
// Should never be reached.
|
||||
[logType set:@"unknown" forFieldValues:@[]];
|
||||
break;
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
/**
|
||||
* Register metrics for measuring memory usage.
|
||||
*/
|
||||
@@ -129,6 +152,7 @@ static void RegisterCommonSantaMetrics(SNTMetricSet *metricSet) {
|
||||
value:[SNTSystemInfo osVersion]];
|
||||
|
||||
RegisterModeMetric(metricSet);
|
||||
RegisterEventLogType(metricSet);
|
||||
// TODO(markowsky) Register CSR status
|
||||
// TODO(markowsky) Register system extension status
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
- (void)testRegisteringCoreMetrics {
|
||||
OCMStub([self.mockConfigurator extraMetricLabels]).andReturn(self.extraMetricLabels);
|
||||
OCMStub([self.mockConfigurator clientMode]).andReturn(SNTClientModeLockdown);
|
||||
OCMStub([self.mockConfigurator eventLogType]).andReturn(SNTEventLogTypeProtobuf);
|
||||
|
||||
SNTRegisterCoreMetrics();
|
||||
|
||||
@@ -191,6 +192,18 @@
|
||||
} ],
|
||||
},
|
||||
},
|
||||
@"/santa/log_type" : @{
|
||||
@"description" : @"Santa's log type",
|
||||
@"type" : @6,
|
||||
@"fields" : @{
|
||||
@"" : @[ @{
|
||||
@"created" : fixedDate,
|
||||
@"data" : @"protobuf",
|
||||
@"last_updated" : fixedDate,
|
||||
@"value" : @""
|
||||
} ],
|
||||
},
|
||||
},
|
||||
},
|
||||
@"root_labels" : @{
|
||||
@"host_name" : hostname,
|
||||
|
||||
Reference in New Issue
Block a user