---
title: "TCP/UDP Output"
description: "write TenXObject and template values to a TCP/UDP socket"
source: "https://github.com/log-10x/modules/tree/main/pipelines/run/modules/output/event/socket/module.yaml"
icon: "material/ip-network-outline"

---
Writes [TenXObject](https://doc.log10x.com/api/js/#TenXObject "Provide structured, reflective access to log/trace events read from input(s).") instance and template fields via TCP/UDP socket using a log4j2 appender.

For an example configuration see the [Logstash TCP output](https://github.com/log-10x/modules/blob/main/pipelines/run/modules/input/forwarder/logstash/stream.yaml){target="\_blank"}.

## :material-menu: Options

Specify the options below to [configure](/config "configure") multiple TCP/UDP output:

|Name|Description|
|---|---|
|[outputSocketProtocol](#outputsocketprotocol "Network protocol for the socket, either \"TCP\" or \"UDP\".")|Network protocol for the socket, either "TCP" or "UDP".|
|[outputSocketHost](#outputsockethost "host TCP/UDP address to connect and write to")|Host TCP/UDP address to connect and write to|
|[outputSocketPort](#outputsocketport "endpoint port number")|Endpoint port number|
|[outputSocketFields](#outputsocketfields "list of TenXObject field names to encode")|List of TenXObject field names to encode|
|[outputSocketFilter](#outputsocketfilter "a JavaScript expression an TenXObject must evaluate as 'truthy' against to be written to this output")|A JavaScript expression an TenXObject must evaluate as 'truthy' against to be written to this output|
|[outputSocketWriteObjects](#outputsocketwriteobjects "if true, encode TenXObjects [outputSocketFields](https://doc.log10x.com/run/output/event/socket/#outputsocketfields) to this output")|If true, encode TenXObjects \[outputSocketFields\](https://doc.log10x.com/run/output/event/socket/#outputsocketfields) to this output|
|[outputSocketWriteTemplates](#outputsocketwritetemplates "if true, write new TenXTemplates to this output")|If true, write new TenXTemplates to this output|
|[outputSocketEncodeType](#outputsocketencodetype "the output format in which to encode TenXObject values. Possible values:[json, delimited]")|The output format in which to encode TenXObject values. Possible values:\[json, delimited\]|
|[outputSocketEncodedLinePrefix](#outputsocketencodedlineprefix "the line prefix prepended to the encoded event if 'outputSocketEncodeType' is 'delimited'")|The line prefix prepended to the encoded event if 'outputSocketEncodeType' is 'delimited'|
|[outputSocketEncodeDelimiter](#outputsocketencodedelimiter "the delimiter placed between key and values pairs if 'outputSocketEncodeType' is 'delimited'")|The delimiter placed between key and values pairs if 'outputSocketEncodeType' is 'delimited'|

### :material-menu-right-outline:**`outputSocketProtocol`**

Network protocol for the socket, either "TCP" or "UDP".

|Type|Default|
|---|---|
|String|""|

Specifies the Network protocol for the socket, either "TCP" (default) or "UDP".


### :material-menu-right-outline:**`outputSocketHost`**

Host TCP/UDP address to connect and write to.

|Type|Default|
|---|---|
|String|127.0.0.1|

Specifies a TCP/UDP address to transmit TenXObject instance/template field values.


### :material-menu-right-outline:**`outputSocketPort`**

Endpoint port number.

|Type|Default|
|---|---|
|String|9000|

Specifies the port number  (e.g., 9000) of the endpoint to transmit data to.


### :material-menu-right-outline:**`outputSocketFields`**

List of TenXObject field names to encode.

|Type|Default|
|---|---|
|List|\[\]|

Specifies a list of TenXObject intrinsic/calculated/extracted field names to extract and write to the output.


### :material-menu-right-outline:**`outputSocketFilter`**

A JavaScript expression an TenXObject must evaluate as 'truthy' against to be written to this output.

|Type|Default|
|---|---|
|String|""|

Specifies a JavaScript expression that an TenXObject must evaluate as truthy to write its
instance/template field values to this output.
For example, 'outputSocketFilter: this.timestamp' will only emit \[timestamped\]https://doc.log10x.com/api/js/#TenXBaseObject+timestamped) TenXObjects.


### :material-menu-right-outline:**`outputSocketWriteObjects`**

If true, encode TenXObjects \[outputSocketFields\](https://doc.log10x.com/run/output/event/socket/#outputsocketfields) to this output.

|Type|Default|
|---|---|
|String|true|

Determine whether to write [outputSocketFields](https://doc.log10x.com/run/output/event/socket/#outputsocketfields "list of TenXObject field names to encode") values of an TenXObject passed to this output.
This configuration is typically defined using a JavaScript expression.

To enable/disable the output depending on whether a launch argument, environment variable,
or JVM -D option evaluates as truthy, use:

```yaml
  outputSocketWriteObjects: $=TenXEnv.get("myTCPAddress")
```

To learn more see [TenXEnv.get](https://doc.log10x.com/api/js/#TenXEnv.get).


### :material-menu-right-outline:**`outputSocketWriteTemplates`**

If true, write new TenXTemplates to this output.

|Type|Default|
|---|---|
|String|false|

Controls whether to write template values of TenXObjects passed to this output.
The output will only emit TenXTemplates that the pipeline did not load at startup via the [templateFile](https://doc.log10x.com/run/template/#templatefiles "input files or glob patterns containing JSON-encoded TenXTemplates") argument,
and will only emit an TenXTemplate once based on its [templateHash](https://doc.log10x.com/api/js/#TenXBaseObject+templateHash "An alphanumeric encoded value of a 64bit hash of the current object's template field.") value.


### :material-menu-right-outline:**`outputSocketEncodeType`**

The output format in which to encode TenXObject values. Possible values:\[json, delimited\].

|Type|Default|
|---|---|
|String|delimited|

Specifies how to encode [outputSocketFields](https://doc.log10x.com/run/output/event/socket/#outputsocketfields "list of TenXObject field names to encode") values to this output. Possible values:

- **json**: formats names and values for the current TenXObject as: {"field":"str","field2":1, "field3": true}
- **delimited**: formats values for the current TenXObject as: "str",1,true
  The [outputSocketEncodeDelimiter](https://doc.log10x.com/run/output/event/socket/#outputsocketencodedelimiter "the delimiter placed between key and values pairs if 'outputSocketEncodeType' is 'delimited'") argument determines the separator to use.


### :material-menu-right-outline:**`outputSocketEncodedLinePrefix`**

The line prefix prepended to the encoded event if 'outputSocketEncodeType' is 'delimited'.

|Type|Default|
|---|---|
|String||

Sets the char which is prepended to the emitted TenXObject field values when [outputSocketEncodeType](https://doc.log10x.com/run/output/event/socket/#outputsocketencodetype "the output format in which to encode TenXObject values. Possible values:[json, delimited]") is `delimited`.


### :material-menu-right-outline:**`outputSocketEncodeDelimiter`**

The delimiter placed between key and values pairs if 'outputSocketEncodeType' is 'delimited'.

|Type|Default|
|---|---|
|String| |

Sets the char delimiter to separate TenXObject field values when [outputSocketEncodeType](https://doc.log10x.com/run/output/event/socket/#outputsocketencodetype "the output format in which to encode TenXObject values. Possible values:[json, delimited]") is `delimited`.


<br/>:material-github: This module is defined in [socket/module.yaml](https://github.com/log-10x/modules/tree/main/pipelines/run/modules/output/event/socket/module.yaml "socket/module.yaml"){target="\_blank"}.

