Vega and Kibana - Dynamic timestamp label and filtered queries
Asked Answered
P

0

14

I am working with my first Vega visualization with Kibana.

{
  $schema: https://vega.github.io/schema/vega-lite/v2.json
  title: Event counts from all indexes

  data: {
    url: {

      %context%: true
      %timefield%: last_submission

      index: test_info

      body: {
        aggs: {
          time_buckets: {
            date_histogram: {

              field: last_submission
              interval: {%autointerval%: true}
              extended_bounds: {
                min: {%timefilter%: "min"}
                max: {%timefilter%: "max"}
              }

              min_doc_count: 0
            }
          }
        }
        size: 0
      }
    }
    format: {property: "aggregations.time_buckets.buckets"}
  }

  mark: line

  encoding: {
    x: {
      field: key
      type: temporal
      axis: {title: false} 
    }
    y: {
      field: doc_count
      type: quantitative
      axis: {title: "Document count"}
    }
  }
}

visualization result

I have two questions here.

1 - As the visualization is linked to the Kibana dashboard, the user can choice different time windows from the main dashboard. As you can see the labels have always the full format. I need to set dynamically the label based on the time windows. That is, show only hours if the user choose day data, show days if the user choose weekly data and so on. What I need to do?

2- I need to filter the events basing on a particular value of a field and use the time windows of the main dashboard. Is that possible? I have tried adding the query filter here in the Vega code, but if I also have the context and timefield set I have this error:

url.%context% and url.%timefield% must not be used when url.body.query is set

Picaresque answered 7/3, 2019 at 14:47 Comment(2)
For the second point, since you care about the context, why not simply adding a filter (located just below the search box)?Calutron
I am also trying to use dashboard's time windows to select my time range. Any luck?Hunchback

© 2022 - 2024 — McMap. All rights reserved.