# Templating: extract value

**URL:** <https://community.grafana.com/t/templating-extract-value/1479>\
**Category:** Grafana\
**Created:** [June 21, 2017, 12:20pm UTC](https://community.grafana.com/t/templating-extract-value/1479 "2017-06-21T12:20:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tzach](https://avatars.discourse-cdn.com/v4/letter/t/5f8ce5/32.png) [@tzach](https://community.grafana.com/u/tzach)\
**Post date:** [June 21, 2017, 12:20pm UTC](https://community.grafana.com/t/templating-extract-value/1479/1 "2017-06-21T12:20:37Z")

</div>

Running Grafana on prometheus, I want to create a row per target.  
up{} return a list of string in the format of "up{instance=“184.72.121.26:9180”,job=“server”}  
How should I extract only the IP value: “184.72.121.26” ?  
I’m fine with doing it in the var def or the var usage.

Thanks  
Tzach

---

<div class="post-metadata">

**Author:** ![daniellee](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/daniellee/32/41_2.png) [@daniellee](https://community.grafana.com/u/daniellee)\
**Post date:** [June 21, 2017, 4:58pm UTC](https://community.grafana.com/t/templating-extract-value/1479/2 "2017-06-21T16:58:11Z")

</div>

You can use regex and a capture group. See [this answer to an Influx query](https://community.grafana.com/t/is-it-possible-to-definie-variable-template-with-regex/1391/3).

And here is an answer for Prometheus:

> [@Using regex in Grafana templating - how?](https://community.grafana.com/t/using-regex-in-grafana-templating-how/859):
>
> I would like populate values for variable in templating using query (a datasource: Prometheus). I know that I can use structure like: label\_values({job="nodes"},instance) and I received something like: [node1.example.com:9100](http://node1.example.com:9100), [node2.example.com:9100](http://node2.example.com:9100), etc. But I would like receive only the FQDN (without a collon and a port number) . Probably I can use for that the “Regex” field but I can’t prepare correct regex pattern. Thank you in advance for any help.

---

<div class="post-metadata">

**Author:** ![tzach](https://avatars.discourse-cdn.com/v4/letter/t/5f8ce5/32.png) [@tzach](https://community.grafana.com/u/tzach)\
**Post date:** [June 22, 2017, 6:22am UTC](https://community.grafana.com/t/templating-extract-value/1479/3 "2017-06-22T06:22:52Z")

</div>

Thanks, the following did the trick for me  
/instance="(._):._"/
