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

  1. Set `log_schema.host_key` to a valid simple path (default `host`) at the top level of the configuration
  2. Run `vector validate <config>` to catch schema errors before deploy
  3. 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 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


AI-assisted analysis of vectordotdev/vector@3708c39b12 (2026-08-20). Data as JSON: /api/errors/993c8985759159a9. Report an issue: GitHub.