Skip to content

Latest commit

 

History

History

linux_metrics_telegraf_azuremonitor

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Linux metrics with telegraf and Azure Monitor

Introduction

Telegraf is a plugin-driven server agent for collecting and reporting metrics. It supports a wide variety of inputs, processors, aggregators, and outputs.

Azure Monitor helps you maximize the availability and performance of your applications and services. It delivers a comprehensive solution for collecting, analyzing, and acting on telemetry from your cloud and on-premises environments. This information helps you understand how your applications are performing and proactively identify issues that affect them and the resources they depend on.

You can see documentation about Azure Monitor output telegraf plugin here.

What it does

This script uses telegraf agent to capture and send VM metrics (CPU/Disk/Mem/Network) to Azure Monitor. The telegraf agent publishes custom metrics using the Azure Monitor REST API (preview). Custom metrics are available in these regions. This script is applicable if you are running Linux MPS Builds using containers or processes for your game servers.

Usage

You should download telegraf from the GitHub releases section. The Debian amd64 package works with this sample.

You should create an Azure resource where the Azure Monitor metrics will be published to. For our sample, we created a VMSS (Virtual Machine Scaleset resource) with 0 Virtual Machines (so there is no compute charge). Once you do that, you should copy the resource ID (and, optionally, the region) and add it to the telegraf.conf file.

We need telegraf to be able to authenticate to Azure Monitor on your subscription so it can post the metrics. Out of the supported methods, we'll use the service principal authentication. You can use the Azure CLI to create a service principal with the "Monitoring Metrics Publisher" role for the subscription that metrics will be published against - the subscription that contains the VMSS resource you created. The subscription ID can be retrieved using az account list or from the Azure portal.

az ad sp create-for-rbac --role="Monitoring Metrics Publisher" --scopes="/subscriptions/<replace-with-subscription-id>"

On success, the output will look similar to:

{
    "appId": "xxx",         // AZURE_CLIENT_ID
    "displayName": "xxx",
    "name": "xxx",
    "password": "xxx",      // AZURE_CLIENT_SECRET
    "tenant": "xxx"         // AZURE_TENANT_ID
}

Add these values to the PF_StartupScript.sh file. Then, create a zip file with the following contents:

  • telegraf.conf
  • telegraf package file (e.g. telegraf_1.24.4-1_amd64.deb)
  • PF_StartupScript.sh file

You can now create a new MPS Build with your startup script using the instructions here.

Linux metrics with telegraf and Azure Monitor
Linux metrics with telegraf and Azure Monitor