Skip to content

Commit

Permalink
Update win mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
v-zhuravlev committed Nov 6, 2024
1 parent f0fd592 commit 55ffc29
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 62 deletions.
9 changes: 3 additions & 6 deletions windows-active-directory-mixin/mixin.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ local alerts = import './alerts/alerts.libsonnet';
local g = import './g.libsonnet';
local var = g.dashboard.variable;
local activedirectorymixin =
windowsobservlib.new(
filteringSelector='job=~"integrations/windows_exporter"',
uid='active-directory',
groupLabels=['job'],
instanceLabels=['instance'],
)
windowsobservlib.new()

{
config+: {
enableADDashboard: true,
groupLabels: ['job'],
uid: 'active-directory',
},
}

Expand Down
6 changes: 1 addition & 5 deletions windows-mixin/mixin.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ local winlib = import 'windows-observ-lib/main.libsonnet';
local config = (import 'config.libsonnet')._config;
{
local windows =
winlib.new(
dashboardNamePrefix=config.dashboardNamePrefix,
uid=config.uid,
filteringSelector=config.filteringSelector,
)
winlib.new()
+
{
config+: config,
Expand Down
42 changes: 42 additions & 0 deletions windows-observ-lib/config.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
// any modular library should include as inputs:
// 'dashboardNamePrefix' - Use as prefix for all Dashboards and (optional) rule groups
// 'filteringSelector' - Static selector to apply to ALL dashboard variables of type query, panel queries, alerts and recording rules.
// 'groupLabels' - one or more labels that can be used to identify 'group' of instances. In simple cases, can be 'job' or 'cluster'.
// 'instanceLabels' - one or more labels that can be used to identify single entity of instances. In simple cases, can be 'instance' or 'pod'.
// 'uid' - UID to prefix all dashboards original uids
groupLabels: ['job'],
instanceLabels: ['instance'],
filteringSelector: 'job=~".*windows.*"',
dashboardTags: ['windows'],
uid: 'windows',
dashboardNamePrefix: '',

// optional
ignoreVolumes: 'HarddiskVolume.*',
alertsCPUThresholdWarning: '90',
alertMemoryUsageThresholdCritical: '90',
alertDiskUsageThresholdCritical: '90',
dashboardPeriod: 'now-1h',
dashboardTimezone: 'default',
dashboardRefresh: '1m',

// optional Windows AD
alertsHighPendingReplicationOperations: 50, // count
alertsHighReplicationSyncRequestFailures: 0, // count
alertsHighPasswordChanges: 25, // count
alertsMetricsDownJobName: 'integrations/windows_exporter',
enableADDashboard: false,

// logs lib related
enableLokiLogs: true,
extraLogLabels: ['channel', 'source', 'keywords', 'level'],
logsVolumeGroupBy: 'level',
showLogsVolume: true,
logsExtraFilters:
|||
| label_format timestamp="{{__timestamp__}}"
| drop channel_extracted,source_extracted,computer_extracted,level_extracted,keywords_extracted
| line_format `{{ if eq "[[instance]]" ".*" }}{{ alignLeft 25 .instance}}|{{end}}{{alignLeft 12 .channel }}| {{ alignLeft 25 .source}}| {{ .message }}`
|||,
}
58 changes: 7 additions & 51 deletions windows-observ-lib/main.libsonnet
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local alerts = import './alerts.libsonnet';
local config = import './config.libsonnet';
local dashboards = import './dashboards.libsonnet';
local datasources = import './datasources.libsonnet';
local g = import './g.libsonnet';
Expand All @@ -7,58 +8,10 @@ local targets = import './targets.libsonnet';
local commonlib = import 'common-lib/common/main.libsonnet';

{
new(
filteringSelector,
groupLabels=['job'],
instanceLabels=['instance'],
dashboardNamePrefix='',
dashboardTags=[uid],
uid,
): {
new(): {

local this = self,
config: {
// any modular library should include as inputs:
// 'dashboardNamePrefix' - Use as prefix for all Dashboards and (optional) rule groups
// 'filteringSelector' - Static selector to apply to ALL dashboard variables of type query, panel queries, alerts and recording rules.
// 'groupLabels' - one or more labels that can be used to identify 'group' of instances. In simple cases, can be 'job' or 'cluster'.
// 'instanceLabels' - one or more labels that can be used to identify single entity of instances. In simple cases, can be 'instance' or 'pod'.
// 'uid' - UID to prefix all dashboards original uids
groupLabels: groupLabels,
instanceLabels: instanceLabels,
filteringSelector: filteringSelector,
dashboardTags: dashboardTags,
uid: uid,
dashboardNamePrefix: dashboardNamePrefix,

// optional
ignoreVolumes: 'HarddiskVolume.*',
alertsCPUThresholdWarning: '90',
alertMemoryUsageThresholdCritical: '90',
alertDiskUsageThresholdCritical: '90',
dashboardPeriod: 'now-1h',
dashboardTimezone: 'default',
dashboardRefresh: '1m',

// optional Windows AD
alertsHighPendingReplicationOperations: 50, // count
alertsHighReplicationSyncRequestFailures: 0, // count
alertsHighPasswordChanges: 25, // count
alertsMetricsDownJobName: 'integrations/windows_exporter',
enableADDashboard: false,

// logs lib related
enableLokiLogs: true,
extraLogLabels: ['channel', 'source', 'keywords', 'level'],
logsVolumeGroupBy: 'level',
showLogsVolume: true,
logsExtraFilters:
|||
| label_format timestamp="{{__timestamp__}}"
| drop channel_extracted,source_extracted,computer_extracted,level_extracted,keywords_extracted
| line_format `{{ if eq "[[instance]]" ".*" }}{{ alignLeft 25 .instance}}|{{end}}{{alignLeft 12 .channel }}| {{ alignLeft 25 .source}}| {{ .message }}`
|||,
},
config: config,
grafana: {
variables: commonlib.variables.new(
filteringSelector=this.config.filteringSelector,
Expand All @@ -74,7 +27,7 @@ local commonlib = import 'common-lib/common/main.libsonnet';
reboot: commonlib.annotations.reboot.new(
title='Reboot',
target=this.grafana.targets.reboot,
instanceLabels=std.join(',', instanceLabels),
instanceLabels=std.join(',', this.config.instanceLabels),
)
+ commonlib.annotations.base.withTagKeys(std.join(',', this.config.groupLabels + this.config.instanceLabels)),
}
Expand Down Expand Up @@ -124,5 +77,8 @@ local commonlib = import 'common-lib/common/main.libsonnet';
},

},
withConfigMixin(config): {
config+: config,
},

}
10 changes: 10 additions & 0 deletions windows-observ-lib/mixin.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
local windowslib = import './main.libsonnet';
{
_config:: {},
_windowsib::
windowslib.new()
+ windowslib.withConfigMixin(self._config),
grafanaDashboards+:: self._windowsib.grafana.dashboards,
prometheusAlerts+:: self._windowsib.prometheus.alerts,
prometheusRules+:: self._windowsib.prometheus.recordingRules,
}

0 comments on commit 55ffc29

Please sign in to comment.