How to use Elasticsearch Scripted Fileds in Grafana?

Hello Team,

I have a nested field in my index.
So, I use scripted field in Kibana to extract the data in the nested field.
My question is how can I do the same thing in Grafana (get the “pressure” data as a metric)?

Thanks for your support in advance.

my index is as follows.

{
“_index”: “produciondata20200609”,
“_type”: “_doc”,
“_id”: “ed71af8bff5fe81b5c18bc3d3b4675f5392543abc33dabff”,
“_version”: 1,
“_score”: null,
“_source”: {
“factorycode”: “Germany”,
“productcode”: “Washing Machine”,
“lastupdatetime”: “2020-06-09T19:15:07.441Z”,
@timestamp”: “2020-06-09T19:08:33.000Z”,
“massproduction”: {
“model”: “0”,
“externalfilename”: null,
“name”: “massproduction”,
“setupid”: null,
“workid”: “GSHGD05040A02200168”,
“product”: “GD50SDJSHDH0A00”,
“judge”: “1”,
“eid”: null,
“identificationtagid”: null,
“line”: “WASH001”,
“operatorldap”: null,
“processcode”: “OP120”,
“cycletime”: null,
“reuse”: {
“num”: “0”
},
“errorcomment”: null,
“ladderver”: null,
“datas”: {
“data”: [
{
“content”: “255”,
“id”: “001”,
“name”: “current”
},
{
“content”: “210”,
“id”: “002”,
“name”: “pressure”
},
{
“content”: “200”,
“id”: “003”,
“name”: “temperature”
},
{
“content”: “0”,
“id”: “004”,
“name”: “load”
}
]
},
“errorcode”: null,
“equipment”: “PKJDKJ0110”,
“machinetime”: null,
“registryutcdate”: “2020-06-09T19:08:33”,
“quantity”: “1”,
“registrydate”: “2020-06-10T04:08:33”
}
},
“fields”: {
“massproduction.registrydate”: [
“2020-06-10T04:08:33.000Z”
],
“lastupdatetime”: [
“2020-06-09T19:15:07.441Z”
],
“registrydate”: [
“2020-06-10T04:08:33.000Z”
],
“massproduction.registryutcdate”: [
“2020-06-09T19:08:33.000Z”
]
},
“sort”: [
1591729713000
]
}

I use following scripted filed to get “pressure” data.

if(params._source.massproduction!=null && params._source.massproduction.datas!=null &&params._source.massproduction.datas.data.size()>0)
{
def data = params._source.massproduction.datas.data;
if(data instanceof ArrayList)
{
for(item in data)
{
if(item.name==‘pressure’)
{
return Float.parseFloat(item.content);
}
}
}else
{
if(data.name==‘pressure’)
{
return Float.parseFloat(data.content);
}
}
}
return null;