Skip to content

Commit

Permalink
Merge pull request #654 from signal18/dashboard
Browse files Browse the repository at this point in the history
prevent missing grafana metrics when initialize with graphite-whitelist
  • Loading branch information
svaroqui authored Jun 15, 2024
2 parents cecd4ef + 48be292 commit 35f1b60
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions cluster/cluster_graphite.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ func (cluster *Cluster) NewClusterGraphite() {
UseBlacklist: cluster.Conf.GraphiteBlacklist,
}

/**
* Check if whitelist.conf not exists
* When not exists check if graphite embedded is already set
* If graphite embedded is immutable, set the default whitelist as grafana to prevent missing metrics
* The next process will be executed by ReloadGraphiteFilterList()
*/
if _, err := os.Stat(cluster.Conf.WorkingDir + "/" + cluster.Name + "/whitelist.conf"); errors.Is(err, os.ErrNotExist) {
//This will change the default to grafana
if _, ok := cluster.Conf.ImmuableFlagMap["graphite-embedded"]; ok {
cluster.LogModulePrintf(cluster.Conf.Verbose, config.ConstLogModGraphite, config.LvlWarn, "[Whitelist] failed to read file in cluster %s working dir, change template as grafana due to immutable graphite-embedded exists", cluster.Name)
cluster.Conf.GraphiteWhitelistTemplate = config.ConstGraphiteTemplateGrafana
}
}

cluster.ReloadGraphiteFilterList()
}

Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ func (repman *ReplicationManager) AddFlags(flags *pflag.FlagSet, conf *config.Co
flags.StringVar(&conf.GraphiteCarbonHost, "graphite-carbon-host", "127.0.0.1", "Graphite monitoring host")
flags.BoolVar(&conf.GraphiteMetrics, "graphite-metrics", false, "Enable Graphite monitoring")
flags.BoolVar(&conf.GraphiteEmbedded, "graphite-embedded", false, "Enable Internal Graphite Carbon Server")
flags.BoolVar(&conf.GraphiteWhitelist, "graphite-whitelist", false, "Enable Whitelist")
flags.BoolVar(&conf.GraphiteWhitelist, "graphite-whitelist", true, "Enable Whitelist")
flags.BoolVar(&conf.GraphiteBlacklist, "graphite-blacklist", false, "Enable Blacklist")
flags.StringVar(&conf.GraphiteWhitelistTemplate, "graphite-whitelist-template", "minimal", "Graphite default template for whitelist (none | minimal | grafana | all)")
}
Expand Down

0 comments on commit 35f1b60

Please sign in to comment.