Skip to content

Commit 11d4023

Browse files
authored
Merge pull request #46281 from axelgMS/patch-28
adding Powershell sample
2 parents 285afa8 + 223281c commit 11d4023

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

articles/virtual-machines/extensions/diagnostics-linux.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,85 @@ az vm extension set --publisher Microsoft.Azure.Diagnostics --name LinuxDiagnost
8686

8787
The URL for the sample configuration, and its contents, are subject to change. Download a copy of the portal settings JSON file and customize it for your needs. Any templates or automation you construct should use your own copy, rather than downloading that URL each time.
8888

89+
#### PowerShell sample
90+
91+
```Powershell
92+
// Set your Azure VM diagnostics variables correctly below - don't forget to replace the VMResourceID
93+
94+
$SASKey = '<SASKeyForDiagStorageAccount>'
95+
96+
$ladCfg = "{
97+
'diagnosticMonitorConfiguration': {
98+
'performanceCounters': {
99+
'sinks': 'WADMetricEventHub,WADMetricJsonBlob',
100+
'performanceCounterConfiguration': [
101+
{
102+
'unit': 'Percent',
103+
'type': 'builtin',
104+
'counter': 'PercentProcessorTime',
105+
'counterSpecifier': '/builtin/Processor/PercentProcessorTime',
106+
'annotation': [
107+
{
108+
'locale': 'en-us',
109+
'displayName': 'Aggregate CPU %utilization'
110+
}
111+
],
112+
'condition': 'IsAggregate=TRUE',
113+
'class': 'Processor'
114+
},
115+
{
116+
'unit': 'Bytes',
117+
'type': 'builtin',
118+
'counter': 'UsedSpace',
119+
'counterSpecifier': '/builtin/FileSystem/UsedSpace',
120+
'annotation': [
121+
{
122+
'locale': 'en-us',
123+
'displayName': 'Used disk space on /'
124+
}
125+
],
126+
'condition': 'Name='/'',
127+
'class': 'Filesystem'
128+
}
129+
]
130+
},
131+
'metrics': {
132+
'metricAggregation': [
133+
{
134+
'scheduledTransferPeriod': 'PT1H'
135+
},
136+
{
137+
'scheduledTransferPeriod': 'PT1M'
138+
}
139+
],
140+
'resourceId': '<VMResourceID>'
141+
},
142+
'eventVolume': 'Large',
143+
'syslogEvents': {
144+
'sinks': 'SyslogJsonBlob,LoggingEventHub',
145+
'syslogEventConfiguration': {
146+
'LOG_USER': 'LOG_INFO'
147+
}
148+
}
149+
}
150+
}"
151+
$ladCfg = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($ladCfg))
152+
$perfCfg = "[
153+
{
154+
'query': 'SELECT PercentProcessorTime, PercentIdleTime FROM SCX_ProcessorStatisticalInformation WHERE Name='_TOTAL'',
155+
'table': 'LinuxCpu',
156+
'frequency': 60,
157+
'sinks': 'LinuxCpuJsonBlob'
158+
}
159+
]"
160+
161+
// Get the VM Resource
162+
Get-AzureRmVM -ResourceGroupName <RGName> -VMName <VMName>
163+
164+
// Finally tell Azure to install and enable the extension
165+
Set-AzureRmVMExtension -ExtensionType LinuxDiagnostic -Publisher Microsoft.Azure.Diagnostics -ResourceGroupName <RGName> -VMName <VMName> -Location <Location> -Name LinuxDiagnostic -Settings @{'StorageAccount'='<DiagStorageAccount>'; 'sampleRateInSeconds' = '15' ; 'ladCfg'=$ladCfg; 'perfCfg' = $perfCfg} -ProtectedSettings @{'storageAccountName' = '<DiagStorageAccount>'; 'storageAccountSasToken' = $SASKey } -TypeHandlerVersion 3.0
166+
```
167+
89168
### Updating the extension settings
90169

91170
After you've changed your Protected or Public settings, deploy them to the VM by running the same command. If anything changed in the settings, the updated settings are sent to the extension. LAD reloads the configuration and restarts itself.

0 commit comments

Comments
 (0)