Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Monitor] add az monitor data-collection commands #2756

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0ac6a0e
Codegen generated with DataCollectionRules Create and Update Pending …
kairu-ms Nov 25, 2020
b4d99c0
regenerate by hiding DataCollectionRules Create & Update commands and…
kairu-ms Nov 25, 2020
d104d64
Reuse Codegen generated with DataCollectionRules Create and Update Pe…
kairu-ms Nov 25, 2020
7b8dfde
add data-collection rule create & update commands
kairu-ms Nov 25, 2020
b10a4ec
hide data-collection rule create & update and data-collection rule as…
kairu-ms Nov 25, 2020
82ac56b
fix codegen invalid operations_tmpl
kairu-ms Nov 26, 2020
1165239
use alias instand of rename in code-gen
kairu-ms Nov 26, 2020
4b6f15e
use alias instead of rename for codegen
kairu-ms Nov 26, 2020
e53dd11
add sub command groups for 'monitor data-collection rule'
kairu-ms Nov 26, 2020
83d6c90
add params for monitor data-collection rule performance-counter, wind…
kairu-ms Nov 26, 2020
da21736
consist argument name with sdk name
kairu-ms Nov 26, 2020
2c2006b
use azure-rest-api-spec keywords rename custom function
kairu-ms Nov 27, 2020
96b7c94
use provider name and operation id to rename custom function
kairu-ms Nov 27, 2020
ab34ba5
Rename custom functions by readable names
kairu-ms Dec 2, 2020
4fa41b3
set monitor data-collection to preview
kairu-ms Dec 3, 2020
024b333
regenerate extension with monitor-control-service name
kairu-ms Dec 3, 2020
f511b0d
add monitor controll service test
kairu-ms Dec 3, 2020
f220d3e
update update functions for data_collection_rules and data_collection…
kairu-ms Dec 4, 2020
1681cc6
add test file
kairu-ms Dec 4, 2020
8194fc0
add tests
kairu-ms Dec 6, 2020
cc0e18f
fix linter and style issues
kairu-ms Dec 6, 2020
e006c93
rename parameters for rule create
kairu-ms Dec 6, 2020
f788c2c
fix style issues
kairu-ms Dec 7, 2020
3a00fdc
add code owner for monitor-control-service
kairu-ms Dec 7, 2020
87a6e87
fix comments issues
kairu-ms Dec 8, 2020
e9196e6
remove _az_debug
kairu-ms Dec 8, 2020
c90e951
add _az_debug in .gitignore
kairu-ms Dec 8, 2020
c41cd22
state as experimental
kairu-ms Dec 14, 2020
a3d910b
Merge branch 'master' into feature-15543-azure-monitor-control-service
kairu-ms Dec 15, 2020
4379896
fix readme
kairu-ms Dec 23, 2020
41dc37d
aio not needed
kairu-ms Dec 23, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,6 @@

/src/automation/ @arrownj

/src/monitor-control-service/ @jsntcy @msyyc @kairu-ms

/src/rdbms-connect/ @mjain2 @Juliehzl
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,5 @@ _build/

# Mac desktop service store files
.DS_Store

_az_debug/
8 changes: 8 additions & 0 deletions src/monitor-control-service/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:
Release History
===============

0.1.0
++++++
* Initial release.
161 changes: 161 additions & 0 deletions src/monitor-control-service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Azure CLI monitor-control-service Extension
This is the extension for monitor-control-service

### How to use
Install this extension using the below CLI command
```
az extension add --name monitor-control-service
```

