title: Counting values in a field (value_count)
body: <p>I’m using Grafana to display metrics from Elasticsearch.</p>
  
  <p>I want to count the number of values in a field and shows them in a graph</p>
  
  <p>Like I do in Elasticsearch</p>
  
  <p>for example:</p>
  
  <pre><code>POST /sales/_search?size=0
  {
      “aggs” : {
          “types_count” : { 
              “value_count” : { “field” : “type” } 
          }
      }
  }
  </code></pre>
  
  <p>I try to convert it like that with no success </p>
  
  <pre><code>aggs(types_count(value_count(demand=type)))   
  </code></pre>