Metric to Log Transform

The Vector metric_to_log transform converts a metric event into a log event, which can be useful for sending metrics to log-support downstream components.

Configuration

[transforms.my_transform_id]
type = "metric_to_log" # required
inputs = ["my-source-or-transform-id", "prefix-*"] # required
host_tag = "hostname" # optional, default
  • commonoptionalstring

    host_tag

    Tag key that identifies the source host.

    • Syntax: literal
    • Default: "hostname"
  • optionalstring

    timezone

    The name of the time zone to apply to timestamp conversions that do not contain an explicit time zone. This overrides the global timezone option. The time zone name may be any name in the TZ database, or local to indicate system local time.

    • Syntax: literal
    • Default: "local"

Telemetry

This component provides the following metrics that can be retrieved through the internal_metrics source. See the metrics section in the monitoring page for more info.

  • counter

    processing_errors_total

    The total number of processing errors encountered by this component. This metric includes the following tags:

    • component_kind - The Vector component kind.

    • component_name - The Vector component ID.

    • component_type - The Vector component type.

    • error_type - The type of the error

    • instance - The Vector instance identified by host and port.

    • job - The name of the job producing Vector metrics.

  • counter

    events_in_total

    The number of events accepted by this component either from tagged origin like file and uri, or cumulatively from other origins. This metric includes the following tags:

    • component_kind - The Vector component kind.

    • component_name - The Vector component ID.

    • component_type - The Vector component type.

    • container_name - The name of the container from which the event originates.

    • file - The file from which the event originates.

    • instance - The Vector instance identified by host and port.

    • job - The name of the job producing Vector metrics.

    • mode - The connection mode used by the component.

    • peer_addr - The IP from which the event originates.

    • peer_path - The pathname from which the event originates.

    • pod_name - The name of the pod from which the event originates.

    • uri - The sanitized uri from which the event originates.

  • counter

    processed_events_total

    The total number of events processed by this component. This metric includes the following tags:

    • component_kind - The Vector component kind.

    • component_name - The Vector component ID.

    • component_type - The Vector component type.

    • file - The file that produced the error

    • instance - The Vector instance identified by host and port.

    • job - The name of the job producing Vector metrics.

  • counter

    events_out_total

    The total number of events emitted by this component. This metric includes the following tags:

    • component_kind - The Vector component kind.

    • component_name - The Vector component ID.

    • component_type - The Vector component type.

    • instance - The Vector instance identified by host and port.

    • job - The name of the job producing Vector metrics.

  • counter

    processed_bytes_total

    The number of bytes processed by the component. This metric includes the following tags:

    • component_kind - The Vector component kind.

    • component_name - The Vector component ID.

    • component_type - The Vector component type.

    • container_name - The name of the container from which the bytes originate.

    • file - The file from which the bytes originate.

    • instance - The Vector instance identified by host and port.

    • job - The name of the job producing Vector metrics.

    • mode - The connection mode used by the component.

    • peer_addr - The IP from which the bytes originate.

    • peer_path - The pathname from which the bytes originate.

    • pod_name - The name of the pod from which the bytes originate.

    • uri - The sanitized uri from which the bytes originate.

Examples

Given the following Vector metric event:

{
"kind": "absolute",
"name": "histogram",
"timestamp": "2020-08-01T21:15:47+00:00",
"tags": {
"host": "my.host.com",
"code": "200"
},
"histogram": {
"buckets": [
{
"upper_limit": 1.0,
"count": 10
},
{
"upper_limit": 2.0,
"count": 20
}
],
"count": 30,
"sum": 50.0
}
}

And the following configuration:

vector.toml
[transforms.metric_to_log]
type = "metric_to_log"
host_tag = "host"

The following Vector log event will be output:

{
"name": "histogram",
"timestamp": "2020-08-01T21:15:47+00:00",
"host": "my.host.com",
"tags": {
"code": "200"
},
"kind": "absolute",
"histogram": {
"buckets": [
{
"count": 10,
"upper_limit": 1.0
},
{
"count": 20,
"upper_limit": 2.0
}
],
"count": 30,
"sum": 50.0
}
}

How It Works

State

This component is stateless, meaning its behavior is consistent across each input.