# Not able to get query working under variables with datasource as elasticsearch

**URL:** <https://community.grafana.com/t/not-able-to-get-query-working-under-variables-with-datasource-as-elasticsearch/104832>\
**Category:** Configuration\
**Created:** [October 3, 2023, 7:19pm UTC](https://community.grafana.com/t/not-able-to-get-query-working-under-variables-with-datasource-as-elasticsearch/104832 "2023-10-03T19:19:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkvel01](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@pkvel01](https://community.grafana.com/u/pkvel01)\
**Post date:** [October 3, 2023, 7:19pm UTC](https://community.grafana.com/t/not-able-to-get-query-working-under-variables-with-datasource-as-elasticsearch/104832/1 "2023-10-03T19:19:42Z")

</div>

Grafana v10.0.3, ES v 8.8.1

i m trying to create new variable for frontend(HAPROXY)

query : { “find”: “terms”, “field”: “haproxy.frontend\_name” } – \> No result

query: { "“find”: “terms”, “field”: “agent.name”} → sucess

On dev tools when i try below query

GET logs-haproxy\*/\_search  
{  
“size”: 0,  
“aggs”: {  
“unique\_frontend\_names”: {  
“terms”: {  
“field”: “haproxy.frontend\_name”,  
“size”: 10 // adjust this to retrieve as many terms as you need  
}  
}  
}  
}

i get

{  
“took”: 1147,  
“timed\_out”: false,  
“\_shards”: {  
“total”: 2,  
“successful”: 2,  
“skipped”: 0,  
“failed”: 0  
},  
“hits”: {  
“total”: {  
“value”: 10000,  
“relation”: “gte”  
},  
“max\_score”: null,  
“hits”:   
},  
“aggregations”: {  
“unique\_frontend\_names”: {  
“doc\_count\_error\_upper\_bound”: 0,  
“sum\_other\_doc\_count”: 3350,  
“buckets”: [  
{  
“key”: “fe\_haproxy-chat\_80”,  
“doc\_count”: 39472465  
},  
{  
“key”: “fe\_haproxy-prd-service\_8080”,  
“doc\_count”: 32282083  
},  
{  
“key”: “fe\_haproxy-stg-service\_8080”,  
“doc\_count”: 1308373  
},  
{  
“key”: “fe\_haproxy-prd-service\_80”,  
“doc\_count”: 849292  
},  
{  
“key”: “fe\_haproxy-stg-service\_80”,  
“doc\_count”: 127236  
},  
{  
“key”: “fe\_haproxy-prd-service\_443~”,  
“doc\_count”: 96227  
},  
{  
“key”: “fe\_haproxy-stg-service\_443~”,  
“doc\_count”: 93037  
},  
{  
“key”: “fe\_haproxy-dev-service\_80”,  
“doc\_count”: 49656  
},  
{  
“key”: “prometheus”,  
“doc\_count”: 13273  
},  
{  
“key”: “fe\_haproxy-dev-service\_443~”,  
“doc\_count”: 7884  
}  
]  
}  
}

can you please advice why i m not able to use it in variables?

---

<div class="post-metadata">

**Author:** ![pkvel01](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@pkvel01](https://community.grafana.com/u/pkvel01)\
**Post date:** [October 3, 2023, 8:30pm UTC](https://community.grafana.com/t/not-able-to-get-query-working-under-variables-with-datasource-as-elasticsearch/104832/2 "2023-10-03T20:30:21Z")

</div>

Close this
