Mapping of streamed data to activity event fields is performed by parser. To map a field value, you have to define field tag in parser configuration:
-
Attributes:
name- defines activity event field namelocator- defines location of data value from streamed data-
locator-type- defines type of attributelocator. Set of supported values:StreamPropIndexLabelRangeCacheActivityExpressionParserPropSystemPropEnvVariable
-
format- defines format type or representation that the value is expected to be in (e.g., binary, date/time string, decimal format, etc.). Set of supported values:base64BinaryhexBinarystringbytesany decimal or date-time format pattern, e.g.
#####0.000. Can be defined multiple date-time patterns delimited using|symbol.-
one of number type enumerators:
integer/int,long,double,float,short,byte,biginteger/bigint/bint,bigdecimal/bigdec/bdecandany.anywill resolve any possible numeric value out of provided string, e.g. string"30hj00"will result value30. It also allows defining casting mode, by adding prefix to number type enumerator (except enumeratorany):- default casting mode without prefix is
EXACT: numeric casting without significant value loss. In case number can't be cast to target type, original value is kept. -
~-APIcasting mode: numeric casting shall be performed using plain Java API and in some cases resulting significant value loss. -
^-UP_BOUNDcasting mode: if value can't be cast to target type, the closest upper bound type shall be used to maintain value without significant loss. Upper bound sequences:- For floating point numbers:
Float,Double,BigDecimal - For non-floating point numbers:
Byte,Short,Integer,Long,Float,Double,BigInteger,BigDecimal
- For floating point numbers:
For example:
<field name="NumericCastExact" locator="number1" locator-type="Label" datatype="Number" format="long"/> <field name="NumericCastApi" locator="number1" locator-type="Label" datatype="Number" format="~long"/> <field name="NumericCastUpBound" locator="number1" locator-type="Label" datatype="Number" format="^int"/>
- default casting mode without prefix is
value- defines predefined (hardcoded) value of field-
datatype- defines how to interpret field resolved value. Set of supported values:StringBinaryNumberDateTimeDurationTimestampGenericAsInput
radix- for numeric values, defines the radix that the value is specified in (ignored if format is specified)-
units- defines the units of value to be represented. Set of supported values:DaysHoursMinutesSecondsMillisecondsMicrosecondsNanoseconds
timezone- defines the time zone that a date/time string is represented in (when not specified, date/time string is assumed to be in local time zone)locale- defines locale for data formatter to userequired- indicates whether a non-null value resolution is required for this field. If present, it takes precedence over the parser propertyRequireDefault.id- field identifierunwrapSingleValue- flag indicating an item value shall be unwrapped if array or collection containing single item.charset- defines a Java supported charset/encoding name (in string format) for field Raw binary data; used to convert between Unicode and a number of other character encodings. Default value is the running streams JVM default charset (in most casesUTF8).-
emptyAsNull- flag indicating an "empty" parser resolved value, e.g.:- string
"" -
0-size array/collection, - array/collection having all
nullor""elements
shall be treated as
nullvalue, and consequently not added to produced activity entity values set. In most cases, some initialized object having no "payload" - is "useless" same way as it is not defined at all (equalsnull). Default value -true. - string
-
Tags:
-
field-map- tag is used to perform manual mapping from streamed data valuesourceto field valuetarget.
-
Sample:
<parser name="TokenParser" class="com.jkoolcloud.tnt4j.streams.parsers.ActivityTokenParser">
<.../>
<field name="StartTime" locator="1" format="dd MMM yyyy HH:mm:ss" locale="en-US"/>
<field name="ServerIp" locator="2"/>
<field name="ApplName" value="orders"/>
<field name="Correlator" locator="3"/>
<field name="UserName" locator="4"/>
<field name="EventName" locator="5"/>
<field name="EventType" locator="5">
<field-map source="Order Placed" target="START"/>
<field-map source="Order Received" target="RECEIVE"/>
<field-map source="Order Processing" target="OPEN"/>
<field-map source="Order Processed" target="SEND"/>
<field-map source="Order Shipped" target="END"/>
</field>
<field name="MsgValue" locator="8"/>
</parser>Predefined Fields Set
/**
* Name of application associated with the activity.
*/
ApplName(String.class),
/**
* Host name of server to associate with activity.
*/
ServerName(String.class),
/**
* IP Address of server to associate with activity.
*/
ServerIp(String.class),
/**
* Name to assign to activity entry. Examples are operation, method, API call, event, etc.
*/
EventName(String.class),
/**
* Type of activity - value must match values in {@link com.jkoolcloud.tnt4j.core.OpType} enumeration.
*/
EventType(Enum.class),
/**
* Status of activity - value must match values in {@link com.jkoolcloud.tnt4j.core.ActivityStatus} enumeration.
*/
EventStatus(Enum.class),
/**
* Time action associated with activity started.
*/
StartTime(UsecTimestamp.class),
/**
* Time action associated with activity ended.
*/
EndTime(UsecTimestamp.class),
/**
* Elapsed time of the activity in microseconds.
*/
ElapsedTime(Long.class),
/**
* Identifier of process where activity event has occurred.
*/
ProcessId(Integer.class),
/**
* Identifier of thread where activity event has occurred.
*/
ThreadId(Integer.class),
/**
* Indicates completion status of the activity - value must match values in {@link com.jkoolcloud.tnt4j.core.OpCompCode} enumeration.
*/
CompCode(Enum.class),
/**
* Numeric reason/error code associated with the activity.
*/
ReasonCode(Integer.class),
/**
* Error/exception message associated with the activity.
*/
Exception(String.class),
/**
* Indicates completion status of the activity - value can either be label from {@link com.jkoolcloud.tnt4j.core.OpLevel} enumeration
* or a numeric value.
*/
Severity(Enum.class),
/**
* Location that activity occurred at.
*/
Location(String.class),
/**
* Identifier used to correlate/relate activity entries to group them into logical entities.
*/
Correlator(String[].class),
/**
* User-defined label to associate with the activity, generally for locating activity.
*/
Tag(String[].class),
/**
* Name of user associated with the activity.
*/
UserName(String.class),
/**
* Name of resource associated with the activity.
*/
ResourceName(String.class),
/**
* User data to associate with the activity.
*/
Message(String.class),
/**
* Identifier used to uniquely identify the data associated with this activity.
*/
TrackingId(String.class),
/**
* Length of activity event message data.
*/
MsgLength(Integer.class),
/**
* MIME type of activity event message data.
*/
MsgMimeType(String.class),
/**
* Encoding of activity event message data.
*/
MsgEncoding(String.class),
/**
* CharSet of activity event message data.
*/
MsgCharSet(String.class),
/**
* Type of log entry.
*/
LogType(String.class),
/**
* Age of activity event message.
*/
MessageAge(Long.class),
/**
* Activity event category name.
*/
Category(String.class),
/**
* Identifier used to uniquely identify parent activity associated with this activity.
*/
ParentId(String.class),
/**
* Identifier used to globally identify the data associated with this activity.
*/
Guid(String.class),
/**
* Stream activity entity time-to-live attribute.
*/
TTL(Long.class);
EventType field is mandatory and
can't have value null. If this field value resolves to null,
then streams automatically sets value to EVENT.
Custom field values can be found as activity event properties:
Sample:
<field name="Transport" locator="ActivityTransport" locator-type="Label"/> <field name="Topic" locator="TopicName" locator-type="Label"/>
Field Locator Types
/**
* Indicates that raw data value is the value of a named property of the current stream.
*/
StreamProp(String.class),
/**
* Indicates that raw data value is at a specified index location, offset, etc. This is a generic index/offset value whose
* interpretation is up to the specific parser applying the locator. It also can be index of RegEx group.
*/
Index(Integer.class),
/**
* Indicates that raw data value is the value of a particular key or label. Examples of this are XPath expressions for XML elements,
* and where each element of a raw activity data string is a name/value pair. It also can be name of RegEx group.
*/
Label(String.class),
/**
* Indicates that raw data value is the value of a specific regular expression match, for parsers that interpret the
* raw activity data using a regular expression pattern defined as a sequence of repeating match patterns. Match
* identifier can be group sequence number or name.
*
* @deprecated use {@link #Label} instead.
*/
@Deprecated
REMatchId(String.class),
/**
* Indicates that data value is the value from stream stored cache with specified cache entry key.
*/
Cache(String.class),
/**
* Indicates that data value is the value from currently processed activity data entity with specified entity field name.
*/
Activity(String.class),
/**
* Indicates that data value shall be evaluated by using provided expression for parser context data.
*/
Expression(String.class),
/**
* Indicates that raw data value is the value of a named property of the current parser.
*/
ParserProp(String.class),
/**
* Indicates that raw data value is the value of a named JVM System property.
*/
SystemProp(String.class),
/**
* Indicates that raw data value is the value of a named OS Environment variable.
*/
EnvVariable(String.class);Index is default value and may be suppressed in field/locator definition:
this:
<field name="UserName" locator="4"/>
is the same as:
<field name="UserName" locator="4" locator-type="Index"/>
Obsolete (yet backward-compatible) locator types:
-
REGroupName- now should be changed toLabel -
REGroupNum- now should be changed toIndex -
REMatchId- now should be changed toLabel -
REMatchNum- now should be changed toIndex
Click here to learn more about TNT4J Events Field Mappings.