How to display line chart from elasticsearch db with field value

Hello,

I am new to grafana, I have following sample documents stored in Elasticsearch:
{
“sales”: [
{
“jobtype”: “daily”,
“salescount”: 10,
“customerCount”: 2,
“salesperCustomer”: 5,
“ts”: 1499644800000
},
{
“jobtype”: “daily”,
“salescount”: 13,
“customerCount”: 11,
“salesperCustomer”: 1.1,
“ts”: 1499644800000
},
{
“jobtype”: “daily”,
“salescount”: 8,
“customerCount”: 2,
“salesperCustomer”: 4,
“ts”: 1499644800000
},
{
“jobtype”: “daily”,
“salescount”: 7,
“customerCount”: 2,
“salesperCustomer”: 3.5,
“ts”: 1499644800000
}
]
}

I want to display timeline with salesperCustomer value. ex line chart for 5, 1.1, 4, 3.5 as points.

Please suggest me how to configure this in grafana

In the metric field change Count to Average and in field selector select salesperCustomer

I tried that but it does not showing exact value as per in sample documents,ex line chart for 5, 1.1, 4, 3.5 as points but the avg value as per timeline.

should show the exact value unless there are more than one document in the group by time interval of the date histogram

Hi Torkel,

There are instances in my case that it is ok to get the average of values if the time interval is not periodic. However, there are cases that I need to respect the value of each sample contained in elastic search.
So the question is:
Let’s say we have the following documents in elastic search:

{"_id":“AWGu27aDWpfbOL8lDi_2”,"_type":“stats”,"_index":“ingest”,"@timestamp":[1518611201020],“count”:“176613”,“version”:“3.18.1”}

{"_id":“AWGu26_0WpfbOL8lDi_p”,"_type":“stats”,"_index":“ingest”,"@timestamp":[1518611202050],“count”:“1”,“version”:“3.18.1”}

{"_id":“AWGu27SGWpfbOL8lDi_y”,"_type":“stats”,"_index":“ingest”,"@timestamp":[1518611207000],“count”:“41854”,“version”:“3.18.1”}

As you could see each “@timestamp” does not show any periodicity.
How can I create a time series graph in elastic search where each timestamp and count value is respected and plotted in the graph?
This is possible using data sources like prometheus but I have not been able to make it work if the data source is Elastic Search.
Is this possible in grafana using ES data source?

Thanks for your help.

a group by date histogram will do the trick

Thanks Torkel.
The issue is that there is more than one document in the time interval.

why is that an issue? you aggregate using Count, Avg, etc

I think it is an issue because the timestamp of the documents are not periodic. So, grouping by date histogram may not reflect the intended result which is rendering the value of count for each time stamp.