Indexing day of week


#1

Hi,

I have recently started to work with kibana . I am running kibana from server.
I have timestamp filed in my dataset which format is "YYYY-MM-DD HH:MM:SS".
I want to have visualization based on "Day Of Week" in kibana. But I don't know
how to index day-of-week as a separate field in Elasticsearch and use it in kibana.

Would you please help me with this?


(Matt Bargar) #2

This should be easy to accomplish :slight_smile:

Just create a visualization with a date histogram with the Interval set to Daily. It should look like this:


#3

Actually, this is not what I mean. For example, there is a data set about sales of a branch of famous brand . Each log contains information about date of sale , item, price, address of branch ,...... We want to see changes in amount of sale for each day of week during specific period of time (last three months) and for instance, finding the day in which average of sales is the highest compared to the other days in week. In this case, we can have a good vision over different days in week.


#4

Consult this doc:
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#_lucene_expressions_scripts

It appears that day of month is in, but it doesn't look like day of week is. It's a bit frustrating. I'd be curious to know whether there was a good reason to leave it out.

Anyway, the good news is that you can use logstash to enrich your documents with a Day of Week field on the way in. See this thread:
https://groups.google.com/d/msg/logstash-users/uZVFwOpBHTI/iDV-GoeUZMEJ


(alainc) #5

i also found this but not tested right now


(Matt Bargar) #6

Sorry for the misunderstanding. As the others have implied, I don't think this is currently possible without re-indexing the data. As tomr mentioned, logstash would be a good option.

Elasticsearch is also working on a new, more powerful (than Lucene expressions) scripting language that will be secure and enabled by default. It won't be available until 5.0 and it looks like it might not support date math yet, but I know the ES folks would love to get feedback about what features they should add next. This scripting language will probably be the easiest option for implementing things like this in the future.


(system) #7