Skip to content

fix(frontend): allow resolution of v6 addresses. (backport release-3.5.x) #18261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/sources/shared/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2713,6 +2713,10 @@ The `frontend` block configures the Loki query-frontend.
# CLI flag: -frontend.instance-interface-names
[instance_interface_names: <list of strings> | default = [<private network interfaces>]]

# Enable using a IPv6 instance address (default false).
# CLI flag: -frontend.instance-enable-ipv6
[instance_enable_ipv6: <boolean> | default = false]

# Defines the encoding for requests to and responses from the scheduler and
# querier. Can be 'json' or 'protobuf' (defaults to 'json').
# CLI flag: -frontend.encoding
Expand Down
4 changes: 2 additions & 2 deletions pkg/lokifrontend/frontend/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"

"github.com/go-kit/log"
"github.com/grafana/dskit/netutil"
"github.com/grafana/dskit/ring"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
Expand All @@ -13,7 +14,6 @@ import (
v1 "github.com/grafana/loki/v3/pkg/lokifrontend/frontend/v1"
v2 "github.com/grafana/loki/v3/pkg/lokifrontend/frontend/v2"
"github.com/grafana/loki/v3/pkg/querier/queryrange/queryrangebase"
"github.com/grafana/loki/v3/pkg/util"
)

// This struct combines several configuration options together to preserve backwards compatibility.
Expand Down Expand Up @@ -48,7 +48,7 @@ func InitFrontend(cfg CombinedFrontendConfig, ring ring.ReadRing, limits v1.Limi
case cfg.FrontendV2.SchedulerAddress != "" || ring != nil:
// If query-scheduler address is configured, use Frontend.
if cfg.FrontendV2.Addr == "" {
addr, err := util.GetFirstAddressOf(cfg.FrontendV2.InfNames, log)
addr, err := netutil.GetFirstAddressOf(cfg.FrontendV2.InfNames, log, cfg.FrontendV2.EnableIPv6)
if err != nil {
return nil, nil, nil, errors.Wrap(err, "failed to get frontend address")
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/lokifrontend/frontend/v2/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ type Config struct {
GracefulShutdownTimeout time.Duration `yaml:"graceful_shutdown_timeout"`

// Used to find local IP address, that is sent to scheduler and querier-worker.
InfNames []string `yaml:"instance_interface_names" doc:"default=[<private network interfaces>]"`
InfNames []string `yaml:"instance_interface_names" doc:"default=[<private network interfaces>]"`
EnableIPv6 bool `yaml:"instance_enable_ipv6"`

// If set, address is not computed from interfaces.
Addr string `yaml:"address" doc:"hidden"`
Expand All @@ -69,6 +70,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {

cfg.InfNames = netutil.PrivateNetworkInterfacesWithFallback([]string{"eth0", "en0"}, util_log.Logger)
f.Var((*flagext.StringSlice)(&cfg.InfNames), "frontend.instance-interface-names", "Name of network interface to read address from. This address is sent to query-scheduler and querier, which uses it to send the query response back to query-frontend.")
f.BoolVar(&cfg.EnableIPv6, "frontend.instance-enable-ipv6", false, "Enable using a IPv6 instance address (default false).")
f.StringVar(&cfg.Addr, "frontend.instance-addr", "", "IP address to advertise to querier (via scheduler) (resolved via interfaces by default).")
f.IntVar(&cfg.Port, "frontend.instance-port", 0, "Port to advertise to querier (via scheduler) (defaults to server.grpc-listen-port).")

Expand Down
Loading