How to sum the values in the column (bytes) and convert it GB?

Hey Folks,

I'm struggling to sum the value in record (bytes) and visualize it in table. Any idea how would i achieve the SUM and converted to GB?

image

image

You can't sum keyword fields, they need to be a numeric mapping. You can either re-map the field as a number, or you can use a runtime field to make a temporary copy of the keyword field to use as a number field. Sum aggregation | Elasticsearch Guide [8.6] | Elastic provides somewhat of an example of using a runtime field. Note: this method will be slower than using a natively mapped number field.

1 Like

Hello @maskrider1111

Use TSVB option instead of Lens, In TSVB u can choose Options and drop down menu under Data Formatter will be having Bytes. and in parallel column, you can divide or multiply to create GBs/MBs/ or TBs as per requirement

1 Like

@maskrider1111 what's the field type for the sentbyte and rcvdbyte? It looks like they are mapped as strings/keywords.

Perhaps a solution I could suggest is to create two runtime field for each of the two, when values are parsed as double (or any numeric type) and then apply a Sum operation in Lens.
The content of the runtime field can be the following:

if(!doc['sentbytes'].isEmpty()){
    emit(Integer.parseInt((doc['sentbytes'].value)))
}
2 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.