### Included Features
#### data-collection rule
##### Create
```
az monitor data-collection rule create --resource-group "myResourceGroup" --location "eastus" --name "myCollectionRule" --data-flows destinations="centralWorkspace" streams="Microsoft-Perf" streams="Microsoft-Syslog" streams="Microsoft-WindowsEvent" --log-analytics name="centralWorkspace" resource-id="/subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.OperationalInsights/workspaces/centralTeamWorkspace" --performance-counters name="cloudTeamCoreCounters" counter-specifiers="\\Processor(_Total)\\% Processor Time" counter-specifiers="\\Memory\\Committed Bytes" counter-specifiers="\\LogicalDisk(_Total)\\Free Megabytes" counter-specifiers="\\PhysicalDisk(_Total)\\Avg. Disk Queue Length" sampling-frequency=15 transfer-period="PT1M" streams="Microsoft-Perf" --performance-counters name="appTeamExtraCounters" counter-specifiers="\\Process(_Total)\\Thread Count" sampling-frequency=30 transfer-period="PT5M" streams="Microsoft-Perf" --syslog name="cronSyslog" facility-names="cron" log-levels="Debug" log-levels="Critical" log-levels="Emergency" streams="Microsoft-Syslog" --syslog name="syslogBase" facility-names="syslog" log-levels="Alert" log-levels="Critical" log-levels="Emergency" streams="Microsoft-Syslog" --windows-event-logs name="cloudSecurityTeamEvents" transfer-period="PT1M" streams="Microsoft-WindowsEvent" x-path-queries="Security!" --windows-event-logs name="appTeam1AppEvents" transfer-period="PT5M" streams="Microsoft-WindowsEvent" x-path-queries="System![System[(Level = 1 or Level = 2 or Level = 3)]]" x-path-queries="Application!*[System[(Level = 1 or Level = 2 or Level = 3)]]"
```
##### Show
```
az monitor data-collection rule show --name "myCollectionRule" --resource-group "myResourceGroup"
```
##### List
List data collection rules by resource group
```
az monitor data-collection rule list --resource-group "myResourceGroup"
```
List data collection rules by subscription
```
az monitor data-collection rule list
```
##### Update
```
az monitor data-collection rule update --resource-group "myResourceGroup" --name "myCollectionRule" --data-flows destinations="centralWorkspace" streams="Microsoft-Perf" streams="Microsoft-Syslog" streams="Microsoft-WindowsEvent" --log-analytics name="centralWorkspace" resource-id="/subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.OperationalInsights/workspaces/centralTeamWorkspace" --performance-counters name="appTeamExtraCounters" counter-specifiers="\\Process(_Total)\\Thread Count" sampling-frequency=30 transfer-period="PT5M" streams="Microsoft-Perf" --syslog name="cronSyslog" facility-names="cron" log-levels="Debug" log-levels="Critical" log-levels="Emergency" streams="Microsoft-Syslog" --windows-event-logs name="cloudSecurityTeamEvents" transfer-period="PT1M" streams="Microsoft-WindowsEvent" x-path-queries="Security!"
```
##### Delete
```
az monitor data-collection rule delete --name "myCollectionRule" --resource-group "myResourceGroup"
```

#### data-collection rule data-flow
##### List
```
az monitor data-collection rule data-flow list --rule-name "myCollectionRule" --resource-group "myResourceGroup"
```
##### Add
```
az monitor data-collection rule data-flow add --rule-name "myCollectionRule" --resource-group "myResourceGroup" --destinations XX3 XX4 --streams "Microsoft-Perf" "Microsoft-WindowsEvent"
```

#### data-collection rule log-analytics
##### List
```
az monitor data-collection rule log-analytics list --rule-name "myCollectionRule" --resource-group "myResourceGroup"
```
##### Show
```
az monitor data-collection rule log-analytics show --rule-name "myCollectionRule" --resource-group "myResourceGroup" --name "centralWorkspace"
```
##### Add
```
az monitor data-collection rule log-analytics add --rule-name "myCollectionRule" --resource-group "myResourceGroup" --name "workspace2" --resource-id "/subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.OperationalInsights/workspaces/workspace2"
```
##### Delete
```
az monitor data-collection rule log-analytics delete --rule-name "myCollectionRule" --resource-group "myResourceGroup" --name "workspace2"
```
##### Update
```
az monitor data-collection rule log-analytics update --rule-name "myCollectionRule" --resource-group "myResourceGroup" --name "workspace2" --resource-id "/subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.OperationalInsights/workspaces/anotherWorkspace"
```

#### data-collection rule performance-counter
##### List
```
az monitor data-collection rule performance-counter list --rule-name "myCollectionRule" --resource-group "myResourceGroup"
```
##### Show
```
az monitor data-collection rule performance-counter show --rule-name "myCollectionRule" --resource-group "myResourceGroup" --name "appTeamExtraCounters"
```
##### Add
```
az monitor data-collection rule performance-counter add --rule-name "myCollectionRule" --resource-group "myResourceGroup" --name "team2ExtraCounters" --streams "Microsoft-Perf" --counter-specifiers "\\Process(_Total)\\Thread Count" "\\LogicalDisk(_Total)\\Free Megabytes" --sampling-frequency 30 --transfer-period PT15M
```
##### Delete
```
az monitor data-collection rule performance-counter delete --rule-name "myCollectionRule" --resource-group "myResourceGroup" --name "team2ExtraCounters"
```
##### Update
```
az monitor data-collection rule performance-counter update --rule-name "myCollectionRule" --resource-group "myResourceGroup" --name "team2ExtraCounters" --transfer-period PT1M
```

