title: How do I get metric names in Grafana's message template?
body: <p>I'm setting up Grafana v8.3.4 alerts. If I use a template like the following</p>
  <pre><code>{{ define &quot;test_message&quot; }}
  
  {{ range .Alerts.Firing }}
  {{ print .ValueString }} 
  {{ end }}
  
  {{ end }}
  </code></pre>
  <p><a href="https://i.stack.imgur.com/oPUMT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oPUMT.png" alt="enter image description here" /></a></p>
  <p>And test the e-mail notification using this template and the predefined message:</p>
  <p><a href="https://i.stack.imgur.com/ZKuNT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZKuNT.png" alt="enter image description here" /></a></p>
  <p>I get:</p>
  <pre><code>[ metric='foo' labels={instance=bar} value=10 ]
  </code></pre>
  <p>In the example above there's only one metric, but there could be more.</p>
  <p><strong>Question: Is there any way to loop through the returned metrics and display it as a table in the e-mail?</strong></p>
  <p>It would look something like:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Metric Name</th>
  <th>Value</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>foo</td>
  <td>10</td>
  </tr>
  <tr>
  <td>x</td>
  <td>22</td>
  </tr>
  <tr>
  <td>y</td>
  <td>7</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>...</p>
  <p><strong>[UPDATE 6/24/2022]</strong>
  @Luis Almeida's answer led me to the right path, so I'm marking it as the correct answer even though my final solution was a little different.</p>
  <p>Here are a couple of other links that also helped:</p>
  <p><a href="https://grafana.com/docs/grafana/latest/alerting/fundamentals/annotation-label/variables-label-annotation/" rel="nofollow noreferrer">How to template annotations and labels - Grafana's Official Documentatio n</a>
  <a href="https://www.youtube.com/watch?v=UtmmhLraSnE" rel="nofollow noreferrer">Unified Alerting Grafana 8 | Prometheus | Victoria | Telegraf | Notifications | Alert Templating</a></p>