# Using a string value (multistate) as Y-Axis

**URL:** <https://discuss.elastic.co/t/using-a-string-value-multistate-as-y-axis/66120>\
**Category:** Kibana\
**Created:** [November 15, 2016, 1:15pm UTC](https://discuss.elastic.co/t/using-a-string-value-multistate-as-y-axis/66120 "2016-11-15T13:15:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Myllka](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/myllka/32/13205_2.png) [@Myllka](https://discuss.elastic.co/u/Myllka)\
**Post date:** [November 15, 2016, 1:15pm UTC](https://discuss.elastic.co/t/using-a-string-value-multistate-as-y-axis/66120/1 "2016-11-15T13:15:10Z")

</div>

Hi everyone,

I'm new at using Kibana and I need some help.  
I managed to create some graphics with my datas from Logstash/Elasticsearch (like how many of certain type of message by day), but I'm now stuck with one graphic I need :  
The point is to see the evolution of a multistate data (saved as a string in Kibana). This one has 3 states possible, but I can't find a way to use it as an Y-Axis.  
Before Kibana, I used some Excel files to create the graph, and I had to convert the string into an integer (so 0, 1 or 2) and then rename the value in the graphic (but that wasn't really that).  
Is there a similar way in Kibana or do I need to create the field in Logstash ? Or even better, is there a direct way to use the string in Kibana ?

If you need more details about what I want, please ask. And sorry for my poor english if I made mistakes !

Thank you !

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [November 15, 2016, 10:24pm UTC](https://discuss.elastic.co/t/using-a-string-value-multistate-as-y-axis/66120/2 "2016-11-15T22:24:52Z")

</div>

Hi Myllka,

I'm not sure what kind of chart you are trying to create. There's a vertical bar chart. What would be on the X-Axis, time?  
Maybe you can post a screenshot of your Excel chart if you still have something like it?

Regards,  
Lee

---

<div class="post-metadata">

**Author:** ![Myllka](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/myllka/32/13205_2.png) [@Myllka](https://discuss.elastic.co/u/Myllka)\
**Post date:** [November 16, 2016, 7:54am UTC](https://discuss.elastic.co/t/using-a-string-value-multistate-as-y-axis/66120/3 "2016-11-16T07:54:40Z")

</div>

Sure, here it is:

I have another issue with the same graph, can't I put 2 fields to the split lines to have Server + Service or do I need to create a merged field in Logstash too ?

Thanks.

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [November 16, 2016, 11:42pm UTC](https://discuss.elastic.co/t/using-a-string-value-multistate-as-y-axis/66120/4 "2016-11-16T23:42:54Z")

</div>

I think to show those values on the Y-Axis you would have convert them to numbers. If you're on Elasticsearch and Kibana 5.0 you can use scripted fields in Kibana with the Painless language. I made one scripted field with this script;

```auto
if (doc['name.keyword'].value == "a") return 1;
if (doc['name.keyword'].value == "b") return 2;
if (doc['name.keyword'].value == "c") return 3;
if (doc['name.keyword'].value == "d") return 4;
return 0;

```

Note that the fields you use like my `name.keyword` above can not be analyzed strings. If they are strings that have to be keywords.

Or maybe you can use filters, but I don't think you can get the chart to show the string values on the y-axis. In the chart below you see I've added filters for a field geo.dest equaling a certain value. And then I'm getting the count.

 ![](https://us1.discourse-cdn.com/elastic/original/2X/8/87e314c4232e0a5f1826f937a9185d13c60789b6.png)

You can also concatenate or doing other string manipulation with Painless scripted fields.  
Let me know if you need help with that.

Regards,  
Lee

---

<div class="post-metadata">

**Author:** ![Myllka](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/myllka/32/13205_2.png) [@Myllka](https://discuss.elastic.co/u/Myllka)\
**Post date:** [November 17, 2016, 8:44am UTC](https://discuss.elastic.co/t/using-a-string-value-multistate-as-y-axis/66120/5 "2016-11-17T08:44:34Z")

</div>

Yes I am on 5.0. I created 2 scripted fields and it seems to have the value I expected. That will be usefull thank you !  
But your example don't work for my case. The closer look I had is this:

That's look pretty good, but 2 things bother me:  
-the view from a big time period, I would like to see the current state at every moment for every server, but my logs only report changes of state. Is there a way to "keep" the last value I missed ? Maybe some kind of dynamic log with the Painless script ?  
-this Y-Axis, can I edit it to replace the integer value like I did Excel ? Maybe this json input, I know nothing about it. And can I change the scale interval ?

Thank you.

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [November 17, 2016, 3:08pm UTC](https://discuss.elastic.co/t/using-a-string-value-multistate-as-y-axis/66120/6 "2016-11-17T15:08:05Z")

</div>

Here's 2 things you could try;

1). The Advanced JSON Input you mentioned. I do have this example where each doc had a start time and a duration in sections and the user wanted the chart to the totals of everything active at any particular time. So this user could pad the data based on information in each document. Your case is different in that each doc changes a state and doesn't have any information on when the next state change happens. But here's the example;

> [@Display concurrency in data on Kibana](https://discuss.elastic.co/t/display-concurrency-in-data-on-kibana/26006):
>
> I have fields with start date and duration (seconds) representing start and duration of a phone call. I would like to define concurrency (a number) when the same destination (also a field) is active within the same duration. That is if a ncall starts now for 30 seconds and another call to the same destination starts 15 seconds into the first call, concurrency should be 2 for the remaining 15 seconds. How do I define this in Kibana visualization as a line graph over time?

2). Have you tried Timelion? It was a plugin but is now built in to Kibana. It has a `derivative` function that might work with your change of state type data.  
Check out; [Timelion: The time series composer for Kibana | Elastic Blog](https://www.elastic.co/blog/timelion-timeline)  
And; [Timelion | Kibana Guide [8.11] | Elastic](https://www.elastic.co/guide/en/kibana/current/timelion.html)

Regards,  
Lee

---

<div class="post-metadata">

**Author:** ![Myllka](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/myllka/32/13205_2.png) [@Myllka](https://discuss.elastic.co/u/Myllka)\
**Post date:** [November 21, 2016, 8:46am UTC](https://discuss.elastic.co/t/using-a-string-value-multistate-as-y-axis/66120/7 "2016-11-21T08:46:07Z")

</div>

I gave a look at both solution, but honestly it's pretty for someone knowing nothing about it !  
I searched for some syntax base and I found [this](https://www.zingchart.com/docs/tutorials/chart-elements/configure-chart-scales/) for JSON, but seems not to work on Kibana.  
For Timelion, I'm totally lost !

So is there some kind of list of terms for these 2 options ?

---

<div class="post-metadata">

**Author:** ![tbragin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tbragin/32/45166_2.png) [@tbragin](https://discuss.elastic.co/u/tbragin)\
**Post date:** [December 13, 2016, 8:25pm UTC](https://discuss.elastic.co/t/using-a-string-value-multistate-as-y-axis/66120/8 "2016-12-13T20:25:50Z")

</div>

There is a built-in tutorial for Timelion right when you log in as well as a built in functional reference guide. There is also this video where Rashid walks you through the basics: [https://www.elastic.co/videos/timelion-plugin-for-kibana-enables-times-series-paris-meetup](https://www.elastic.co/videos/timelion-plugin-for-kibana-enables-times-series-paris-meetup)

Does this help?

---

<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:** [January 10, 2017, 8:26pm UTC](https://discuss.elastic.co/t/using-a-string-value-multistate-as-y-axis/66120/9 "2017-01-10T20:26:21Z")

</div>

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