#### data-collection rule windows-event-log
##### List
```
az monitor data-collection rule windows-event-log list --rule-name "myCollectionRule" --resource-group "myResourceGroup"
```
##### Show
```
az monitor data-collection rule windows-event-log show --rule-name "myCollectionRule" --resource-group "myResourceGroup" --name "appTeam1AppEvents"
```
##### Add
```
az monitor data-collection rule windows-event-log add --rule-name "myCollectionRule" --resource-group "myResourceGroup" --name "appTeam1AppEvents" --transfer-period "PT1M" --streams "Microsoft-WindowsEvent" --x-path-queries "Application!*[System[(Level = 1 or Level = 2 or Level = 3)]]" "System![System[(Level = 1 or Level = 2 or Level = 3)]]"
```
##### Delete
```
az monitor data-collection rule windows-event-log delete --rule-name "myCollectionRule" --resource-group "myResourceGroup" --name "appTeam1AppEvents"
```
##### Update
```
az monitor data-collection rule windows-event-log update --rule-name "myCollectionRule" --resource-group "myResourceGroup" --name "appTeam1AppEvents" --x-path-queries "Application!*[System[(Level = 1 or Level = 2 or Level = 3)]]"
```

#### data-collection rule syslog
##### List
```
az monitor data-collection rule syslog list --rule-name "myCollectionRule" --resource-group "myResourceGroup"
```
##### Show
```
az monitor data-collection rule syslog show --rule-name "myCollectionRule" --resource-group "myResourceGroup" --name "syslogBase"
```
##### Add
```
az monitor data-collection rule syslog add --rule-name "myCollectionRule" --resource-group "myResourceGroup" --name "syslogBase" --facility-names "syslog" --log-levels "Alert" "Critical" --streams "Microsoft-Syslog"
```
##### Delete
```
az monitor data-collection rule syslog delete --rule-name "myCollectionRule" --resource-group "myResourceGroup" --name "syslogBase"
```
##### Update
```
az monitor data-collection rule syslog update --rule-name "myCollectionRule" --resource-group "myResourceGroup" --name "syslogBase" --facility-names "syslog" --log-levels "Emergency" "Critical"
```

#### data-collection rule association
##### Create
```
az monitor data-collection rule association create --name "myAssociation" --rule-id "/subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Insights/dataCollectionRules/myCollectionRule" --resource "subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm"
```
##### Show
```
az monitor data-collection rule association show --name "myAssociation" --resource "subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm"
```
##### Update
```
az monitor data-collection rule association update --name "myAssociation" --rule-id "/subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Insights/dataCollectionRules/myCollectionRule" --resource "subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm"
```
##### List
List associations for specified data collection rule
```
az monitor data-collection rule association list --rule-name "myCollectionRule" --resource-group "myResourceGroup"
```
List associations for specified resource
```
az monitor data-collection rule association list --resource "subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm"
```
##### Delete
```
az monitor data-collection rule association delete --name "myAssociation" --resource "subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm"
```
50 changes: 50 additions & 0 deletions src/monitor-control-service/azext_amcs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from azure.cli.core import AzCommandsLoader
from azext_amcs.generated._help import helps # pylint: disable=unused-import
try:
from azext_amcs.manual._help import helps # pylint: disable=reimported
except ImportError:
pass


class MonitorClientCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_amcs.generated._client_factory import cf_monitor_control_service_cl
monitor_control_service_custom = CliCommandType(
operations_tmpl='azext_amcs.custom#{}',
client_factory=cf_monitor_control_service_cl)
parent = super(MonitorClientCommandsLoader, self)
parent.__init__(cli_ctx=cli_ctx, custom_command_type=monitor_control_service_custom)

def load_command_table(self, args):
from azext_amcs.generated.commands import load_command_table
load_command_table(self, args)
try:
from azext_amcs.manual.commands import load_command_table as load_command_table_manual
load_command_table_manual(self, args)
except ImportError:
pass
return self.command_table

def load_arguments(self, command):
from azext_amcs.generated._params import load_arguments
load_arguments(self, command)
try:
from azext_amcs.manual._params import load_arguments as load_arguments_manual
load_arguments_manual(self, command)
except ImportError:
pass


COMMAND_LOADER_CLS = MonitorClientCommandsLoader
17 changes: 17 additions & 0 deletions src/monitor-control-service/azext_amcs/action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

from .generated.action import * # noqa: F403
try:
from .manual.action import * # noqa: F403
except ImportError:
pass
4 changes: 4 additions & 0 deletions src/monitor-control-service/azext_amcs/azext_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"azext.isPreview": true,
"azext.minCliCoreVersion": "2.15.0"
}
17 changes: 17 additions & 0 deletions src/monitor-control-service/azext_amcs/custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

from .generated.custom import * # noqa: F403
try:
from .manual.custom import * # noqa: F403
except ImportError:
pass
12 changes: 12 additions & 0 deletions src/monitor-control-service/azext_amcs/generated/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------


def cf_monitor_control_service_cl(cli_ctx, *_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azext_amcs.vendored_sdks.amcs import MonitorClient
return get_mgmt_service_client(cli_ctx,
MonitorClient)


def cf_data_collection_rule_association(cli_ctx, *_):
return cf_monitor_control_service_cl(cli_ctx).data_collection_rule_associations


def cf_data_collection_rule(cli_ctx, *_):
return cf_monitor_control_service_cl(cli_ctx).data_collection_rules
Loading