Field's name

Hi, i'm new with Kibana and Vega,
I visualizated data that i entered manually and i noticed that when i enter a field name containing a dot (.) the visualization doesn't show up but when i remove the dot it works fine.
The problem is that the data base that i'm currently using contains a file names with a dot
What can i do in this case ?

Could you please share your Vega Spec?

{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "data": {
    "name": "metricbeat",
    "values": [
      {
        "processname": "Java",
        "processstate": "running",
        "color": "green"
      },
      {
        "processname": "Apache",
        "processstate": "sleeping",
        "color": "red"
      },
      {
        "processname": "Node",
        "processstate": "unknown",
        "color": "yellow"
      },
      {
        "processname": "MySQL",
        "processstate": "sleeping",
        "color": "red"
      }
    ]
  },
  "scales": [
    {
      "name": "x",
      "domain": {
        "data": "metricebeat",
        "field": "processname"
      }
    }
  ],
  "mark": "circle",
  "config": {
    "circle": {
      "size": 1000
    },
    "range": {
      "category": {
        "scheme": "elastic"
      }
    },
    "mark": {
      "color": "#54B399"
    },
    "title": {
      "color": "#343741"
    },
    "style": {
      "guide-label": {
        "fill": "#69707d"
      },
      "guide-title": {
        "fill": "#343741"
      },
      "group-title": {
        "fill": "#343741"
      },
      "group-subtitle": {
        "fill": "#343741"
      }
    },
    "axis": {
      "tickColor": "#eef0f3",
      "domainColor": "#eef0f3",
      "gridColor": "#eef0f3"
    },
    "background": "transparent"
  },
  "encoding": {
    "column": {
      "field": "processname",
      "type": "nominal"
    },
    "color": {
      "field": "color",
      "type": "nominal",
      "scale": null
    }
  },
  "width": "container",
  "height": "container",
  "autosize": {
    "type": "fit",
    "contains": "padding"
  }
}

Can you please post what data you are trying to add a period to?

I'm using data from metricbeat which contains fields "process.name" "process.state"

Use ['process.name'] to make that work when there are . in your field names.

it gave me that error message:
Found '[' where a key name was expected (check your syntax or use quotes if the key name includes {},: or whitespace) at line 6,8 >>> {["process.nam ...

Can you post the spec you used that generated this error?

i don't know why but it showed me a spec
anyway this is what i entered:
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"name": "metricbeat",
"values": [
{["process.name"]: "Java", ["process.state"]: "running","color":"green"},
{["process.name"]: "Apache", ["process.state"]: "sleeping","color":"red"},
{["process.name"]: "Node", ["process.state"]: "unknown","color":"yellow"},
{["process.name"]: "MySQL", ["process.state"]: "sleeping","color":"red"}
]

},
"scales":[
{
"name": "x",
"domain":{"data":"metricebeat","field":["process.name"]},
}
],
"mark" : "circle",
"config":{
"circle":{"size": 1000},
}

"encoding": {
"column": {"field": ["process.name"], "type": "nominal"},
"color": {"field": "color", "type": "nominal","scale":null}

}

}

Try this instead.

You data will come in as process.name so you can't change that in your data block. To make this easier just do a transform like I did below and rename that field to something without a . and then you can use that.

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "A simple bar chart with embedded data.",
  "data": {
    "values": [
      {"process.name": "A", "b": 28}, {"process.name": "B", "b": 55}, {"process.name": "C", "b": 43},
      {"process.name": "D", "b": 91}, {"process.name": "E", "b": 81}, {"process.name": "F", "b": 53},
      {"process.name": "G", "b": 19}, {"process.name": "H", "b": 87}, {"process.name": "I", "b": 52}
    ]
  },
    "transform": [
    {"calculate": "datum['process.name']", "as": "processName"}
  ],
  "mark": "bar",
  "encoding": {
    "x": {"field": "processName", "type": "nominal", "axis": {"labelAngle": 0}},
    "y": {"field": "b", "type": "quantitative"}
  }
}

That fixed the problem
Thank you very much!

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