{"record":{"id":"30bc3e390f25a2a5","repo":"prometheus/node_exporter","slug":"invalid-ntp-protocol-version-d-must-be-2-3-or","errorCode":null,"errorMessage":"invalid NTP protocol version %d; must be 2, 3, or 4","messagePattern":"invalid NTP protocol version (.+?); must be 2, 3, or 4","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/ntp.go","lineNumber":70,"sourceCode":"\tlogger                                                                 *slog.Logger\n}\n\nfunc init() {\n\tregisterCollector(\"ntp\", defaultDisabled, NewNtpCollector)\n}\n\n// NewNtpCollector returns a new Collector exposing sanity of local NTP server.\n// Default definition of \"local\" is:\n// - collector.ntp.server address is a loopback address (or collector.ntp.server-is-mine flag is turned on)\n// - the server is reachable with outgoing IP_TTL = 1\nfunc NewNtpCollector(logger *slog.Logger) (Collector, error) {\n\tipaddr := net.ParseIP(*ntpServer)\n\tif !*ntpServerIsLocal && (ipaddr == nil || !ipaddr.IsLoopback()) {\n\t\treturn nil, fmt.Errorf(\"only IP address of local NTP server is valid for --collector.ntp.server\")\n\t}\n\n\tif *ntpProtocolVersion < 2 || *ntpProtocolVersion > 4 {\n\t\treturn nil, fmt.Errorf(\"invalid NTP protocol version %d; must be 2, 3, or 4\", *ntpProtocolVersion)\n\t}\n\n\tif *ntpOffsetTolerance < 0 {\n\t\treturn nil, fmt.Errorf(\"offset tolerance must be non-negative\")\n\t}\n\n\tif *ntpServerPort < 1 || *ntpServerPort > 65535 {\n\t\treturn nil, fmt.Errorf(\"invalid NTP port number %d; must be between 1 and 65535 inclusive\", *ntpServerPort)\n\t}\n\n\tlogger.Warn(\"This collector is deprecated and will be removed in the next major version release.\")\n\treturn &ntpCollector{\n\t\tstratum: typedDesc{prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, ntpSubsystem, \"stratum\"),\n\t\t\t\"NTPD stratum.\",\n\t\t\tnil, nil,\n\t\t), prometheus.GaugeValue},\n\t\tleap: typedDesc{prometheus.NewDesc(","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/ntp.go#L52-L88","documentation":"NewNtpCollector validates --collector.ntp.protocol-version after checking the server flag. The NTP query implementation used by this collector only supports protocol versions 2, 3, and 4; values below 2 or above 4 cause the constructor to return this formatted error at startup.","triggerScenarios":"Starting node_exporter with --collector.ntp.protocol-version=1, 0, 5, 6, 7, or any integer outside [2,4] passed via the flag (the value is an int flag, so non-numeric values fail earlier at flag parsing).","commonSituations":"Users assuming NTPv5 or draft versions are supported on newer systems; copying old ntpdate-era defaults like version 1; setting version 4 explicitly is fine, but 5 is not despite newer NTP drafts existing.","solutions":["Set --collector.ntp.protocol-version=4 (the most widely supported modern choice).","Use 3 or 2 only if your local server is very old and rejects v4.","Check the current flag value in your service/unit file and correct it to an integer in [2,4].","Remember this collector is deprecated; if you need newer protocol behavior, use an alternative NTP exporter."],"exampleFix":"// before\n//   --collector.ntp.protocol-version=5\n// after\n//   --collector.ntp.protocol-version=4","handlingStrategy":"validation","validationCode":"# shell: reject protocol versions outside 2-4 before launch\ncase \"$NTP_PROTO\" in 2|3|4) ;; *) echo \"invalid --collector.ntp.protocol-version: $NTP_PROTO\"; exit 1;; esac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin --collector.ntp.protocol-version=4 in your standard deployment config.","Do not copy ntpdate-era defaults like version 1.","Validate any templated integer against [2,4] before rendering unit files.","Check the flag with --help if unsure of supported values."],"tags":["ntp","configuration","cli-flag","validation"],"backgroundTag":"value-out-of-range","analyzedSha":"17ddd77c59ba27e1508e9f7894b1e55b44d6aed3","analyzedAt":"2026-09-07T17:54:06.211Z","contentChangedAt":"2026-09-07T17:54:06.211Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}