mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 21:24:05 -08:00
Add computer name to azure sd
Signed-off-by: darshanime <deathbullet@gmail.com>
This commit is contained in:
parent
79d354ad2e
commit
c8a2ffdb72
|
@ -46,6 +46,7 @@ const (
|
||||||
azureLabelMachineID = azureLabel + "machine_id"
|
azureLabelMachineID = azureLabel + "machine_id"
|
||||||
azureLabelMachineResourceGroup = azureLabel + "machine_resource_group"
|
azureLabelMachineResourceGroup = azureLabel + "machine_resource_group"
|
||||||
azureLabelMachineName = azureLabel + "machine_name"
|
azureLabelMachineName = azureLabel + "machine_name"
|
||||||
|
azureLabelMachineComputerName = azureLabel + "machine_computer_name"
|
||||||
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"
|
||||||
|
@ -226,6 +227,7 @@ type azureResource struct {
|
||||||
type virtualMachine struct {
|
type virtualMachine struct {
|
||||||
ID string
|
ID string
|
||||||
Name string
|
Name string
|
||||||
|
ComputerName string
|
||||||
Type string
|
Type string
|
||||||
Location string
|
Location string
|
||||||
OsType string
|
OsType string
|
||||||
|
@ -306,6 +308,7 @@ func (d *Discovery) refresh(ctx context.Context) ([]*targetgroup.Group, error) {
|
||||||
azureLabelTenantID: model.LabelValue(d.cfg.TenantID),
|
azureLabelTenantID: model.LabelValue(d.cfg.TenantID),
|
||||||
azureLabelMachineID: model.LabelValue(vm.ID),
|
azureLabelMachineID: model.LabelValue(vm.ID),
|
||||||
azureLabelMachineName: model.LabelValue(vm.Name),
|
azureLabelMachineName: model.LabelValue(vm.Name),
|
||||||
|
azureLabelMachineComputerName: model.LabelValue(vm.ComputerName),
|
||||||
azureLabelMachineOSType: model.LabelValue(vm.OsType),
|
azureLabelMachineOSType: model.LabelValue(vm.OsType),
|
||||||
azureLabelMachineLocation: model.LabelValue(vm.Location),
|
azureLabelMachineLocation: model.LabelValue(vm.Location),
|
||||||
azureLabelMachineResourceGroup: model.LabelValue(r.ResourceGroup),
|
azureLabelMachineResourceGroup: model.LabelValue(r.ResourceGroup),
|
||||||
|
@ -463,6 +466,7 @@ func mapFromVM(vm compute.VirtualMachine) virtualMachine {
|
||||||
return virtualMachine{
|
return virtualMachine{
|
||||||
ID: *(vm.ID),
|
ID: *(vm.ID),
|
||||||
Name: *(vm.Name),
|
Name: *(vm.Name),
|
||||||
|
ComputerName: *(vm.VirtualMachineProperties.OsProfile.ComputerName),
|
||||||
Type: *(vm.Type),
|
Type: *(vm.Type),
|
||||||
Location: *(vm.Location),
|
Location: *(vm.Location),
|
||||||
OsType: osType,
|
OsType: osType,
|
||||||
|
@ -490,6 +494,7 @@ func mapFromVMScaleSetVM(vm compute.VirtualMachineScaleSetVM, scaleSetName strin
|
||||||
return virtualMachine{
|
return virtualMachine{
|
||||||
ID: *(vm.ID),
|
ID: *(vm.ID),
|
||||||
Name: *(vm.Name),
|
Name: *(vm.Name),
|
||||||
|
ComputerName: *(vm.VirtualMachineScaleSetVMProperties.OsProfile.ComputerName),
|
||||||
Type: *(vm.Type),
|
Type: *(vm.Type),
|
||||||
Location: *(vm.Location),
|
Location: *(vm.Location),
|
||||||
OsType: osType,
|
OsType: osType,
|
||||||
|
|
|
@ -30,10 +30,14 @@ func TestMapFromVMWithEmptyTags(t *testing.T) {
|
||||||
name := "name"
|
name := "name"
|
||||||
vmType := "type"
|
vmType := "type"
|
||||||
location := "westeurope"
|
location := "westeurope"
|
||||||
|
computerName := "computer_name"
|
||||||
networkProfile := compute.NetworkProfile{
|
networkProfile := compute.NetworkProfile{
|
||||||
NetworkInterfaces: &[]compute.NetworkInterfaceReference{},
|
NetworkInterfaces: &[]compute.NetworkInterfaceReference{},
|
||||||
}
|
}
|
||||||
properties := &compute.VirtualMachineProperties{
|
properties := &compute.VirtualMachineProperties{
|
||||||
|
OsProfile: &compute.OSProfile{
|
||||||
|
ComputerName: &computerName,
|
||||||
|
},
|
||||||
StorageProfile: &compute.StorageProfile{
|
StorageProfile: &compute.StorageProfile{
|
||||||
OsDisk: &compute.OSDisk{
|
OsDisk: &compute.OSDisk{
|
||||||
OsType: "Linux",
|
OsType: "Linux",
|
||||||
|
@ -54,6 +58,7 @@ func TestMapFromVMWithEmptyTags(t *testing.T) {
|
||||||
expectedVM := virtualMachine{
|
expectedVM := virtualMachine{
|
||||||
ID: id,
|
ID: id,
|
||||||
Name: name,
|
Name: name,
|
||||||
|
ComputerName: computerName,
|
||||||
Type: vmType,
|
Type: vmType,
|
||||||
Location: location,
|
Location: location,
|
||||||
OsType: "Linux",
|
OsType: "Linux",
|
||||||
|
@ -71,6 +76,7 @@ func TestMapFromVMWithTags(t *testing.T) {
|
||||||
name := "name"
|
name := "name"
|
||||||
vmType := "type"
|
vmType := "type"
|
||||||
location := "westeurope"
|
location := "westeurope"
|
||||||
|
computerName := "computer_name"
|
||||||
tags := map[string]*string{
|
tags := map[string]*string{
|
||||||
"prometheus": new(string),
|
"prometheus": new(string),
|
||||||
}
|
}
|
||||||
|
@ -78,6 +84,9 @@ func TestMapFromVMWithTags(t *testing.T) {
|
||||||
NetworkInterfaces: &[]compute.NetworkInterfaceReference{},
|
NetworkInterfaces: &[]compute.NetworkInterfaceReference{},
|
||||||
}
|
}
|
||||||
properties := &compute.VirtualMachineProperties{
|
properties := &compute.VirtualMachineProperties{
|
||||||
|
OsProfile: &compute.OSProfile{
|
||||||
|
ComputerName: &computerName,
|
||||||
|
},
|
||||||
StorageProfile: &compute.StorageProfile{
|
StorageProfile: &compute.StorageProfile{
|
||||||
OsDisk: &compute.OSDisk{
|
OsDisk: &compute.OSDisk{
|
||||||
OsType: "Linux",
|
OsType: "Linux",
|
||||||
|
@ -98,6 +107,7 @@ func TestMapFromVMWithTags(t *testing.T) {
|
||||||
expectedVM := virtualMachine{
|
expectedVM := virtualMachine{
|
||||||
ID: id,
|
ID: id,
|
||||||
Name: name,
|
Name: name,
|
||||||
|
ComputerName: computerName,
|
||||||
Type: vmType,
|
Type: vmType,
|
||||||
Location: location,
|
Location: location,
|
||||||
OsType: "Linux",
|
OsType: "Linux",
|
||||||
|
@ -115,10 +125,14 @@ func TestMapFromVMScaleSetVMWithEmptyTags(t *testing.T) {
|
||||||
name := "name"
|
name := "name"
|
||||||
vmType := "type"
|
vmType := "type"
|
||||||
location := "westeurope"
|
location := "westeurope"
|
||||||
|
computerName := "computer_name"
|
||||||
networkProfile := compute.NetworkProfile{
|
networkProfile := compute.NetworkProfile{
|
||||||
NetworkInterfaces: &[]compute.NetworkInterfaceReference{},
|
NetworkInterfaces: &[]compute.NetworkInterfaceReference{},
|
||||||
}
|
}
|
||||||
properties := &compute.VirtualMachineScaleSetVMProperties{
|
properties := &compute.VirtualMachineScaleSetVMProperties{
|
||||||
|
OsProfile: &compute.OSProfile{
|
||||||
|
ComputerName: &computerName,
|
||||||
|
},
|
||||||
StorageProfile: &compute.StorageProfile{
|
StorageProfile: &compute.StorageProfile{
|
||||||
OsDisk: &compute.OSDisk{
|
OsDisk: &compute.OSDisk{
|
||||||
OsType: "Linux",
|
OsType: "Linux",
|
||||||
|
@ -140,6 +154,7 @@ func TestMapFromVMScaleSetVMWithEmptyTags(t *testing.T) {
|
||||||
expectedVM := virtualMachine{
|
expectedVM := virtualMachine{
|
||||||
ID: id,
|
ID: id,
|
||||||
Name: name,
|
Name: name,
|
||||||
|
ComputerName: computerName,
|
||||||
Type: vmType,
|
Type: vmType,
|
||||||
Location: location,
|
Location: location,
|
||||||
OsType: "Linux",
|
OsType: "Linux",
|
||||||
|
@ -158,6 +173,7 @@ func TestMapFromVMScaleSetVMWithTags(t *testing.T) {
|
||||||
name := "name"
|
name := "name"
|
||||||
vmType := "type"
|
vmType := "type"
|
||||||
location := "westeurope"
|
location := "westeurope"
|
||||||
|
computerName := "computer_name"
|
||||||
tags := map[string]*string{
|
tags := map[string]*string{
|
||||||
"prometheus": new(string),
|
"prometheus": new(string),
|
||||||
}
|
}
|
||||||
|
@ -165,6 +181,9 @@ func TestMapFromVMScaleSetVMWithTags(t *testing.T) {
|
||||||
NetworkInterfaces: &[]compute.NetworkInterfaceReference{},
|
NetworkInterfaces: &[]compute.NetworkInterfaceReference{},
|
||||||
}
|
}
|
||||||
properties := &compute.VirtualMachineScaleSetVMProperties{
|
properties := &compute.VirtualMachineScaleSetVMProperties{
|
||||||
|
OsProfile: &compute.OSProfile{
|
||||||
|
ComputerName: &computerName,
|
||||||
|
},
|
||||||
StorageProfile: &compute.StorageProfile{
|
StorageProfile: &compute.StorageProfile{
|
||||||
OsDisk: &compute.OSDisk{
|
OsDisk: &compute.OSDisk{
|
||||||
OsType: "Linux",
|
OsType: "Linux",
|
||||||
|
@ -186,6 +205,7 @@ func TestMapFromVMScaleSetVMWithTags(t *testing.T) {
|
||||||
expectedVM := virtualMachine{
|
expectedVM := virtualMachine{
|
||||||
ID: id,
|
ID: id,
|
||||||
Name: name,
|
Name: name,
|
||||||
|
ComputerName: computerName,
|
||||||
Type: vmType,
|
Type: vmType,
|
||||||
Location: location,
|
Location: location,
|
||||||
OsType: "Linux",
|
OsType: "Linux",
|
||||||
|
|
|
@ -386,6 +386,7 @@ The following meta labels are available on targets during [relabeling](#relabel_
|
||||||
* `__meta_azure_machine_id`: the machine ID
|
* `__meta_azure_machine_id`: the machine ID
|
||||||
* `__meta_azure_machine_location`: the location the machine runs in
|
* `__meta_azure_machine_location`: the location the machine runs in
|
||||||
* `__meta_azure_machine_name`: the machine name
|
* `__meta_azure_machine_name`: the machine name
|
||||||
|
* `__meta_azure_machine_computer_name`: the machine computer 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_public_ip`: the machine's public IP if it exists
|
||||||
|
|
Loading…
Reference in a new issue