Monitoring Azure resources with Zabbix

Posted: August 21, 2018 in Azure

I used this post as starting point.

Creating Azure application

(ID/keys will be used for authentication to Azure)

In Azure portal click Azure Active directory-App registrations-new App registration

1.png

2.PNG

In App registrations select All apps from drop-down menu-click on Zabbix application

3.png

Write down application ID (we’ll use it on scripts)

4.png

Click Settings-Keys-set a name,duration and click Save

5.png

Write down key

6.PNG

Write down TenantID

7.png

Write down Subscription ID-from Azure dashboard,click Cost Management + Billing under my subscription write subscription ID

8.png

Give application read rights to resource group

click on resource group-Access control (IAM)

Untitled.png

click Add-select Reader role-Assign access to Azure AD user,group or application and select Zabbix application

2

Install powershell on Zabbix server (CentOS)

# Register the Microsoft RedHat repository
curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
# Install PowerShell
sudo yum install -y powershell

Copy all files in azure.zip to /usr/lib/zabbix/externalscripts, make sure *.sh files are executable

Supported services are SQL,storage account,Virtual Machines and Virtual Network gateway

All available services and metric: https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-supported-metrics

Time periods (monitoring intervals) are called timegrains

time_grains = {
"PT1M" => "1 Minute",
"PT5M" => "5 Minutes",
"PT1H" => "1 Hour",
"PT12H" => "12 Hours"
}

In trapper.ps1 and azure.ps1 substitute TenantID,applicationID, application key in appropriate sections/

Files can be downloaded from here

Testing

For VM:

./azure.sh resource group subscription vm

For SQL:

./azure.sh resource group subscription sql

For network gateway:

./azure.sh resource group subscription vng

For Storage account

./azure.sh resource group subscription storage

[root@ip-172-31-27-77 externalscripts]# ./azure.sh RG  subscriptionD storage
{"data":[
{
"{#ID}": "/subscriptions/111-222-333/resourceGroups/RG/providers/Microsoft.Storage/storageAccounts/storageaccount",
"{#STORAGEACCOUNT}": "storageaccount"
},
{
"{#ID}": "/subscriptions/111-222-333/resourceGroups/RG/providers/Microsoft.Storage/storageAccounts/storageaccount",
"{#STORAGEACCOUNT}": "storageaccount"
},
{
"{#ID}": "/subscriptions/111-222-333/resourceGroups/RG/providers/Microsoft.Storage/storageAccounts/storageaccount",
"{#STORAGEACCOUNT}": "storageaccount"
}
]
}

give ownership of azure.json to zabbix user:

chown zabbix:zabbix azure.json

create dummy host and attach template, specify resource group and subscription ID

9.PNG

Test zabbix trapper:

./trapper.sh zabbix-dummy-host

if no issues,create cron job for trapper (for example to run it every 15 minutes):

*/15 * * * * /usr/lib/zabbix/externalscripts/trapper.sh dummy-host

Advertisements
Comments
  1. Uladzislau Dadzimau says:

    I believe you might want to put a back-link to the original source of your code:

    https://b-blog.info/en/monitoring-azure-resources-with-zabbix.html

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s