# Coloring Metric aggregation based on String

**URL:** <https://discuss.elastic.co/t/coloring-metric-aggregation-based-on-string/286821>\
**Category:** Kibana\
**Created:** [October 15, 2021, 10:17am UTC](https://discuss.elastic.co/t/coloring-metric-aggregation-based-on-string/286821 "2021-10-15T10:17:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cibot](https://avatars.discourse-cdn.com/v4/letter/c/bbe5ce/32.png) [@Cibot](https://discuss.elastic.co/u/Cibot)\
**Post date:** [October 15, 2021, 10:17am UTC](https://discuss.elastic.co/t/coloring-metric-aggregation-based-on-string/286821/1 "2021-10-15T10:17:30Z")

</div>

I have been trying to create a dashboard with relevant information for a service.  
As such we display logs, uptime over time, errors, current state and so on.  
To make it easy to indicate whether a service is down, I want to use colors.  
As such I've tried the following:

Go To Dashboard  
All Types -\> AGGREGATION BASED -\> Metric  
Metric: Top Hit  
Field: system.service.state  
Concatenate: 1

Now to achieve different coloring, there are OPTIONS which include coloring based on ranges.  
Is there a way to color based on value?  
System.service.state usually has something like 'active' or 'dead' and as such is there a way to define static coloring options?  
Maybe I can achieve something similar in a different way?  
I don't exactly know how the ranges here are exactly calculated but I always end up with red.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/c/9c5dbdeaaf9acbd3cb839892feec9fb52070ac99.png)

---

<div class="post-metadata">

**Author:** ![matw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matw/32/13913_2.png) [@matw](https://discuss.elastic.co/u/matw)\
**Post date:** [October 19, 2021, 6:28am UTC](https://discuss.elastic.co/t/coloring-metric-aggregation-based-on-string/286821/2 "2021-10-19T06:28:32Z")

</div>

Hi and welcome to our community

This is currently just possible using Vega in Kibana, and also I can't find a simple solution for this, you need to dig into Vega documentation.

> **[Condition](https://vega.github.io/vega-lite/docs/condition.html)**
>
> Vega-Lite - a high-level grammar for statistical graphics. Vega-Lite provides a higher-level grammar for visual analysis, comparable to ggplot or Tableau, that generates complete Vega specifications. Vega-Lite specifications consist of simple...

There might another work around using runtime fields

> **[Runtime fields | Elasticsearch Guide \[master\] | Elastic](https://www.elastic.co/guide/en/elasticsearch//reference/master/runtime.html)**

You could create a runtime field mapping strings to emojis, this need field you can use in your metric aggregation, and this way you can add some color to your metric ... it's not exactly what you're a looking for, but just wanted to highlight that this is possible:

 ![Bildschirmfoto 2021-10-19 um 08.25.15](https://us1.discourse-cdn.com/elastic/original/3X/f/d/fd5b6bf2a8d57e276e9629050ad59c3a264fcbf2.png)

> **[Runtime fields | Elasticsearch Guide \[master\] | Elastic](https://www.elastic.co/guide/en/elasticsearch//reference/master/runtime.html)**

Best,  
Matthias

---

<div class="post-metadata">

**Author:** ![matw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matw/32/13913_2.png) [@matw](https://discuss.elastic.co/u/matw)\
**Post date:** [October 19, 2021, 6:48am UTC](https://discuss.elastic.co/t/coloring-metric-aggregation-based-on-string/286821/3 "2021-10-19T06:48:47Z")

</div>

go another info for you. you can use the color field formatter for your task, it should work like this:

 ![Bildschirmfoto 2021-10-19 um 08.46.05](https://us1.discourse-cdn.com/elastic/original/3X/c/d/cd8f3efdfa6412a37f03459c5087dad4ae475c46.png)  
 ![Bildschirmfoto 2021-10-19 um 08.46.49](https://us1.discourse-cdn.com/elastic/original/3X/9/c/9cb30dc7d4334b32cd45086fb022d76f82bda268.png)

Hope this helps

---

<div class="post-metadata">

**Author:** ![Cibot](https://avatars.discourse-cdn.com/v4/letter/c/bbe5ce/32.png) [@Cibot](https://discuss.elastic.co/u/Cibot)\
**Post date:** [October 19, 2021, 8:14am UTC](https://discuss.elastic.co/t/coloring-metric-aggregation-based-on-string/286821/4 "2021-10-19T08:14:54Z")

</div>

Thanks for the replies.  
I tried to get into VEGA but I think I would need another month to fully understand everything there so that's not an option 😃

The second option I've already seen in some other post so that was my backup solution, but still thanks for pointing it out.  
It certainly is a solution but obviously not as neat / clean as the coloring mechanism in the metric itself, since it is much much smaller.  
It will still suffice for now though. Maybe separating each field based on the service will make this look better. Since I currently have 18 services in one block, I will have to create 18 separate blocks to check whether this looks better. Thank you anyway.

![image](https://us1.discourse-cdn.com/elastic/original/3X/8/4/8479d65db923642d810ade00771ae62ff0f8b379.png)

---

<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:** [November 16, 2021, 8:15am UTC](https://discuss.elastic.co/t/coloring-metric-aggregation-based-on-string/286821/5 "2021-11-16T08:15:27Z")

</div>

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