{"record":{"id":"e8aafd4e6827867d","repo":"grafana/loki","slug":"failed-to-get-hostname-w","errorCode":null,"errorMessage":"failed to get hostname, %w","messagePattern":"failed to get hostname, %w","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/ruler/base/ruler_ring.go","lineNumber":61,"sourceCode":"\tInstanceID             string   `yaml:\"instance_id\" doc:\"hidden\"`\n\tInstanceInterfaceNames []string `yaml:\"instance_interface_names\" doc:\"default=[<private network interfaces>]\"`\n\tInstancePort           int      `yaml:\"instance_port\" doc:\"hidden\"`\n\tInstanceAddr           string   `yaml:\"instance_addr\" doc:\"hidden\"`\n\tEnableIPv6             bool     `yaml:\"instance_enable_ipv6\" doc:\"hidden\"`\n\tNumTokens              int      `yaml:\"num_tokens\"`\n\n\t// Injected internally\n\tListenPort int `yaml:\"-\"`\n\n\t// Used for testing\n\tSkipUnregister bool `yaml:\"-\"`\n}\n\n// RegisterFlags adds the flags required to config this to the given FlagSet\nfunc (cfg *RingConfig) RegisterFlags(f *flag.FlagSet) {\n\thostname, err := os.Hostname()\n\tif err != nil {\n\t\tpanic(fmt.Errorf(\"failed to get hostname, %w\", err))\n\t}\n\n\t// Ring flags\n\tcfg.KVStore.RegisterFlagsWithPrefix(\"ruler.ring.\", \"rulers/\", f)\n\tf.DurationVar(&cfg.HeartbeatPeriod, \"ruler.ring.heartbeat-period\", 5*time.Second, \"Interval between heartbeats sent to the ring.\")\n\tf.DurationVar(&cfg.HeartbeatTimeout, \"ruler.ring.heartbeat-timeout\", time.Minute, \"The heartbeat timeout after which ruler ring members are considered unhealthy within the ring. 0 = never (timeout disabled).\")\n\n\t// Instance flags\n\tcfg.InstanceInterfaceNames = netutil.PrivateNetworkInterfacesWithFallback([]string{\"eth0\", \"en0\"}, util_log.Logger)\n\tf.Var((*flagext.StringSlice)(&cfg.InstanceInterfaceNames), \"ruler.ring.instance-interface-names\", \"Name of network interface to read addresses from.\")\n\tf.StringVar(&cfg.InstanceAddr, \"ruler.ring.instance-addr\", \"\", \"IP address to advertise in the ring.\")\n\tf.IntVar(&cfg.InstancePort, \"ruler.ring.instance-port\", 0, \"Port to advertise in the ring (defaults to server.grpc-listen-port).\")\n\tf.StringVar(&cfg.InstanceID, \"ruler.ring.instance-id\", hostname, \"Instance ID to register in the ring.\")\n\tf.BoolVar(&cfg.EnableIPv6, \"ruler.ring.instance-enable-ipv6\", false, \"Enable using a IPv6 instance address.\")\n\tf.IntVar(&cfg.NumTokens, \"ruler.ring.num-tokens\", 128, \"The number of tokens the lifecycler will generate and put into the ring if it joined without transferring tokens from another lifecycler.\")\n}\n\n// ToLifecyclerConfig returns a LifecyclerConfig based on the ruler","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/grafana/loki/blob/24cfedd4f67b53367b63e273d64dbfc5ad307535/pkg/ruler/base/ruler_ring.go#L43-L79","documentation":"Error \"failed to get hostname, %w\" thrown in grafana/loki.","triggerScenarios":"Thrown at pkg/ruler/base/ruler_ring.go:61 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"24cfedd4f67b53367b63e273d64dbfc5ad307535","analyzedAt":"2026-08-15T20:47:01.143Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}