# Vega Error

**URL:** <https://discuss.elastic.co/t/vega-error/130538>\
**Category:** Kibana\
**Created:** [May 4, 2018, 12:18am UTC](https://discuss.elastic.co/t/vega-error/130538 "2018-05-04T00:18:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jspeer](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jspeer](https://discuss.elastic.co/u/jspeer)\
**Post date:** [May 4, 2018, 12:18am UTC](https://discuss.elastic.co/t/vega-error/130538/1 "2018-05-04T00:18:13Z")

</div>

I'm trying to create a vega visual, but receiving 'invalid field type "undefined"'

The 2 fields are strings, and the @timestamp a a date field. I've also tried it without converting the @timestamp to a date, and passing the @timestamp to x, but that gives me the same error.

Here is the json:

```
{
  $schema: https: //vega.github.io/schema/vega-lite/v2.json
  mark: point

  data: {
    url: {
      %context%: true
      %timefield%: @timestamp
      index: service-appointment-prod-*
      body: {
        size: 10000
        _source: [
                "@timestamp",
                "system.process.memory.rss.bytes",
                "system.filesystem.files"
            ]
        }
    }
    format: { property: "hits.hits"
    }
}

  transform: [
        {
      calculate: "toDate(datum._source['@timestamp'])"
      as: "time"
        }
    ]

      encoding: {
    x: {
      field: time
      type: temporal
      axis: { title: false
            }
        }
    y: {
      field: _source.system.process.memory.rss.bytes
      type: quantative
      axis: { title: "bytes"
            }
        }
    }
}

```

I am able to perform a search using those fields:

```
GET service-appointment-prod-*/_search
{
  "size": 10,
  "_source": ["@timestamp","system.process.memory.rss.bytes","host"]
}

```

returns:

```
{
  "took": 51,
  "timed_out": false,
  "_shards": {
    "total": 119,
    "successful": 119,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 17727946,
    "max_score": 1,
    "hits": [
      {
        "_index": "service-appointment-prod-2018.03.15",
        "_type": "doc",
        "_id": "RTmjK2IBt7mrOhHx1Cni",
        "_score": 1,
        "_source": {
          "@timestamp": "2018-03-15T21:49:38.880Z",
          "host": "stlrck-vcrh001"
        }
      },
    {
    "_index": "service-appointment-prod-2018.03.15",
    "_type": "doc",
    "_id": "1Z6jK2IB4hB-5zYa1M_i",
    "_score": 1,
    "_source": {
      "@timestamp": "2018-03-15T21:49:39.033Z",
      "system": {
        "process": {
          "memory": {
            "rss": {
              "bytes": 1018032128
            }
          }
        }
      },
      "host": "stlrck-vcrh001"
    }
  },
```

---

<div class="post-metadata">

**Author:** ![jspeer](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jspeer](https://discuss.elastic.co/u/jspeer)\
**Post date:** [May 4, 2018, 6:35pm UTC](https://discuss.elastic.co/t/vega-error/130538/2 "2018-05-04T18:35:40Z")

</div>

I've cleaned up a few mistakes that I've made, it appears that I'm not able to use fields with a "." in them.

Here is my simplified version

```
{
  $schema: https: //vega.github.io/schema/vega-lite/v2.json
  mark: point

  data: {
    url: {
      %context%: true
      %timefield%: @timestamp
      index: service-appointment-prod-*
      body: {
        size: 100,
        _source: [
                "@timestamp",
                "system.process.memory.rss.bytes"
            ]
        }
    },
    format: { property: "hits.hits" }
  },
  transform: [
        { calculate: "toDate(datum._source['@timestamp'])" as: "time"},
        { calculate: "datum._source['system.process.memory.rss.bytes']" as: "host"}
    
    ],
  encoding: {
    x: { field: "time", type: "temporal" }
    y: { field: "host", type: "nominal" }
  }
}

```

if I have the field "system.process.memory.rss.bytes" in the json, I receive this error:  
Cannot read property 'process' of undefined

but when I swap the field "system.process.memory.rss.bytes" for the field "host" it works.

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [May 7, 2018, 2:52pm UTC](https://discuss.elastic.co/t/vega-error/130538/3 "2018-05-07T14:52:08Z")

</div>

You have to escape the `.` so try something like

```auto
calculate: "datum._source['system\.process\.memory\.rss\.bytes']" as: "host"}

```

The official vega documentation can be found at [https://github.com/vega/vega/wiki/Marks#value-references](https://github.com/vega/vega/wiki/Marks#value-references)

---

<div class="post-metadata">

**Author:** ![jspeer](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jspeer](https://discuss.elastic.co/u/jspeer)\
**Post date:** [May 7, 2018, 3:59pm UTC](https://discuss.elastic.co/t/vega-error/130538/4 "2018-05-07T15:59:15Z")

</div>

I had tried that as well, I receive a bad string at the line with the escaped string.

```
{
  $schema: https://vega.github.io/schema/vega-lite/v2.json
  "data": {
    # URL object is a context-aware query to Elasticsearch
    "url": {
      # The %-enclosed keys are handled by Kibana to modify the query
      # before it gets sent to Elasticsearch. Context is the search
      # filter as shown above the dashboard. Timefield uses the value 
      # of the time picker from the upper right corner.
      %context%: true
      %timefield%: @timestamp
      "index": service-appointment-prod-*
      "body": {
        size: 1000
        _source: ["@timestamp","system.process.memory.rss.bytes"] 
      }
    }
    # We only need the content of hits.hits array
    format: {property: "hits.hits"}
  }
  # Parse timestamp into a javascript date value
  transform: [
    {calculate: "toDate(datum._source['@timestamp'])", as: "time"},
    {calculate: "datum._source['system\.process\.memory\.rss\.bytes']" as: "host"}
  ],
  # Draw a circle, with x being the time field, and y - number of bytes
  mark: point
  encoding: 
  {
  x: {field: "time", type: "temporal", axis: { title: false }
  },
  y: {field: "host", type: "nominal" }

  }
}
```

---

<div class="post-metadata">

**Author:** ![jspeer](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jspeer](https://discuss.elastic.co/u/jspeer)\
**Post date:** [May 7, 2018, 5:58pm UTC](https://discuss.elastic.co/t/vega-error/130538/5 "2018-05-07T17:58:36Z")

</div>

I've also attempted the double slash escape from the vega-lite docs, to no avail.

> **[Parameter Types](https://vega.github.io/vega/docs/types/)**
>
> Vega - A Visualization Grammar. Vega is a visualization grammar, a declarative format for creating, saving, and sharing interactive visualization designs. With Vega, you can describe the visual appearance and interactive behavior of a visualization...

---

<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:** [June 4, 2018, 5:58pm UTC](https://discuss.elastic.co/t/vega-error/130538/6 "2018-06-04T17:58:48Z")

</div>

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