Skip to content

Commit

Permalink
fix for previous PR
Browse files Browse the repository at this point in the history
  • Loading branch information
dgkanatsios committed Feb 12, 2024
1 parent e645e2d commit 609dd5b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 29 deletions.
42 changes: 42 additions & 0 deletions windows_logs_telegraf_playfab/PF_StartupScript.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<#
.SYNOPSIS
<Overview of script>
.DESCRIPTION
<Brief description of script>
.NOTES
Version: 1.0
Author: <Name>
Creation Date: <Date>
Purpose/Change: Initial script development
#>

# Set Error Action to Stop
$ErrorActionPreference = "Stop"

# Grab the script path
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
echo "the current script path is $scriptPath"

# these are some of the env variables that are available to you
echo "PlayFab Title ID is $env:PF_TITLE_ID" # e.g. 59F84
echo "PlayFab Build ID is $env:PF_BUILD_ID" # Guid, e.g. 09d91059-22d3-4d0a-8c99-f34f80525aae
echo "PlayFab Virtual Machine ID is $env:PF_VM_ID" # e.g. vmss:SouthCentralUs:2458795A9259968E_12fe54be-fae1-41aa-83d9-09b809d5ef01:09d91059-22d3-4d0a-8c99-f34f80525aae
echo "Region where the VM is deployed is $env:PF_REGION" # e.g. SouthCentralUs

$telegrafConfPath = "$scriptPath\telegraf.conf"
((Get-Content -path $telegrafConfPath -Raw) -replace '_%PF_TITLE_ID%_', "$env:PF_TITLE_ID") | Set-Content -Path $telegrafConfPath
((Get-Content -path $telegrafConfPath -Raw) -replace '_%PF_BUILD_ID%_', "$env:PF_BUILD_ID") | Set-Content -Path $telegrafConfPath
((Get-Content -path $telegrafConfPath -Raw) -replace '_%PF_VM_ID%_', "$env:PF_VM_ID") | Set-Content -Path $telegrafConfPath

$telegrafPath = 'C:\Program Files\telegraf'
New-Item -ItemType Directory -Force -Path "$telegrafPath"
cp "$scriptPath\telegraf.*" "$telegrafPath"
cd "$telegrafPath"
.\telegraf.exe --service install --config "$telegrafPath\telegraf.conf"

$registryPath = "HKLM:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\telegraf"
$values = @("AZURE_TENANT_ID=", "AZURE_CLIENT_ID=", "AZURE_CLIENT_SECRET=")
New-ItemProperty -Path $registryPath -Name "Environment" -Value $values -PropertyType MultiString -Force

# start the telegraf service
.\telegraf.exe --service start
28 changes: 0 additions & 28 deletions windows_logs_telegraf_playfab/PF_StartupScript.sh

This file was deleted.

2 changes: 1 addition & 1 deletion windows_logs_telegraf_playfab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You can see documentation about [Telegraf output plugin for PlayFab here](https:

## What it does

This script uses [telegraf](https://www.influxdata.com/time-series-platform/telegraf/) agent to grab game server logs emitted via the [Game Server SDK (GSDK)](https://github.com/playfab/gsdk) and send them to PlayFab. GSDK logs from game servers are written in paths `"D:\\GameLogs\\*\\GSDK_output_*.txt"`. These text files contents' are grabbed by the [tail](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/tail/README.md) telegraf plugin and converted to proper telegraf metrics via the [grok](https://docs.influxdata.com/telegraf/v1.26/data_formats/input/grok/) format. Finally, the [Telegraf output plugin for PlayFab here](https://github.com/dgkanatsios/telegraftoplayfab) pushes these logs to PlayFab.
This script uses [telegraf](https://www.influxdata.com/time-series-platform/telegraf/) agent to grab game server logs emitted via the [Game Server SDK (GSDK)](https://github.com/playfab/gsdk) and send them to PlayFab. GSDK logs from game servers are written in paths `"D:\\GameLogs\\*\\GSDK_output_*.txt"`. Content in these text files is grabbed by the [tail](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/tail/README.md) telegraf plugin and converted to proper telegraf metrics via the [grok](https://docs.influxdata.com/telegraf/v1.26/data_formats/input/grok/) format. Finally, the [Telegraf output plugin for PlayFab here](https://github.com/dgkanatsios/telegraftoplayfab) pushes these logs to PlayFab.

This script is applicable if you are running Windows MPS Builds using Windows game servers.

Expand Down

0 comments on commit 609dd5b

Please sign in to comment.