diff --git a/dashboards/resources/variables/cluster.libsonnet b/dashboards/resources/variables/cluster.libsonnet index d2126c844..43fe42156 100644 --- a/dashboards/resources/variables/cluster.libsonnet +++ b/dashboards/resources/variables/cluster.libsonnet @@ -5,6 +5,6 @@ local common = import './common.libsonnet'; local datasource = common.datasource(config); { datasource: datasource, - cluster: common.cluster(config, datasource, 'up{%(cadvisorSelector)s}'), + cluster: common.cluster(config, datasource), }, } diff --git a/dashboards/resources/variables/common.libsonnet b/dashboards/resources/variables/common.libsonnet index 4926fd9e2..b1b73ad2e 100644 --- a/dashboards/resources/variables/common.libsonnet +++ b/dashboards/resources/variables/common.libsonnet @@ -15,20 +15,16 @@ local var = g.dashboard.variable; }, }, - cluster(config, datasourceVar, selectorTemplate):: + cluster(config, datasourceVar):: var.query.new('cluster') + var.query.withDatasourceFromVariable(datasourceVar) + var.query.queryTypes.withLabelValues( config.clusterLabel, - selectorTemplate % config, + 'up{%(kubeStateMetricsSelector)s}' % config, ) + var.query.generalOptions.withLabel('cluster') + var.query.refresh.onTime() - + ( - if config.showMultiCluster - then var.query.generalOptions.showOnDashboard.withLabelAndValue() - else var.query.generalOptions.showOnDashboard.withNothing() - ) + + var.query.generalOptions.showOnDashboard.withLabelAndValue() + var.query.withSort(type='alphabetical'), namespace(config, datasourceVar):: diff --git a/dashboards/resources/variables/namespace.libsonnet b/dashboards/resources/variables/namespace.libsonnet index 091173361..c523666f6 100644 --- a/dashboards/resources/variables/namespace.libsonnet +++ b/dashboards/resources/variables/namespace.libsonnet @@ -3,7 +3,7 @@ local common = import './common.libsonnet'; { namespace(config):: local datasource = common.datasource(config); - local clusterVar = common.cluster(config, datasource, 'up{%(kubeStateMetricsSelector)s}'); + local clusterVar = common.cluster(config, datasource); { datasource: datasource, cluster: clusterVar, diff --git a/dashboards/resources/variables/pod.libsonnet b/dashboards/resources/variables/pod.libsonnet index 37f7204bd..33baaa2e4 100644 --- a/dashboards/resources/variables/pod.libsonnet +++ b/dashboards/resources/variables/pod.libsonnet @@ -3,7 +3,7 @@ local common = import './common.libsonnet'; { pod(config):: local datasource = common.datasource(config); - local clusterVar = common.cluster(config, datasource, 'up{%(kubeStateMetricsSelector)s}'); + local clusterVar = common.cluster(config, datasource); { datasource: datasource, cluster: clusterVar,