资讯动态

Vector `vector` Sink 默认 scheme 弃用指南:无 scheme 地址从 `http` 向 `https` 迁移

发布时间:2026/9/15 4:36:35 来源:尧图企业网站定制
VectorvectorSink 默认 scheme 弃用指南无 scheme 地址从http向https迁移【免费下载链接】vectorA high-performance observability data pipeline.项目地址: https://gitcode.com/GitHub_Trending/vect/vector导读本指南聚焦 Vector 项目在vectorsinkVector 之间中继观测数据的 sink上的一项行为变更当address或routing.endpoints未显式书写 scheme协议前缀时目前默认按http解析而该行为自 Vector 0.59.0 起被标记为弃用未来将改为默认https。本文以仓库内弃用公告 deprecation.d/vector-sink-default-scheme.md 为主体结合 src/sinks/vector/config.rs 的源码实现与测试用例讲清弃用的来龙去脉、实际行为差异、迁移步骤以及如何通过显式 scheme 消除告警并规避未来破坏性变更。弃用公告解读发生了什么仓库 deprecation.d 目录统一存放 Vector 的功能弃用公告每份文件以 YAML frontmatter 声明what弃用内容与deprecated_since首次公告版本。本主题公告原文如下whatvectorsink 中无 scheme 的address与routing.endpoints值默认解析为httpdeprecated_since0.59.0公告正文声明了三条核心事实形如127.0.0.1的vectorsink 端点在未显式书写 scheme 时当前默认按http处理该默认行为已弃用未来版本将改为默认https一个重要的例外当 TLS 已启用时无 scheme 地址现在就已经默认解析为https。也就是说这一弃用并不是把功能移除而是把无 scheme 时的默认解析结果从http收紧为https属于默认值语义的变化属于破坏性变更breaking change因此走完整的弃用生命周期。源码视角默认 scheme 的解析与告警机制弃用行为在源码中并非简单写死而是由一套校验时记录、构建时告警、TLS 联动的逻辑实现核心集中在 src/sinks/vector/config.rs。校验阶段记录 scheme 是否被省略在VectorConfig::validate中端点会先被解析并暂存为ValidatedEndpoint见 src/sinks/vector/config.rs。该结构体保存两个关键信息endpoint已按http默认 scheme 解析出的绝对 URL始终是带 host 与可用端口的http/https地址scheme_defaulted布尔值标记原始端点字符串是否省略了 scheme。解析时使用ValidatedEndpoint::parsefn parse(endpoint: str) - crate::ResultSelf { let scheme_defaulted !has_scheme(endpoint); let endpoint HttpEndpoint::parse_default_http(endpoint)?; Ok(Self { endpoint, scheme_defaulted }) }其中has_scheme定义于 src/sinks/util/uri.rs只识别出现在字符串最开头的scheme://形式[a-zA-Z][a-zA-Z0-9.-]*://。因此localhost:8080/write?targethttp://upstream中路径/查询串里后置的http://不会被误判为 scheme整个地址仍视为无 scheme会走默认值逻辑。校验注释还特别说明直接对host:port[/path]形式的字符串调用http::Uri解析是不安全的——http::Uri会把 host 当成 scheme 读取产生校验通过但 sink 无法使用的 URI因此必须使用带默认 scheme 的解析路径。parse_default_http默认补全http://前缀HttpEndpoint::parse_default_http见 src/sinks/util/uri.rs与通用的HttpEndpoint::parse语义不同解析函数无 scheme 时的默认值说明HttpEndpoint::parsehttps其他 HTTP 类 sink 的默认例如example.com:8080→https://example.com:8080HttpEndpoint::parse_default_httphttpvectorsink 专用兼容历史行为其实现parse_with_default_schemesrc/sinks/util/uri.rs在检测到无 scheme 时先拼接${default_scheme}://${endpoint}再交给Uri解析若端点已有显式 scheme 则原样保留。相应测试http_endpoint_defaults_missing_scheme_to_httpsrc/sinks/util/uri.rs覆盖了example.com、example.com:8080、localhost:8080/path、[::1]:8080等输入断言默认后 scheme 均为http并验证显式https://会被保留。构建阶段TLS 联动与弃用告警sink真正构建时VectorConfig::build先根据tls配置计算出MaybeTlsSettings随后调用两个关键步骤见 src/sinks/vector/config.rslet tls MaybeTlsSettings::from_config(self.tls.as_ref(), false)?; validated.warn_on_scheme_defaulted_endpoints(tls.is_tls()); let uris endpoints .iter() .map(|endpoint| endpoint.with_scheme(tls.is_tls())) .collect::crate::ResultVec_()?;warn_on_scheme_defaulted_endpoints(tls)src/sinks/vector/config.rs对每个scheme_defaulted true且未启用 TLS的端点输出一条DEPRECATED级别的告警日志完整措辞为DEPRECATED, scheme-lessaddressorrouting.endpointsvalue in thevectorsink defaults tohttp. This behavior is deprecated and will change tohttpsin a future release. Specify the scheme explicitly.告警中的端点地址通过redacted_uri()输出内嵌的 userinfo 凭据会被脱敏避免把密码写进日志。with_scheme(tls)src/sinks/vector/config.rs仅在tls scheme_defaulted时将 URI 的 scheme 原地改写为https显式 scheme 无论 TLS 开关如何都保持不变。这正是公告中TLS 启用时无 scheme 地址已默认https的源码落点。由此可推断的设计意图弃用告警只针对无 scheme 且默认成了http的情况——因为只有这种情况会在未来被重新解释为https并可能改变传输安全属性。TLS 启用时无 scheme 默认https已经是未来行为故不告警。测试验证四种场景的行为矩阵源码测试src/sinks/vector/config.rs完整覆盖了弃用行为的四个组合场景可直接作为迁移后的验收基准场景端点写法TLS是否告警说明build_warns_on_scheme_less_endpoint127.0.0.1:6000否✅ 1 条DEPRECATED核心弃用场景应优先迁移build_warns_on_scheme_less_endpoint_with_userinfo_redacteduser:secret127.0.0.1:6000否✅ 1 条且日志不含secret告警同时验证凭据脱敏build_does_not_warn_on_explicit_schemehttp://127.0.0.1:6000否❌ 无显式 scheme 即未来推荐写法build_does_not_warn_on_scheme_less_endpoint_with_tls127.0.0.1:6000是❌ 无TLS 下默认已是https符合未来行为迁移指南显式声明 scheme按弃用公告的迁移建议只需在端点中显式写出 scheme 即可。公告给出的最小迁移示例deprecation.d/vector-sink-default-scheme.mdsinks: my_sink: type: vector address: http://127.0.0.1:6000仓库也在多处与之对齐VectorConfig::generate_configsrc/sinks/vector/config.rs生成的示例配置显式使用http://127.0.0.1:6000注释明确说明无 scheme 默认http已弃用生成示例不依赖该默认值address字段的文档示例同样采用http://127.0.0.1:6000与https://somehost:6000src/sinks/vector/config.rs。迁移决策表目标链路推荐端点写法说明明文本地/内网当前行为不变address: http://127.0.0.1:6000显式http行为与旧默认一致消除告警需要加密传输address: https://somehost:6000显式https与未来默认一致多端点 负载均衡/故障转移见下文routing示例对每个 endpoint 显式加 scheme依赖 TLS 配置推导tls: { enabled: true } 无 scheme现状即可但建议仍显式书写以便未来语义稳定多端点场景routing.endpointsaddress与routing互斥且routing.endpoints至少需要一个端点校验逻辑见 src/sinks/vector/config.rs。弃用同样适用于routing.endpoints中的每个值迁移时逐个端点显式补全 schemesinks: my_sink: type: vector routing: strategy: load_balance endpoints: - http://127.0.0.1:6000 - http://10.0.0.2:6000 health: interval_secs: 5 timeout_secs: 3routing支持load_balance默认基于 Tower distributed service 分发请求、failover每次仅用一个端点失败后顺延下一个等策略策略枚举定义于 src/sinks/vector/config.rs。当strategy为load_balance时还可配置routing.health控制健康检查与退避行为。迁移后的验证方法本地校验配置vector validate --config file仓库提供 src/validate.rs 及 config/vector.yaml 可作参考确认语法与端点合法性观察启动日志迁移前启动会打印包含DEPRECATED, scheme-less ... defaults to http的告警迁移后告警消失回归验证可对照上文四种测试场景矩阵确认显式 scheme 写法的行为符合预期。弃用生命周期从公告到移除本公告只是弃用的第一步。按 deprecation.d/README.md 的生命周期约定完整的流程为Announce公告引入弃用的 PR 向deprecation.d/添加本文件deprecated_since: 0.59.0即首次公告版本Planned计划中此后每个版本发布时该条目都会进入发布说明的planned_deprecations区块持续提醒用户Removed移除未来某版本正式将无 scheme 默认值改为https时通过cargo vdev deprecation enact vector-sink-default-scheme --version removed-in-version一次性记录移除信息并删除本片段手动删除会导致条目从past_deprecations中丢失。当前阶段处于Planned行为仍是无 scheme 默认http 告警而非立即切换为https。这意味着迁移窗口充足但应视为硬性 deadline——一旦正式移除无 scheme 配置将静默改为https可能因协议不匹配直接导致数据发送失败因此显式声明 scheme 是唯一稳妥的长期写法。小结vectorsink 的 scheme 默认值弃用是一个典型的默认值语义收紧型破坏性变更0.59.0 起无 scheme 的address/routing.endpoints在未启用 TLS 时默认http并输出DEPRECATED告警未来将改为httpsTLS 启用时现在即默认https。迁移成本极低——为每个端点显式补上http://或https://前缀即可同时消除告警并确保未来版本行为稳定。告警、脱敏、TLS 联动等细节均有源码与测试支撑可放心作为迁移验收的依据。【免费下载链接】vectorA high-performance observability data pipeline.项目地址: https://gitcode.com/GitHub_Trending/vect/vector创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

读完文章,也想定制专属网站?

尧图设计师 24 小时内与您沟通定制方案

免费获取报价