Coercer

CAUTION

This transform has been deprecated in favor of the remap transform, which enables you to use Vector Remap Language (VRL for short) to create transform logic of any degree of complexity. The examples below show how you can use VRL to replace this transform's functionality.

.bool = to_bool("false")
.float = to_float("1.0")
.int = to_int("1")
.string = to_string(1)
.timestamp = to_timestamp("2021-01-15T12:33:22.213221Z")

Example Configuration

Date

Config
Input
Output
1[transforms.my_transform_id]
2type = "coercer"
3
4 [transforms.my_transform_id.types]
5 bytes_in = "int"
6 bytes_out = "int"
7 status = "int"
8 timestamp = "timestamp|%d/%m/%Y:%H:%M:%S %z"
1{
2 "log": {
3 "bytes_in": "5667",
4 "bytes_out": "20574",
5 "host": "5.86.210.12",
6 "message": "GET /embrace/supply-chains/dynamic/vertical",
7 "status": "201",
8 "timestamp": "19/06/2019:17:20:49 -0400",
9 "user_id": "zieme4647"
10 }
11}
1{
2 "log": {
3 "bytes_in": 5667,
4 "bytes_out": 20574,
5 "host": "5.86.210.12",
6 "message": "GET /embrace/supply-chains/dynamic/vertical",
7 "status": 201,
8 "timestamp": "19/06/2019:17:20:49 -0400",
9 "user_id": "zieme4647"
10 }
11}

Configuration Options

Required Options

inputs(required)

A list of upstream source or transform IDs. Wildcards (*) are supported.

See configuration for more info.

TypeSyntaxDefaultExample
arrayliteral["my-source-or-transform-id","prefix-*"]
type(required)

The component type. This is a required field for all components and tells Vector which component to use.

TypeSyntaxDefaultExample
stringliteral["coercer"]

Advanced Options

drop_unspecified(optional)

Set to true to drop all fields that are not specified in the types table. Make sure both message and timestamp are specified in the types table as their absense will cause the original message data to be dropped along with other extraneous fields.

TypeSyntaxDefaultExample
bool
timezone(optional)

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.

TypeSyntaxDefaultExample
stringliterallocal["local","America/NewYork","EST5EDT"]
types(optional)

Key/value pairs representing mapped log field names and types. This is used to coerce log fields from strings into their proper types. The available types are listed in the Types list below.

Timestamp coercions need to be prefaced with timestamp|, for example "timestamp|%F". Timestamp specifiers can use either of the following:

  1. One of the built-in-formats listed in the Timestamp Formats table below.
  2. The time format specifiers from Rust's chrono library.

Types

  • array
  • bool
  • bytes
  • float
  • int
  • map
  • null
  • timestamp (see the table below for formats)

Timestamp Formats

FormatDescriptionExample
%F %TYYYY-MM-DD HH:MM:SS2020-12-01 02:37:54
%v %TDD-Mmm-YYYY HH:MM:SS01-Dec-2020 02:37:54
%FT%TISO 8601[RFC 3339](https://tools.ietf.org/html/rfc3339) format without time zone2020-12-01T02:37:54
%a, %d %b %Y %TRFC 822/2822 without time zoneTue, 01 Dec 2020 02:37:54
%a %d %b %T %Ydate command output without time zoneTue 01 Dec 02:37:54 2020
%a %b %e %T %Yctime formatTue Dec 1 02:37:54 2020
%sUNIX timestamp1606790274
%FT%TZISO 8601/RFC 3339 UTC2020-12-01T09:37:54Z
%+ISO 8601/RFC 3339 UTC with time zone2020-12-01T02:37:54-07:00
%a %d %b %T %Z %Ydate command output with time zoneTue 01 Dec 02:37:54 PST 2020
%a %d %b %T %z %Ydate command output with numeric time zoneTue 01 Dec 02:37:54 -0700 2020
%a %d %b %T %#z %Ydate command output with numeric time zone (minutes can be missing or present)Tue 01 Dec 02:37:54 -07 2020

Note: the examples in this table are for 54 seconds after 2:37 am on December 1st, 2020 in Pacific Standard Time.

TypeSyntaxDefaultExample
hash[{"status":"int","duration":"float","success":"bool","timestamp_iso8601":"timestamp|%F","timestamp_custom":"timestamp|%a %b %e %T %Y","timestamp_unix":"timestamp|%F %T","parent":{"child":"int"}}]

How it Works

State

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