Hi All,
I was trying to use round function in my query
According to druid documentation:
round : round(x, y) would return the value of the x rounded to the y decimal places..
When using below query:
"type" : "expression",
"name" : "VIRTUALKPI_NodeB_C_15",
"expression" : "100*((NodeB_C_2)/(NodeB_C_1))",
"outputType" : "DOUBLE"
Results were:
{
"version" : "v1",
"timestamp" : "2019-07-02T12:00:00.000Z",
"event" : {
"NodeB_C_1" : 3724.0,
"NodeB_P_1" : "EER",
"VIRTUALKPI_NodeB_C_15" : 98.09344790547799,
"COUNTER_GROUP_ID" : "NodeB_CG_31",
"NodeB_C_2" : 3653.0
}
}, {
"version" : "v1",
"timestamp" : "2019-07-02T12:15:00.000Z",
"event" : {
"NodeB_C_1" : 4093.0,
"NodeB_P_1" : "EER",
"VIRTUALKPI_gNodeB_C_15" : 99.12044954800879,
"COUNTER_GROUP_ID" : "NodeB_CG_31",
"NodeB_C_2" : 4057.0
}
}
when i tried round function:
"type" : "expression",
"name" : "VIRTUALKPI_NodeB_C_15",
"expression" : "round(100*((NodeB_C_2)/(NodeB_C_1)),6)",
"outputType" : "DOUBLE"
I got Exception :
{
"error" : "Unknown exception",
"errorMessage" : "Function[round] needs 1 argument",
"errorClass" : "org.apache.druid.java.util.common.IAE",
"host" : null
}
So i tried modifying query to be:
"type" : "expression",
"name" : "VIRTUALKPI_NodeB_C_15",
"expression" : "round(100*((NodeB_C_2)/(NodeB_C_1))*1000)/1000",
"outputType" : "DOUBLE"
The results were:
{
"version" : "v1",
"timestamp" : "2019-07-02T12:00:00.000Z",
"event" : {
"NodeB_C_1" : 3724.0,
"NodeB_P_1" : "EER",
"VIRTUALKPI_NodeB_C_15" : 98,
"COUNTER_GROUP_ID" : "NodeB_CG_31",
"NodeB_C_2" : 3653.0
}
}, {
"version" : "v1",
"timestamp" : "2019-07-02T12:15:00.000Z",
"event" : {
"NodeB_C_1" : 4093.0,
"NodeB_P_1" : "EER",
"VIRTUALKPI_NodeB_C_15" : 99,
"COUNTER_GROUP_ID" : "NodeB_CG_31",
"NodeB_C_2" : 4057.0
}
}
Can anyone please help me in getting round off values to 3 decimal places.
Thanks in Advance.
Amit Kumar