# \[KIBANA\] Customize the result of a metric in a Data Table Aggregation

**URL:** <https://discuss.elastic.co/t/kibana-customize-the-result-of-a-metric-in-a-data-table-aggregation/298311>\
**Category:** Kibana\
**Created:** [February 25, 2022, 6:37pm UTC](https://discuss.elastic.co/t/kibana-customize-the-result-of-a-metric-in-a-data-table-aggregation/298311 "2022-02-25T18:37:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sisiniya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sisiniya/32/101378_2.png) [@Sisiniya](https://discuss.elastic.co/u/Sisiniya)\
**Post date:** [February 25, 2022, 6:37pm UTC](https://discuss.elastic.co/t/kibana-customize-the-result-of-a-metric-in-a-data-table-aggregation/298311/1 "2022-02-25T18:37:12Z")

</div>

Hello,

In my application, each action generates a series of logs. For example :

**First suite of logs** for the same value of data1/data2/data3 :

```auto
{data1: "val1", data2: "val2", data3: "val3", level: "INFO", level_value: 2000, message: "init ....", ....}
{data1: "val1", data2: "val2", data3: "val3", level: "INFO", level_value: 2000, message: "check....", ....}
{data1: "val1", data2: "val2", data3: "val3", level: "ERROR", level_value: 4000, message: "save....", ....}

```

**Second suite of logs** for the same value of data1/data2/data3 :

```auto
{data1: "val1", data2: "val22", data3: "val3", level: "WARN", level_value: 3000, message: "init ....", ....}
{data1: "val1", data2: "val22", data3: "val3", level: "INFO", level_value: 2000, message: "save....", ....}

```

In order to present in kibana the number of logs generated for the triplet data1/data2/data3, I created a data aggregation table (Aggregation based) :

- 3 Buckets Rows : data1, data2, data3
- 1 Metrci : count that calculates the number of logs for this data triplet.

**For example :**

- First suite of logs : I have a line with 3 columns val1/val2/val3 and the metric which is 3
- Second suite of logs : I have a line with 3 columns val1/val22/val3 and the metric which is 2

**My objective** :

I want to display in this aggregation table, a new information "Status Log" which indicates if a series of logs contain an error or not, based on the "level" and "level\_value" data.

**Example of expected result :**

- First suite of logs : new column will display the text ERROR (because max(level\_value) equals 4000)
- Second suite of logs : new column will show text SUCCESS (because max(level\_value) is different from 4000)

If I use this new column as a metric, the only function I can apply is MAX on the "level\_value" field, but I can't introduce logic into the MAX metric like :

- If max(level.value) calculated is equal to 4000, then the metric displays "ERROR"
- Else, it displays "SUCCESS"

Is there a way to do my need?

Thank you very much in advance.

---

<div class="post-metadata">

**Author:** ![Marta\_Bondyra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_bondyra/32/102122_2.png) [@Marta\_Bondyra](https://discuss.elastic.co/u/Marta_Bondyra)\
**Post date:** [March 23, 2022, 7:39am UTC](https://discuss.elastic.co/t/kibana-customize-the-result-of-a-metric-in-a-data-table-aggregation/298311/2 "2022-03-23T07:39:59Z")

</div>

Hello, unfortunately, I don't think it's possible with Visualize tools. You might try experiment with Vega though, but it's not trivial. Here's some examples: [javascript - Custom label text in Vega chart - Stack Overflow](https://stackoverflow.com/questions/55765067/custom-label-text-in-vega-chart)  
[Conditional setting of values in VEGA (for gantt chart)](https://discuss.elastic.co/t/conditional-setting-of-values-in-vega-for-gantt-chart/266580)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 20, 2022, 7:40am UTC](https://discuss.elastic.co/t/kibana-customize-the-result-of-a-metric-in-a-data-table-aggregation/298311/3 "2022-04-20T07:40:50Z")

</div>

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