AWS EC2 Relabel IF public IP exists

344 views
Skip to first unread message

joehgo...@gmail.com

unread,
Mar 19, 2018, 5:20:31 PM3/19/18
to Prometheus Users
I have a bunch of AWS instances.  Some have public IP addresses and some only have RFC-1918 addressing and we access them via VPN.  I have been trying to figure out a regex to relabel only those instances with public IP addresses.  The Prometheus server has access to all the privately addressed servers via those IP's but must access the publicly accessible servers via their public IP.

I am pretty flexible to a solution, so if I need to add some tagging to make this easier, I am open to that.

Thanks,
Joe

Brian Brazil

unread,
Mar 19, 2018, 5:51:23 PM3/19/18
to joehgo...@gmail.com, Prometheus Users
On 19 March 2018 at 21:20, <joehgo...@gmail.com> wrote:
I have a bunch of AWS instances.  Some have public IP addresses and some only have RFC-1918 addressing and we access them via VPN.  I have been trying to figure out a regex to relabel only those instances with public IP addresses.  The Prometheus server has access to all the privately addressed servers via those IP's but must access the publicly accessible servers via their public IP.

I am pretty flexible to a solution, so if I need to add some tagging to make this easier, I am open to that.

No need for that, you can do:

- source_labels: [__meta_ec2_public_ip]
  regex: (.+)
  replacement: ${1}:1234
  target_label: __address__

The + requires at least one matching character, so won't match a missing/empty label.

Brian
 

Thanks,
Joe

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/94940f9a-7a25-4f85-a3ef-f6c1dacfe4f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
Message has been deleted
0 new messages