vectordotdev/vector · error
valid host key
Error message
valid host key
What it means
`log_schema().host_key()` returns an Option; metric_to_log requires it when building the schema definition for the Legacy log namespace (src/transforms/metric_to_log.rs:248). If the global `log_schema.host_key` is unset, blank, or unparseable as a value path, `expect("valid host key")` panics while the transform's type definition is assembled at config-load time.
Source
Thrown at src/transforms/metric_to_log.rs:248
None,
);
// This is added as a "marker" field to determine which namespace is being used at runtime.
// This is normally handled automatically by sources, but this is a special case.
schema_definition = schema_definition.with_metadata_field(
&owned_value_path!("vector"),
Kind::object(Collection::empty()),
None,
);
}
LogNamespace::Legacy => {
if let Some(timestamp_key) = log_schema().timestamp_key() {
schema_definition =
schema_definition.with_event_field(timestamp_key, Kind::timestamp(), None);
}
schema_definition = schema_definition.with_event_field(
log_schema().host_key().expect("valid host key"),
Kind::bytes().or_undefined(),
None,
);
}
}
schema_definition
}
#[derive(Clone, Debug)]
pub struct MetricToLog {
host_tag: Option<OwnedValuePath>,
timezone: TimeZone,
log_namespace: LogNamespace,
tag_values: MetricTagValues,
}
impl MetricToLog {
pub fn new(View on GitHub (pinned to 3708c39b12)
Solutions
- Set `log_schema.host_key` to a valid simple path (default `host`) at the top level of the configuration
- Run `vector validate <config>` to catch schema errors before deploy
- If embedding: replace the expect with a propagated configuration error
Example fix
# before log_schema: timestamp_key: ts # host_key missing or blank # after log_schema: host_key: host timestamp_key: ts
Defensive patterns
Strategy: validation
Validate before calling
# shell: ensure every log_schema key used by Legacy-namespace transforms is set vector validate /etc/vector/vector.yaml --no-environment grep -A6 '^log_schema:' /etc/vector/vector.yaml # message/host/timestamp keys present
Prevention
- When overriding log_schema, always specify message_key, host_key, and timestamp_key explicitly
- Validate configs in CI with `vector validate`
- Watch for YAML indentation that detaches keys from the log_schema block
When it happens
Trigger: A metric_to_log transform in a pipeline with a top-level `log_schema:` override whose `host_key` is missing, empty, or an invalid path expression.
Common situations: Operators customizing log_schema (e.g. renaming host to hostname) who blank or mistype the value; YAML indentation mistakes placing host_key under a component instead of log_schema.
Related errors
- valid message key
- global log_schema.message_key to be valid path
- valid metadata key
- registered log schema required
- valid message key
AI-assisted analysis of vectordotdev/vector@3708c39b12 (2026-08-20).
Data as JSON: /api/errors/993c8985759159a9.
Report an issue: GitHub.