# Query for anomaly explorer visualization

**URL:** <https://discuss.elastic.co/t/query-for-anomaly-explorer-visualization/270784>\
**Category:** Kibana\
**Created:** [April 21, 2021, 5:09am UTC](https://discuss.elastic.co/t/query-for-anomaly-explorer-visualization/270784 "2021-04-21T05:09:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ElasticLiver](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticliver/32/64869_2.png) [@ElasticLiver](https://discuss.elastic.co/u/ElasticLiver)\
**Post date:** [April 21, 2021, 5:09am UTC](https://discuss.elastic.co/t/query-for-anomaly-explorer-visualization/270784/1 "2021-04-21T05:09:46Z")

</div>

Hi Im trying to emulate the anomaly explorer in a vega visualization, at first I think that a top hit agreggation will get me similar results, like this query:

```auto
POST /.ml-anomalies-*/_search
{
  "size": 0, 
  "aggs": {
    "top_score": {
      "top_hits": {
        "sort": [
          {
            "record_score": {
              "order": "desc"
            }
          }
        ],
        "_source": {
          "includes": [
            "actual",
            "typical",
            "partition_field_value",
            "record_score",
            "timestamp",
            "by_field"
          ]
        },
        "size": 10
      }
    }
  }
}

```

but after seeing this anomaly explorer for a job, I realize that is more than just a top hit aggregation

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/c/5cdc9062ac78744c197a3ae0ad48881c06953c85.png)

what will be the query to obtain similar results and display them in vega?

---

<div class="post-metadata">

**Author:** ![darnautov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/darnautov/32/70608_2.png) [@darnautov](https://discuss.elastic.co/u/darnautov)\
**Post date:** [April 28, 2021, 11:42am UTC](https://discuss.elastic.co/t/query-for-anomaly-explorer-visualization/270784/2 "2021-04-28T11:42:17Z")

</div>

Hey @ElasticLiver,

First, may I ask what elastic stack version you're using? Since `7.8` we provide the [anomaly swim lane embeddable](https://github.com/elastic/kibana/pull/64056) and since `7.9`, you can [attach to the dashboard](https://github.com/elastic/kibana/pull/68784) directly from the Anomaly Explorer page.

If you still prefer to write a query manually, it depends on the anomaly results you are interested in. Is it the Overall swim lane, View by an influencer, or View by job id?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 26, 2021, 11:42am UTC](https://discuss.elastic.co/t/query-for-anomaly-explorer-visualization/270784/3 "2021-05-26T11:42:20Z")

</div>

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