# Vega-lite invalid spec error

**URL:** https://discuss.elastic.co/t/vega-lite-invalid-spec-error/254706
**Category:** Kibana
**Created:** [November 9, 2020, 5:50am UTC](https://discuss.elastic.co/t/vega-lite-invalid-spec-error/254706 "2020-11-09T05:50:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![smruthip](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@smruthip](https://discuss.elastic.co/u/smruthip)
#### Post date: [November 9, 2020, 5:50am UTC](https://discuss.elastic.co/t/vega-lite-invalid-spec-error/254706/1 "2020-11-09T05:50:23Z")

</div>

I am just trying to do a simple count of all container\_id 's for every state in vega-lite and it thorws an error as invalid spec. What am I doing wrong here?

```auto
{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
  "title": "Event counts from all indexes",
  "data": {
    "url": {
      "index": "my_index",
      "body": {
        "mark": "bar",
        "encoding": {
          "x": {"field": "currDetails_state"},
          "y": {"aggregate": "distinct", "field": "currDetails_container_id.keyword", "type": "quantitative"}
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![monfera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/monfera/32/26467_2.png) [@monfera](https://discuss.elastic.co/u/monfera)
#### Post date: [November 9, 2020, 2:49pm UTC](https://discuss.elastic.co/t/vega-lite-invalid-spec-error/254706/2 "2020-11-09T14:49:54Z")

</div>

The `"mark"` specification should not be underneath the `"data"` specification; they should be at the same level. Please see structuring in the vega-lite [examples](https://vega.github.io/editor/#/examples/vega-lite/bar). Also, please expand the last item [here](https://www.elastic.co/guide/en/kibana/current/vega-lite-tutorial.html) labeled `▶ Expand final Vega-Lite spec`

---

<div class="post-metadata">

### Author: ![smruthip](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@smruthip](https://discuss.elastic.co/u/smruthip)
#### Post date: [November 9, 2020, 5:26pm UTC](https://discuss.elastic.co/t/vega-lite-invalid-spec-error/254706/3 "2020-11-09T17:26:59Z")

</div>

> [@monfera](#):
>
> here

Thank you Robert. That fixed the error.

---

<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: [December 7, 2020, 5:26pm UTC](https://discuss.elastic.co/t/vega-lite-invalid-spec-error/254706/4 "2020-12-07T17:26:59Z")

</div>

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