diff --git a/discovery/azure/azure.go b/discovery/azure/azure.go index a48622a9b..f3d2ac5f3 100644 --- a/discovery/azure/azure.go +++ b/discovery/azure/azure.go @@ -48,6 +48,7 @@ const ( azureLabelMachineOSType = azureLabel + "machine_os_type" azureLabelMachineLocation = azureLabel + "machine_location" azureLabelMachinePrivateIP = azureLabel + "machine_private_ip" + azureLabelMachinePublicIP = azureLabel + "machine_public_ip" azureLabelMachineTag = azureLabel + "machine_tag_" azureLabelMachineScaleSet = azureLabel + "machine_scale_set" @@ -334,6 +335,9 @@ func (d *Discovery) refresh(ctx context.Context) ([]*targetgroup.Group, error) { if *networkInterface.Primary { for _, ip := range *networkInterface.IPConfigurations { + if ip.PublicIPAddress != nil { + labels[azureLabelMachinePublicIP] = model.LabelValue(*ip.PublicIPAddress.IPAddress) + } if ip.PrivateIPAddress != nil { labels[azureLabelMachinePrivateIP] = model.LabelValue(*ip.PrivateIPAddress) address := net.JoinHostPort(*ip.PrivateIPAddress, fmt.Sprintf("%d", d.port)) diff --git a/docs/configuration/configuration.md b/docs/configuration/configuration.md index 2ee62cc6a..08b9f0d9b 100644 --- a/docs/configuration/configuration.md +++ b/docs/configuration/configuration.md @@ -274,6 +274,7 @@ The following meta labels are available on targets during relabeling: * `__meta_azure_machine_name`: the machine name * `__meta_azure_machine_os_type`: the machine operating system * `__meta_azure_machine_private_ip`: the machine's private IP +* `__meta_azure_machine_public_ip`: the machine's public IP if it exists * `__meta_azure_machine_resource_group`: the machine's resource group * `__meta_azure_machine_tag_`: each tag value of the machine * `__meta_azure_machine_scale_set`: the name of the scale set which the vm is part of (this value is only set if you are using a [scale set](https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/))