Files
windows_exporter/contrib/mixin/dashboards/variables.libsonnet
T
2026-10-10 16:10:55 +02:00

130 lines
5.3 KiB
Jsonnet

local b = import 'builders.libsonnet';
local variables = b.dashboard.spec.variables;
local query = variables.QueryVariableKind;
local datasource = variables.DatasourceVariableKind;
local common = query.withKind()
+ query.spec.withAllowCustomValue(true)
+ query.spec.withCurrent({ text: '', value: '' })
+ query.spec.withHide('dontHide')
+ query.spec.withIncludeAll(false)
+ query.spec.withMulti(false)
+ query.spec.withOptions([])
+ query.spec.withRefresh('onTimeRangeChanged')
+ query.spec.withRegex('')
+ query.spec.withSkipUrlSync(false)
+ query.spec.withSort('alphabeticalAsc');
local new(name, definition) = common
+ query.spec.withName(name)
+ query.spec.withDefinition(definition)
+ query.spec.withQuery(b.dataQuery({
qryType: 1,
query: definition,
refId: 'PrometheusVariableQueryEditor-VariableQuery',
}));
// Variables of disabled collectors are left out.
function(on) [variable for variable in [
datasource.withKind()
+ datasource.spec.withAllowCustomValue(true)
+ datasource.spec.withCurrent({
text: '',
value: '',
})
+ datasource.spec.withHide('dontHide')
+ datasource.spec.withIncludeAll(false)
+ datasource.spec.withLabel('Data source')
+ datasource.spec.withMulti(false)
+ datasource.spec.withName('datasource')
+ datasource.spec.withOptions([])
+ datasource.spec.withPluginId('prometheus')
+ datasource.spec.withRefresh('onDashboardLoad')
+ datasource.spec.withRegex('')
+ datasource.spec.withSkipUrlSync(false)
,
new('job', 'label_values(windows_os_hostname, job)')
+ query.spec.withCurrent({
text: [
'All',
],
value: [
'$__all',
],
})
+ query.spec.withIncludeAll(true)
+ query.spec.withLabel('Job')
+ query.spec.withMulti(true)
,
new('hostname', 'label_values(windows_os_hostname{job=~"$job"}, hostname)')
+ query.spec.withCurrent({
text: [
'All',
],
value: [
'$__all',
],
})
+ query.spec.withIncludeAll(true)
+ query.spec.withLabel('Hostname')
+ query.spec.withMulti(true)
,
new('instance', 'label_values(windows_os_hostname{job=~"$job", hostname=~"$hostname"}, instance)')
+ query.spec.withLabel('Instance')
,
new('show_hostname', 'label_values(windows_os_hostname{job=~"$job", instance="$instance"}, hostname)')
+ query.spec.withHide('hideVariable')
,
if on('logical_disk') then new('volume', 'label_values(windows_logical_disk_size_bytes{job=~"$job", instance="$instance"}, volume)')
+ query.spec.withCurrent({
text: [
'All',
],
value: [
'$__all',
],
})
+ query.spec.withIncludeAll(true)
+ query.spec.withLabel('Volume')
+ query.spec.withMulti(true)
+ query.spec.withRegex('/^(?!HarddiskVolume).+$/')
,
if on('net') then new('nic', 'label_values(windows_net_bytes_total{job=~"$job", instance="$instance"}, nic)')
+ query.spec.withCurrent({
text: [
'All',
],
value: [
'$__all',
],
})
+ query.spec.withIncludeAll(true)
+ query.spec.withLabel('Network interface')
+ query.spec.withMulti(true)
+ query.spec.withRegex('/^(?!isatap|Teredo|6to4).+$/'),
if on('process') then new('process', 'label_values(windows_process_info{job=~"$job", instance="$instance", process_id!="0"}, process)')
+ query.spec.withCurrent({
text: [
'All',
],
value: [
'$__all',
],
})
+ query.spec.withIncludeAll(true)
+ query.spec.withLabel('Process')
+ query.spec.withMulti(true),
if on('process') then variables.CustomVariableKind.withKind()
+ variables.CustomVariableKind.withSpec({
name: 'process_top',
label: 'Top N processes',
description: 'Maximum number of processes per graph. Summary counters include all selected processes.',
query: '5,10,20',
current: { text: '10', value: '10' },
options: [{ text: value, value: value, selected: value == '10' } for value in ['5', '10', '20']],
multi: false,
includeAll: false,
allowCustomValue: false,
hide: 'dontHide',
skipUrlSync: false,
}),
] if variable != null]