Exclude weekends(Saturdays and Sundays) from my dashboard view

I am using ELK – 7.12.1 version and currently I am looking for a way to filter-out the weekends(Saturdays and Sundays) from my dashboard view.

On my Dashboard I have (Vertical Bar, Line, Data table, Pie & Gauge) chart visualizations. From all these I would want to filter out the weekends. Basically I want to exclude weekends from dashboard, So is it possible to do that?

If so please let me know the ways to achieve the same. Thanks in advance.

One way to achieve this is to create a scripted field.
For example, the scripted field will return 1 for weekdays and 0 for weekends.
Then filter the dashboard for documents that have 1 and not 0.
Good luck!

1 Like

Ok Aclerk thanks for the pointer. the below is my scripted field.

Name: filter-weekend
Language: painless
Type: number
Format: Default
Popularity: 0
Script: doc['timestamp'].value.getDayOfWeekEnum()

**Preview Result:-**
[
 {
  "_id": "38009464",
  "filter-weekend": [
   "FRIDAY"
  ]
 },
 {
  "_id": "38026158",
  "filter-weekend": [
   "FRIDAY"
  ]
 },
 {
  "_id": "38030065",
  "filter-weekend": [
   "FRIDAY"
  ]
 },
 {
  "_id": "38035442",
  "filter-weekend": [
   "SATURDAY"
  ]
 },
 {
  "_id": "37688636",
  "filter-weekend": [
   "SATURDAY"
  ]
 },

With this still i can see the weekends(Saturday and Sunday).

I would use int getDayOfWeek() and not enum.
Secondly, How did you get Preview Result:-? where is your filter?

doc['timestamp'].value.getDayOfWeek()

Preview result:-

[
 {
  "_id": "38009464",
  "filter-weekend": [
   5
  ]
 },
 {
  "_id": "38026158",
  "filter-weekend": [
   5
  ]
 },
 {
  "_id": "38030065",
  "filter-weekend": [
   5
  ]
 },
 {
  "_id": "38035442",
  "filter-weekend": [
   6
  ]
 },

With the above code it prints days in numbers but still i can see 6 Saturday. My preview result filter is timestamp.

What did you run to get these results?
This is what you should run, as to my understanding (need syntax validation)

GET /my-index/_search
{
  "query": {
    "bool": {
      "filter": [
        { "term": { "filter-weekend": "6"   }},
        { "term": { "filter-weekend": "7" }}
      ]
    }
  }
}

or should be 1 & 7? please validate...

Kibna > Stack Management > Index Patterns > My-index > scripted fields here after filling the fields i am checking in preview result section.

Great.
Now use this filed, as mentioned previously

Vertical Bar
Y-axis
Aggregation: Count

Buckets
X-axis
Aggregation: Filters
Filter-1: filter-weekend

This way i need to achieve this?

I think you should use it in the search bar
image

Thank you so much Aclerk, i was trying to create a new visualization with newly created scripted field(filter-weekend), With your continues help and in my existing dashboard itself with the created scripted field able to create a filter in search bar and now weekends has been excluded. Thanks a lot once again.

1 Like

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