Double
less than a minute
The Double converter converts a given value to a double precision floating point type (float64). Use Int when you need whole numbers (e.g., status codes, counts). Use Double when dealing with measurements that may require precision or when the input might be a floating point number (e.g., time durations, temperatures).
Syntax: Double(value)
- value: the bracket notation location of the field to convert.
Value types:
- float64: Returns the value without changes.
- string: Tries to parse a double from the string; returns nil if the parsing fails.
- bool: Returns 1.0 if true, 0.0 if false.
- int64: Converts the integer to a double.
Input
{
"_type": "log",
"attributes": {
"latency": "1025.9658"
},
"body": "2024-12-11T03:26:54.681811Z Successful NotificationService:229 request api_request spec:{uri:/api/v1/order method:POST latency:1025ms}",
"resource": {...},
"timestamp": 1733889840195
}
Statement
set(attributes["latency_int"], Double(attributes["latency"]))
Output
{
"_type": "log",
"attributes": {
"latency": "1025.9658",
"latency_int": 1025.9658
},
"body": "2024-12-11T03:26:54.681811Z Successful NotificationService:229 request api_request spec:{uri:/api/v1/order method:POST latency:1025ms}",
"resource": {...},
"timestamp": 1733889828934
}
The latency string "1025.9658" was converted to a double 1025.9658.