fix(plugin): Azure InsightsMetrics more fixes (#3196)
* resourceid management * misc fixes on plugin and modes
This commit is contained in:
parent
6fb5e91654
commit
93ec810d77
|
@ -74,7 +74,7 @@ sub set_counters {
|
|||
{ template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ sub check_options {
|
|||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $query = 'InsightsMetrics | where Namespace == "Processor" | summarize arg_max(TimeGenerated, *) by Tags, Name, Computer';
|
||||
my $query = 'InsightsMetrics | where Namespace == "Processor" | summarize arg_max(TimeGenerated, *) by Tags, Name, Computer';
|
||||
$query .= '| where Computer == "' . $self->{option_results}->{filter_computer} . '"' if defined $self->{option_results}->{filter_computer} && $self->{option_results}->{filter_computer} ne '';
|
||||
$query .= '| where _ResourceId == "' . $self->{option_results}->{filter_resourceid} . '"' if defined $self->{option_results}->{filter_resourceid} && $self->{option_results}->{filter_resourceid} ne '';
|
||||
|
||||
|
@ -172,7 +172,13 @@ Specify the Azure Log Analytics Workspace ID.
|
|||
|
||||
=item B<--filter-computer>
|
||||
|
||||
Filter on a specific Azure "computer".
|
||||
Filter on a specific Azure "computer" name.
|
||||
Example: --filter-name='azure-vm1'
|
||||
|
||||
=item B<--filter-resourceid>
|
||||
|
||||
Filter on a specific Azure "computer" based on the full resource ID.
|
||||
Example: --filter-resourceid='/subscriptions/1234abcd-5678-defg-9012-3456789abcde/resourcegroups/my_resourcegroup/providers/microsoft.compute/virtualmachines/azure-vm1'
|
||||
|
||||
=item B<--filter-cpu>
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ sub check_options {
|
|||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $query = 'InsightsMetrics | where Namespace == "LogicalDisk" | summarize arg_max(TimeGenerated, *) by Tags, Name, Computer';
|
||||
my $query = 'InsightsMetrics | where Namespace == "LogicalDisk" | summarize arg_max(TimeGenerated, *) by Tags, Name, Computer';
|
||||
$query .= '| where Computer == "' . $self->{option_results}->{filter_computer} . '"' if defined $self->{option_results}->{filter_computer} && $self->{option_results}->{filter_computer} ne '';
|
||||
$query .= '| where _ResourceId == "' . $self->{option_results}->{filter_resourceid} . '"' if defined $self->{option_results}->{filter_resourceid} && $self->{option_results}->{filter_resourceid} ne '';
|
||||
|
||||
|
@ -198,6 +198,7 @@ sub manage_selection {
|
|||
$decoded_tag = $options{custom}->json_decode(content => $results->{data}->{$entry}->{tags});
|
||||
my $mountid = $decoded_tag->{"vm.azm.ms/mountId"};
|
||||
next if ($mountid !~ m/$disk/);
|
||||
next if (defined($self->{option_results}->{filter_disk}) && $decoded_tag->{"vm.azm.ms\/mountId"} !~ m/$self->{option_results}->{filter_disk}/);
|
||||
|
||||
if ($results->{data}->{$entry}->{name} =~ m/(.*Space)MB/) {
|
||||
$self->{computer}->{$results->{data}->{$entry}->{computer}}->{logicaldisk}->{$mountid}->{$1} = $results->{data}->{$entry}->{value} * 1000000;
|
||||
|
@ -205,7 +206,7 @@ sub manage_selection {
|
|||
$self->{computer}->{$results->{data}->{$entry}->{computer}}->{logicaldisk}->{$mountid}->{$results->{data}->{$entry}->{name}} = $results->{data}->{$entry}->{value};
|
||||
}
|
||||
if ($results->{data}->{$entry}->{name} =~ 'Status') {
|
||||
$self->{computer}->{$results->{data}->{$entry}->{computer}}->{logicaldisk}->{$mountid}->{$results->{data}->{$entry}->{name}} = %$status_mapping{$results->{data}->{$entry}->{value}};
|
||||
$self->{computer}->{$results->{data}->{$entry}->{computer}}->{logicaldisk}->{$mountid}->{$results->{data}->{$entry}->{name}} = $status_mapping->{$results->{data}->{$entry}->{value}};
|
||||
}
|
||||
|
||||
if (defined($decoded_tag->{"vm.azm.ms/diskSizeMB"})) {
|
||||
|
@ -249,13 +250,18 @@ Specify the Azure Log Analytics Workspace ID.
|
|||
|
||||
=item B<--filter-computer>
|
||||
|
||||
Filter on a specific Azure "computer".
|
||||
Filter on a specific Azure "computer" name.
|
||||
Example: --filter-name='azure-vm1'
|
||||
|
||||
=item B<--filter-resourceid>
|
||||
|
||||
Filter on a specific Azure "computer" based on the full resource ID.
|
||||
Example: --filter-resourceid='/subscriptions/1234abcd-5678-defg-9012-3456789abcde/resourcegroups/my_resourcegroup/providers/microsoft.compute/virtualmachines/azure-vm1'
|
||||
|
||||
=item B<--filter-disk>
|
||||
|
||||
Filter on specific logical(s) disk(s).
|
||||
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Warning threshold on logical disk status (Default: none).
|
||||
|
|
|
@ -87,7 +87,7 @@ sub set_counters {
|
|||
{ template => '%d', min => 0, max => 100, unit => '%', label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ sub check_options {
|
|||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $query = 'InsightsMetrics | where Namespace == "Memory" | summarize arg_max(TimeGenerated, *) by Tags, Name, Computer';
|
||||
my $query = 'InsightsMetrics | where Namespace == "Memory" | summarize arg_max(TimeGenerated, *) by Tags, Name, Computer';
|
||||
$query .= '| where Computer == "' . $self->{option_results}->{filter_computer} . '"' if defined $self->{option_results}->{filter_computer} && $self->{option_results}->{filter_computer} ne '';
|
||||
$query .= '| where _ResourceId == "' . $self->{option_results}->{filter_resourceid} . '"' if defined $self->{option_results}->{filter_resourceid} && $self->{option_results}->{filter_resourceid} ne '';
|
||||
|
||||
|
@ -181,7 +181,13 @@ Specify the Azure Log Analytics Workspace ID.
|
|||
|
||||
=item B<--filter-computer>
|
||||
|
||||
Filter on a specific Azure "computer".
|
||||
Filter on a specific Azure "computer" name.
|
||||
Example: --filter-name='azure-vm1'
|
||||
|
||||
=item B<--filter-resourceid>
|
||||
|
||||
Filter on a specific Azure "computer" based on the full resource ID.
|
||||
Example: --filter-resourceid='/subscriptions/1234abcd-5678-defg-9012-3456789abcde/resourcegroups/my_resourcegroup/providers/microsoft.compute/virtualmachines/azure-vm1'
|
||||
|
||||
=item B<--warning-*>
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ sub new {
|
|||
'memory' => 'cloud::azure::management::insightsmetrics::mode::memory',
|
||||
);
|
||||
|
||||
$self->{custom_modes}{api} = 'cloud::azure::custom::api';
|
||||
$self->{custom_modes}->{api} = 'cloud::azure::custom::api';
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue