Document toolboxDocument toolbox

To Float (float)

Description

Converts a valid number string or an integer into a float number. 

You can also extract a float value from a json (json data type) using the Jq evaluation (jqeval) operation and convert it into float type.

How does it work in the search window?

Select Create column in the search window toolbar, then select the To Float operation. You need to specify one argument:

Argument

Data type

Argument

Data type

String to convert / Integer to convert / Json to convert mandatory

string, integer, json

The data type of the values in the new column is float.

Example 1

In the siem.logtrust.web.activity table, we want to transform the values in our bytesTransferred column (integer) into float format. To do it, we will create a new column using the To Float operation.

The arguments needed to create the new column are:

  • Integer to convert - bytesTransferred column

 

Click Create column and you will see the following result:

Example 2

We have the following JSON string:

{"str": "hello", "int": 1, "float": 2.5, "boolean": true, "array": [1,2,3], "object": {"a": 5}}

And we want to extract the float value in it in a new column and convert it to float data type. To do it, the first step is transforming the string into a json data type column, and then using the Jq evaluation (jqeval) operation to extract the float parts from the JSON objects.

Step 1: Transform the JSON string into json data type

We use the To json (jsonparse) operation and enter the JSON string we want to use to get a column representing it in json data type.

Step 2: Extract the float value from the JSON objects

Then, we use the Jq evaluation (jqeval) operation to extract the float part of the JSON objects in a new column, in json data type. These are the required arguments:

  • jq -  Click the pencil icon and enter .float

  • json - json column

 

Step 3: Transform the float values into float data type

Finally, we use the To float operation to transform the float representations in json data type into float data type. 

 

Click Create column and you will see the following result:

How does it work in LINQ?

Use the operator select... as...  and add the operation syntax to create the new column. These are the valid formats of the To Float operation:

  • float(number_string)

  • float(integer)

  • float(json_float)

Example 1

You can copy the following LINQ script and try the first example explained above on the siem.logtrust.web.activity table. 

from siem.logtrust.web.activity select float(bytesTransferred) as bytestransferred_Float

Example 2

You can copy the following LINQ script and try the second example explained above on the siem.logtrust.web.activity table. 

from siem.logtrust.web.activity select jsonparse("{\"str\": \"hello\", \"int\": 1, \"float\": 2.5, \"boolean\": true, \"array\": [1,2,3], \"object\": {\"a\": 5}}") as json, jqeval(jqcompile(".float"), json) as jsonFloat, float(jsonFloat) as float