title: Modelling influxdb data into tags and fields
body: <p><strong>TL;DR</strong><br>
  How to model data into fields vs tags incase you want to perform both group by and count(distinct())</p>
  
  <p>So currently this is my influxdb data model:</p>
  
  <pre><code>api_requests (database)
     - requests_stats (measurement)
          - api_path (tag)
          - app_version (tag)
          - host (tag)
          - platform (tag) 
  
          - account_id (field)
          - user_id (field)
          - function_name (field)
          - network (field)
          - network_type (field)
          - time_to_execute (field)
  </code></pre>
  
  <p>So now I want to find out the number of distinct accounts (active accounts).
  So I can run the following query:</p>
  
  <pre><code>SELECT count(distinct("account_id")) AS "active_accounts"
  FROM "api_requests"."autogen"."requests_stats"
  </code></pre>
  
  <p>This works fine as account id is a field.</p>
  
  <p>Now suppose I want to perform a group by operation on account_id, for example to find the number of requests received per account:</p>
  
  <pre><code>SELECT count("function_name") AS "request_count" 
  FROM "api_requests"."autogen"."requests_stats"
  GROUP BY "account_id"
  </code></pre>
  
  <p>I cannot do this as group by is recommended on tags.</p>
  
  <p>How would one manage this kind of scenerio?</p>
  
  <p>One of the solution is to store the value in both field and value but that would be data redundancy.</p>
  
  <p>The other and the most optimal way would be for count(distinct()) to work on tags. Is this possible? This was actually a feature request in their github repo.</p>
  
  <p>Or can something be done about the data model to achieve the same?</p>