You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vector.dev拆分配置文件后执行命令报错,请求排查问题

Vector配置拆分后启动报错排查

当前目录结构

├── sinks
│   └── sin.yaml
├── sources
│   └── sss.yaml
├── transforms
│   └── ttt.yaml
└── vector.yaml

各配置文件内容

sources/sss.yaml

type: "kafka"
  bootstrap_servers: http://example.com
  auto_offset_reset: "earliest"
  group_id: "vector-kuber"
  topics: ["vector-kuber"]
  decoding:
    codec: "json"

transforms/ttt.yaml

type: "remap"
inputs: ["sss"]
source: |
  output = {}
  . = output

sinks/sin.yaml

type: elasticsearch
inputs: ["ttt"]
endpoints: ["http://elk:9200"]
encoding:
  except_fields: ["route"]
bulk:
  index: kuberlogs-%Y-%m-%d
auth:
  password: "pass"
  user: "user"
  strategy: basic

执行命令及错误

执行命令:

vector -config-dir /etc/vector

报错信息:

error: unrecognized subcommand '/etc/vector'

错误原因及修复方案

1. 命令参数使用错误

-config-dir是Vector的命令选项,不是子命令,正确的命令格式应该是将选项放在命令后:

vector --config-dir /etc/vector

或者使用短选项简化命令:

vector -C /etc/vector

2. 配置文件格式不符合要求

Vector的组件配置(source/transform/sink)需要以组件名称作为顶层键,当前配置文件缺少这一层结构,需修改如下:

  • 修改sources/sss.yaml:
sss:
  type: "kafka"
  bootstrap_servers: http://example.com
  auto_offset_reset: "earliest"
  group_id: "vector-kuber"
  topics: ["vector-kuber"]
  decoding:
    codec: "json"
  • 修改transforms/ttt.yaml:
ttt:
  type: "remap"
  inputs: ["sss"]
  source: |
    output = {}
    . = output
  • 修改sinks/sin.yaml:
sin:
  type: elasticsearch
  inputs: ["ttt"]
  endpoints: ["http://elk:9200"]
  encoding:
    except_fields: ["route"]
  bulk:
    index: kuberlogs-%Y-%m-%d
  auth:
    password: "pass"
    user: "user"
    strategy: basic

完成以上修改后,重新执行正确的启动命令即可加载拆分后的配置文件。

内容的提问来源于stack exchange,提问作者Vacilio

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 01:16:09