{"record":{"id":"0c9c76d6be8c59cb","repo":"cloudflare/cloudflared","slug":"metrics-has-to-be-provided","errorCode":null,"errorMessage":"--metrics has to be provided","messagePattern":"--metrics has to be provided","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/tunnel/subcommands.go","lineNumber":484,"sourceCode":"\treturn strings.Join(output, \", \")\n}\n\nfunc buildReadyCommand() *cli.Command {\n\treturn &cli.Command{\n\t\tName:               \"ready\",\n\t\tAction:             cliutil.ConfiguredAction(readyCommand),\n\t\tUsage:              \"Call /ready endpoint and return proper exit code\",\n\t\tUsageText:          \"cloudflared tunnel [tunnel command options] ready [subcommand options]\",\n\t\tDescription:        \"cloudflared tunnel ready will return proper exit code based on the /ready endpoint\",\n\t\tFlags:              []cli.Flag{},\n\t\tCustomHelpTemplate: commandHelpTemplate(),\n\t}\n}\n\nfunc readyCommand(c *cli.Context) error {\n\tmetricsOpts := c.String(flags.Metrics)\n\tif !c.IsSet(flags.Metrics) {\n\t\treturn errors.New(\"--metrics has to be provided\")\n\t}\n\n\trequestURL := fmt.Sprintf(\"http://%s/ready\", metricsOpts)\n\treq, err := http.NewRequest(http.MethodGet, requestURL, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// nolint: gosec // URL is constructed from the user-configured local metrics endpoint.\n\tres, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() { _ = res.Body.Close() }()\n\tif res.StatusCode != 200 {\n\t\tbody, err := io.ReadAll(res.Body)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/tunnel/subcommands.go#L466-L502","documentation":"readyCommand polls the /ready endpoint on the metrics server, so it needs the metrics address. If the --metrics flag was not explicitly set, cloudflared refuses to guess the address and returns \"--metrics has to be provided\".","triggerScenarios":"Running `cloudflared tunnel ready` without --metrics (e.g. `cloudflared tunnel ready` alone), relying on a config-file value which is not counted as \"set\" on the CLI.","commonSituations":"Health-check scripts omitting --metrics; assuming the metrics default from the config file satisfies the flag check; copy-pasting the command from docs without the flag.","solutions":["Run `cloudflared tunnel ready --metrics 127.0.0.1:PORT` matching your metrics listener address.","Ensure the metrics server is running on that address (check the running cloudflared's metrics flag).","Update health-check scripts/monitoring to include --metrics."],"exampleFix":"// before\ncloudflared tunnel ready\n// after\ncloudflared tunnel ready --metrics 127.0.0.1:20241","handlingStrategy":"validation","validationCode":"if ! grep -q -- '--metrics' <<<\"$CMD\"; then set -- \"$@\" --metrics 127.0.0.1:20241; fi\ncloudflared tunnel ready \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --metrics to `tunnel ready` in health-check scripts.","Match the flag value to the running instance's metrics listener address.","Confirm the metrics server is up before probing /ready."],"tags":["cli","metrics","health-check","missing-flag"],"backgroundTag":"missing-required-flag","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}