Azure / batch-insights

One liners to enable Application insights on azure batch
MIT License
24 stars 16 forks source link

Batch Insights

PROJECT STATUS

This project is no longer actively maintained. Please see the main Azure Batch GitHub repository for more information about Azure Batch.

Build Status

Azure Batch Insights is a tool used to get system statistics for your Azure Batch account nodes.

Usage (New)

Create Application Insights account

  1. Goto the Azure portal
  2. Search for Application Insights
  3. Create or use an existing one(Application type input doesn't matter)

Configure your Azure Batch pool start task

Set 3 environment variables in your start task. Make sure this is set as a Batch environment variable rather than exporting. Without the Batch environment variable it will not show up in Batch Explorer. Then set the start task user to be Pool Admin(Task admin might work too)

On the application insight blade in the Azure Portal

On the application insight blade in the Azure Portal

For example:

Linux

Add this to your start task

# For version 1.x of batch insights
/bin/bash -c 'wget  -O - https://raw.githubusercontent.com/Azure/batch-insights/master/scripts/1.x/run-linux.sh | bash'

# For latest version of batch insights
/bin/bash -c 'wget  -O - https://raw.githubusercontent.com/Azure/batch-insights/master/scripts/run-linux.sh | bash'

Windows

Add this to your start task

# For version 1.x of batch insights
cmd /c @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/Azure/batch-insights/master/scripts/1.x/run-windows.ps1'))"

# For latest version of batch insights
cmd /c @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/Azure/batch-insights/master/scripts/run-windows.ps1'))"

Note: The script used above just downloads the executable at the BATCH_INSIGHTS_DOWNLOAD_URL URL and run it in the background. You can download it some other way and start it separately.

Python Usage (Old)

Ubuntu

Add this command in your start task commandLine:

/bin/bash -c 'wget  -O - https://raw.githubusercontent.com/Azure/batch-insights/master/ubuntu.sh | bash'

Centos

Add this command in your start task commandLine:

/bin/bash -c 'wget  -O - https://raw.githubusercontent.com/Azure/batch-insights/master/centos.sh | bash'

Windows

cmd /c @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/Azure/batch-insights/master/windows.ps1'))"

Generic

If you already have a version of python installed you just need to download nodestats.py and install dependencies You can add this to your main script:

pip install psutil python-dateutil applicationinsights==0.11.3
wget --no-cache https://raw.githubusercontent.com/Azure/batch-insights/master/nodestats.py
python --version
python nodestats.py > batch-insights.log 2>&1 &

Configuration

See available configuration options

You can set the AZ_BATCH_INSIGHTS_ARGS environemnt variable to pass parameters to the tool. e.g. AZ_BATCH_INSIGHTS_ARGS > --disable networkIO --aggregation 5

View data

Option 1: Batch Explorer

BatchLabs is a desktop app used to manage, debug and monitor your azure batch accounts. You can download it here If you followed the getting started instruction batchlabs should show you the statistics for each of your pool.

Option 2:

Use the app insights tools to build your own query on the Azure Portal

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.