Hide weekends for date histogram field in time series in graph

Our application runs between Monday to Friday... and not on Saturday and Sunday.
We are creating a chart in Kibana and using the date histogram field for time series.
It is showing the weekends as well in the graph. somehow we want to hide weekends in the chart.

Note: The data stored in Elasticsearch is only in weekdays. i.e. Monday to Friday.

Kindly let us know if there is a way to do that in Kibana charts.

this is a workaround at best but could be an interesting option to try. Longer term answer below

Use a runtime field to emit the date as a string at the right granularity with the weekend logic. Use "Top Values" and rank by alphabetical


ZonedDateTime input = doc['@timestamp'].value;

String output = input.format(DateTimeFormatter.ofPattern('yyyy-mm-dd'));

emit(output);

I have groomed the existing request for this and added a quote / screenshot from this discussion for the longer term fix. [Lens] Time series only for weekdays · Issue #2942 · elastic/kibana · GitHub - I agree we should have native support for this in the date histogram.

I tried the workaround you have provided but it didn't work.

The data in the index is large, so it is taking a lot of time to compute top 100 values from timestamp-keyword.
I have changed the top 100 to top 7 as well but the chart refresh is taking around 2-3 mins for computing the values.

This solution will not work for me.

When I again reverted to date histogram, I am getting the results in 4-5 seconds.

Do let me know if there is any other approach for solving this.

  • Thanks

Note: Minor change in the Date Time pattern you have provided. it needs to be changed from yyyy-mm-dd to yyyy-MM-dd. (Though solution didn't fit for me). I am adding as a note here if someone wants to try it out.

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