Browse Source

Add azure public ip label (#5475)

* Update Azure SD Config with Public IP label

Signed-off-by: earthmant <trammell@cloudify.co>
pull/5478/head
EarthmanT 6 years ago committed by Brian Brazil
parent
commit
35be8c9e25
  1. 4
      discovery/azure/azure.go
  2. 1
      docs/configuration/configuration.md

4
discovery/azure/azure.go

@ -48,6 +48,7 @@ const (
azureLabelMachineOSType = azureLabel + "machine_os_type" azureLabelMachineOSType = azureLabel + "machine_os_type"
azureLabelMachineLocation = azureLabel + "machine_location" azureLabelMachineLocation = azureLabel + "machine_location"
azureLabelMachinePrivateIP = azureLabel + "machine_private_ip" azureLabelMachinePrivateIP = azureLabel + "machine_private_ip"
azureLabelMachinePublicIP = azureLabel + "machine_public_ip"
azureLabelMachineTag = azureLabel + "machine_tag_" azureLabelMachineTag = azureLabel + "machine_tag_"
azureLabelMachineScaleSet = azureLabel + "machine_scale_set" azureLabelMachineScaleSet = azureLabel + "machine_scale_set"
@ -334,6 +335,9 @@ func (d *Discovery) refresh(ctx context.Context) ([]*targetgroup.Group, error) {
if *networkInterface.Primary { if *networkInterface.Primary {
for _, ip := range *networkInterface.IPConfigurations { for _, ip := range *networkInterface.IPConfigurations {
if ip.PublicIPAddress != nil {
labels[azureLabelMachinePublicIP] = model.LabelValue(*ip.PublicIPAddress.IPAddress)
}
if ip.PrivateIPAddress != nil { if ip.PrivateIPAddress != nil {
labels[azureLabelMachinePrivateIP] = model.LabelValue(*ip.PrivateIPAddress) labels[azureLabelMachinePrivateIP] = model.LabelValue(*ip.PrivateIPAddress)
address := net.JoinHostPort(*ip.PrivateIPAddress, fmt.Sprintf("%d", d.port)) address := net.JoinHostPort(*ip.PrivateIPAddress, fmt.Sprintf("%d", d.port))

1
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_name`: the machine name
* `__meta_azure_machine_os_type`: the machine operating system * `__meta_azure_machine_os_type`: the machine operating system
* `__meta_azure_machine_private_ip`: the machine's private IP * `__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_resource_group`: the machine's resource group
* `__meta_azure_machine_tag_<tagname>`: each tag value of the machine * `__meta_azure_machine_tag_<tagname>`: 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/)) * `__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/))

Loading…
Cancel
Save