diff --git a/docs/sources/shared/configuration.md b/docs/sources/shared/configuration.md index 6703fcc6c0a1a..cbc13a72d89eb 100644 --- a/docs/sources/shared/configuration.md +++ b/docs/sources/shared/configuration.md @@ -124,7 +124,7 @@ ui: # How frequently to rejoin the cluster to address split brain issues. # CLI flag: -ui.rejoin-interval - [rejoin_interval: | default = 1m] + [rejoin_interval: | default = 3m] # Number of initial peers to join from the discovered set. # CLI flag: -ui.cluster-max-join-peers @@ -138,6 +138,10 @@ ui: # CLI flag: -ui.enable-ipv6 [enable_ipv6: | default = false] + # Enable debug logging for the UI. + # CLI flag: -ui.debug + [debug: | default = false] + discovery: # List of peers to join the cluster. Supports multiple values separated by # commas. Each value can be a hostname, an IP address, or a DNS name (A/AAAA diff --git a/pkg/ui/config.go b/pkg/ui/config.go index b1a9b4096fe8a..79283d2fd81e6 100644 --- a/pkg/ui/config.go +++ b/pkg/ui/config.go @@ -21,6 +21,7 @@ type Config struct { ClusterMaxJoinPeers int `yaml:"cluster_max_join_peers"` // Number of initial peers to join from the discovered set. ClusterName string `yaml:"cluster_name"` // Name to prevent nodes without this identifier from joining the cluster. EnableIPv6 bool `yaml:"enable_ipv6"` + Debug bool `yaml:"debug"` Discovery struct { JoinPeers []string `yaml:"join_peers"` } `yaml:"discovery"` @@ -42,11 +43,12 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) { f.Var((*flagext.StringSlice)(&cfg.InfNames), "ui.interface", "Name of network interface to read address from.") f.StringVar(&cfg.NodeName, "ui.node-name", hostname, "Name to use for this node in the cluster.") f.StringVar(&cfg.AdvertiseAddr, "ui.advertise-addr", "", "IP address to advertise in the cluster.") - f.DurationVar(&cfg.RejoinInterval, "ui.rejoin-interval", 1*time.Minute, "How frequently to rejoin the cluster to address split brain issues.") + f.DurationVar(&cfg.RejoinInterval, "ui.rejoin-interval", 3*time.Minute, "How frequently to rejoin the cluster to address split brain issues.") f.IntVar(&cfg.ClusterMaxJoinPeers, "ui.cluster-max-join-peers", 3, "Number of initial peers to join from the discovered set.") f.StringVar(&cfg.ClusterName, "ui.cluster-name", "", "Name to prevent nodes without this identifier from joining the cluster.") f.BoolVar(&cfg.EnableIPv6, "ui.enable-ipv6", false, "Enable using a IPv6 instance address.") f.Var((*flagext.StringSlice)(&cfg.Discovery.JoinPeers), "ui.discovery.join-peers", "List of peers to join the cluster. Supports multiple values separated by commas. Each value can be a hostname, an IP address, or a DNS name (A/AAAA and SRV records).") + f.BoolVar(&cfg.Debug, "ui.debug", false, "Enable debug logging for the UI.") } func (cfg Config) Validate() error { diff --git a/pkg/ui/service.go b/pkg/ui/service.go index b665c03b1d1fa..e3ad459fbf0df 100644 --- a/pkg/ui/service.go +++ b/pkg/ui/service.go @@ -20,8 +20,6 @@ import ( "github.com/grafana/dskit/services" "github.com/prometheus/client_golang/prometheus" "golang.org/x/net/http2" - - util_log "github.com/grafana/loki/v3/pkg/util/log" ) // This allows to rate limit the number of updates when the cluster is frequently changing (e.g. during rollout). @@ -42,7 +40,7 @@ type Service struct { } func NewService(cfg Config, router *mux.Router, logger log.Logger, reg prometheus.Registerer) (*Service, error) { - addr, err := ring.GetInstanceAddr(cfg.AdvertiseAddr, cfg.InfNames, util_log.Logger, cfg.EnableIPv6) + addr, err := ring.GetInstanceAddr(cfg.AdvertiseAddr, cfg.InfNames, logger, cfg.EnableIPv6) if err != nil { return nil, err } @@ -56,6 +54,10 @@ func NewService(cfg Config, router *mux.Router, logger log.Logger, reg prometheu }, }, } + + if !cfg.Debug { + logger = level.NewFilter(logger, level.AllowInfo()) + } advertiseAddr := fmt.Sprintf("%s:%d", cfg.AdvertiseAddr, cfg.AdvertisePort) node, err := ckit.NewNode(httpClient, ckit.Config{ Name: cfg.NodeName, diff --git a/production/helm/loki/values.yaml b/production/helm/loki/values.yaml index 5853809c4d2b6..a06b5ee9b862d 100644 --- a/production/helm/loki/values.yaml +++ b/production/helm/loki/values.yaml @@ -286,7 +286,7 @@ loki: ui: discovery: join_peers: - - '{{ include "loki.distributorFullname" . }}.{{ $.Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}' + - '{{ include "loki.queryFrontendFullname" . }}.{{ $.Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}' {{- end }} {{- with .Values.loki.querier }} querier: