Skip to content

Commit

Permalink
Performance / custom dashboards: new configs (#3668) (#3670)
Browse files Browse the repository at this point in the history
- discovery_enabled (true/false/auto) to switch discovery mode
- discovery_auto_threshold: pods threshold above which discovery is
  skipped in auto mode

Part of #3660
  • Loading branch information
jotak committed Feb 4, 2021
1 parent e91c6a6 commit be93b82
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
19 changes: 12 additions & 7 deletions business/dashboards.go
Expand Up @@ -569,14 +569,19 @@ func (in *DashboardsService) GetCustomDashboardRefs(namespace, app, version stri

if len(runtimes) == 0 {
cfg := config.Get()
filters := make(map[string]string)
if app != "" {
filters[cfg.IstioLabels.AppLabelName] = app
}
if version != "" {
filters[cfg.IstioLabels.VersionLabelName] = version
discoveryEnabled := cfg.ExternalServices.CustomDashboards.DiscoveryEnabled
if discoveryEnabled == config.DashboardsDiscoveryEnabled ||
(discoveryEnabled == config.DashboardsDiscoveryAuto &&
len(pods) <= cfg.ExternalServices.CustomDashboards.DiscoveryAutoThreshold) {
filters := make(map[string]string)
if app != "" {
filters[cfg.IstioLabels.AppLabelName] = app
}
if version != "" {
filters[cfg.IstioLabels.VersionLabelName] = version
}
runtimes = in.discoverDashboards(namespace, filters)
}
runtimes = in.discoverDashboards(namespace, filters)
}
return runtimes
}
Expand Down
22 changes: 16 additions & 6 deletions config/config.go
Expand Up @@ -59,6 +59,12 @@ const (
OidcClientSecretFile = "/kiali-secret/oidc-secret"
)

const (
DashboardsDiscoveryEnabled = "true"
DashboardsDiscoveryDisabled = "false"
DashboardsDiscoveryAuto = "auto"
)

// Global configuration for the application.
var configuration Config
var rwMutex sync.RWMutex
Expand Down Expand Up @@ -112,10 +118,12 @@ type PrometheusConfig struct {

// CustomDashboardsConfig describes configuration specific to Custom Dashboards
type CustomDashboardsConfig struct {
Enabled bool `yaml:"enabled,omitempty"`
IsCoreComponent bool `yaml:"is_core_component,omitempty"`
NamespaceLabel string `yaml:"namespace_label,omitempty"`
Prometheus PrometheusConfig `yaml:"prometheus,omitempty"`
DiscoveryEnabled string `yaml:"discovery_enabled,omitempty"`
DiscoveryAutoThreshold int `yaml:"discovery_auto_threshold,omitempty"`
Enabled bool `yaml:"enabled,omitempty"`
IsCoreComponent bool `yaml:"is_core_component,omitempty"`
NamespaceLabel string `yaml:"namespace_label,omitempty"`
Prometheus PrometheusConfig `yaml:"prometheus,omitempty"`
}

// GrafanaConfig describes configuration used for Grafana links
Expand Down Expand Up @@ -388,8 +396,10 @@ func NewConfig() (c *Config) {
},
ExternalServices: ExternalServices{
CustomDashboards: CustomDashboardsConfig{
Enabled: true,
NamespaceLabel: "kubernetes_namespace",
DiscoveryEnabled: DashboardsDiscoveryAuto,
DiscoveryAutoThreshold: 10,
Enabled: true,
NamespaceLabel: "kubernetes_namespace",
},
Grafana: GrafanaConfig{
Auth: Auth{
Expand Down

0 comments on commit be93b82

Please sign in to comment.