Templating host selection with ELS backend

Hello,

I’m trying to build a template dashboard from data stored in ELS.
Data comes from collectd/logstash, syslog/logstash and metricbeat. All of those use default settings (as described in the software docs). Not specific customization on field types.

I want to be able to select hostnames from a drop-down list so that the dashboard can be more specific, on-demand. I read that I need to use “Templates”. I tried to reproduce what’s describred in http://docs.grafana.org/reference/templating/ but I can’t find the right query to show a hostname list.

In the templating section, I created a new variable and configured:
Name: hostname
Label: Hostname
Type: Query
Data source: The ELS source
Refresh: On Time Range Change
Query: {“find”: “terms”, “field”: “host.keyword”}
Regex:
Sort: Alphabetical

This leads to the following error “Templating. Template variables could not be initialized: undefined”.

I tried a bunch of queries but I can’t list my hostnames.

Query: {“find”: “terms”, “field”: “host”} gives the same undefined error.

Query: {“find”: “fields”, “type”: “keyword”} gives the following Preview Of Values: All @version.keyword host.keyword message.keyword procid.keyword programname.keyword type.keyword

What am I doing wrong?

Thank you.

In case it matters, here’s the software I use:

  • collectd 5.5.1
  • metricbeat 5.6.3
  • logstash 5.6.3
  • elasticsearch 5.6.3
  • grafana 4.5.2

Hi,

Please have a look at the Elasticsearch templating documentation.

Seems like you should use a query like {“find”: “terms”, “field”: “@host.keyword”, “size”: 1000}. As you see in the documenation there are other types of queries you can use.

Hope this helps

Marcus

I ended discovering I had to force ELS Source à 5.x.
Then, everything went well.