Doc count per day and avearge

hello everyone

is it possible to get the number of documents that we have in our index per day? and then, after getting that (which I have already done) get the average of that, ie doc_count per day.

I aim to integrate it into a vega kibana visualization, can you help me with that too?

Thanks in advance!

hi there ,

i don't know much about vega but other than that can be done using aggregation . for your understanding i am giving example so take it as reference:


GET indexname/_search?size=0
{
  "aggs": {
    "hist": {
      "date_histogram": {
        "field": "date",
        "interval": "day"
      },
      "aggs": {
        "count": {
          "value_count": {
            "field": "date"
          }
        }
      }
    },
    "avg": {
      "avg_bucket": {
        "buckets_path": "hist>count"
      }
    }
  }
}

I hope it will help you ...you might find better way too ...If you find you can replay with another solutions.

Thank you very much for your answer, it's exactly what I wanted!

Now I'm trying to adapt it for a Vega visualization, the result I want is a graph over time of the documents I have, with an overlay of the average of my documents, a straight line that intersects my curve.

If someone can help me, I'd be happy !

1 Like

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