title: Removing duplicate entries with Grafana and Loki
body: <p>I am using Grafana to visualize metrics from Prometheus and logs from Loki about an app. There are log statements such as:</p>
  <pre><code>{&quot;action&quot;: &quot;action_a&quot;, &quot;username&quot;: &quot;user_1&quot;, &quot;ts&quot;: 1012}
  {&quot;action&quot;: &quot;action_a&quot;, &quot;username&quot;: &quot;user_2&quot;, &quot;ts&quot;: 1008}
  {&quot;action&quot;: &quot;action_a&quot;, &quot;username&quot;: &quot;user_1&quot;, &quot;ts&quot;: 1005}
  {&quot;action&quot;: &quot;action_a&quot;, &quot;username&quot;: &quot;user_1&quot;, &quot;ts&quot;: 1000}
  </code></pre>
  <p>and I have a query to get a list of the &quot;recently active users&quot;, using the Grafana Logs panel:</p>
  <pre><code>{job=&quot;my-app&quot;} | json | username != &quot;&quot; | line_format &quot;{{.username}}&quot;
  </code></pre>
  <p>I have tried all values of <code>Deduplication</code>, and this mostly works fine, except in the (common) case where users are making actions in between each other (as above), then I get logs like this:</p>
  <pre><code>user_1
  user_2
  user_1
  </code></pre>
  <p>How can I make it so it only shows each user one time?, eg:</p>
  <pre><code>user_1
  user_2
  </code></pre>