Que tal usar Observability para algo diferente? Nesse post nós usaremos nossas ferramentas para monitorar como nossos jogos estão performando. Hoje nos exploraremos como usar o Elastic Agent para monitorar um Steam Deck, o que nos permitirá ver o que jogamos mais, o quanto de recurso eles usam e como a GPU está performando.
Nós iremos ver:
A System Integration já coleta todos os dados que precisamos sobre os processos que estão rodando. Nós usaremos esses dados para ver quanto de recurso os processos usam e os jogos mais jogados.
De modo geral Observability data não inclui dados sobre a performance da CPU ou GPU. É possÃvel coletar dados de NVIDIA GPUs, mas o Steam Deck usa uma GPU AMD personalizada, e nós queremos botar a mão na massa também.
Linux distros normalmente incluem lm_sensors e ele está presente no Steam OS. Isso será suficiente para coletar toda a informação que precisamos.
Rodando sensors
no meu Steam Deck, esse é o resultado:
nvme-pci-0100
Adapter: PCI adapter
Composite: +45.9°C (low = -273.1°C, high = +82.8°C)
(crit = +84.8°C)
Sensor 1: +45.9°C (low = -273.1°C, high = +65261.8°C)
BAT1-acpi-0
Adapter: ACPI interface
in0: 8.40 V
curr1: 1.74 A
amdgpu-pci-0400
Adapter: PCI adapter
vddgfx: 650.00 mV
vddnb: 655.00 mV
edge: +44.0°C
slowPPT: 7.12 W (avg = 11.10 W, cap = 15.00 W)
fastPPT: 11.10 W (cap = 15.00 W)
steamdeck_hwmon-isa-0000
Adapter: ISA adapter
PD Contract Voltage: 5.00 V
System Fan: 0 RPM
Battery Temp: +25.0°C
PD Contract Current: 1000.00 mA
acpitz-acpi-0
Adapter: ACPI interface
temp1: +54.0°C (crit = +105.0°C)
Tudo que precisamos está aqui, mas não no melhor formato para coletar esses dados. Então usaremos a versão em JSON, basta rodar sensors -j
:
{
"nvme-pci-0100":{
"Adapter": "PCI adapter",
"Composite":{
"temp1_input": 31.850,
"temp1_max": 82.850,
"temp1_min": -273.150,
"temp1_crit": 84.850,
"temp1_alarm": 0.000
},
"Sensor 1":{
"temp2_input": 31.850,
"temp2_max": 65261.850,
"temp2_min": -273.150
}
},
"BAT1-acpi-0":{
"Adapter": "ACPI interface",
"in0":{
"in0_input": 8.656
},
"curr1":{
"curr1_input": 0.159
}
},
"amdgpu-pci-0400":{
"Adapter": "PCI adapter",
"vddgfx":{
"in0_input": 0.650
},
"vddnb":{
"in1_input": 0.655
},
"edge":{
"temp1_input": 41.000
},
"slowPPT":{
"power1_average": 2.072,
"power1_input": 2.040,
"power1_cap": 15.000
},
"fastPPT":{
"power2_average": 2.072,
"power2_cap": 15.000
}
},
"steamdeck_hwmon-isa-0000":{
"Adapter": "ISA adapter",
"PD Contract Voltage":{
"in0_input": 5.000
},
"System Fan":{
"fan1_input": 1522.000,
"fan1_fault": 0.000
},
"Battery Temp":{
"temp1_input": 25.000
},
"PD Contract Current":{
"curr1_input": 1.000
}
},
"acpitz-acpi-0":{
"Adapter": "ACPI interface",
"temp1":{
"temp1_input": 42.000,
"temp1_crit": 105.000
}
}
}
Não é possÃvel ter o Elastic Agent rodando comandos arbitrários e processando o que eles retornam, então nós precisaremos de um servidorzinho HTTP que colete e retorne esses dados.
Eu fiz um em Go, acesse GitHub - AndersonQ/steamdeck-sensors-api e instale ou faça sua própria versão dele.
Agora nós podemos configurar o Elastic Agent para coletar os dado dessa API. Para garantir que ele estará sempre rodando, steamdeck-sensors-api
tem um instalador que instala e registra ele como um serviço usando systemd
.
Agora que temos todos os dados que precisamos, é hora de coletá-los.
Instale um Elastic Agent. A System
integration é adicionada por padrão em toda policy criada. Crie uma nova policy, eu usarei Steam Deck
como o nome da minha, e instale um Elastic Agent no seu Steam Deck
De uma olhada no FAQ pra ver como desativar o modo read only usando sudo steamos-readonly disable
. Caso você tenha esquecido a senha do root
, crie uma nova senha seguindo esse tutorial.
Now we have an agent and a policy, we can add and configure the Custom API integration
Go to Management > Integrations and search for "custom api":
Add it to your Steam Deck policy and let's configure it:
system.gpu
http://localhost:4242/gpu
30s
- you can choose another interval if you prefer. To start playing with it and testing visualisations I used 1s
to see new data in real time.GET
- decode_json_fields:
fields: ["message"]
target: "system.gpu"
overwrite_keys: true
add_error_key: true
expand_keys: true
The processor is crucial for formatting the final event correctly. Without it, the steamdeck-sensors-api
response would be a string in the message
field.
Now save and add the integration to your Steam Deck policy. If you already installed the agent, it'll automatically deploy the newly updated policy, if you haven't installed it yet, go and install the agent.
Go to Discover, select the metrics-*
data view. Filter for event.dataset :"system.process"
. Then, add process.name
, system.process.cpu.total.pct
and system.process.memory.size
. Open some game on your Steam Deck and try to find it among all the process metrics.
For the GPU data, go to the logs-*
data view and filter for event.dataset :"system.process"
Now we just need to create a dashboard.
Here is the dashboard I created:
Astro-Win64-Shi
is Astroneer, great game, I totally recommend it.
You can import this dashboard, it's on my github repo. I'll explain how to import it in a bit. But first let's see how to create a dashboard and add it a visualisation to it.
Go to `Dashboards > Create dashboard
In the query bar, add a filter to display data only from your Steam Deck. Filter by host.hostname : "steamdeck"
, adjusting the hostname
if you've changed it on your device."
Click on Create visialization
Select the metrics-*
dataview
search for process.cpu
drag and drop system.process.cpu.total.pct
to the drop area
it'll create a chart like this:
process.name
, and set "Number of values" to 15, then close the panelit should be like that:
Now lets create one for the most played games.
process.working_directory.text :"/home/deck/.local/share/Steam/steamapps/common/*"
. This query on process.working_directory
will limit the process metrics to only the process which working directory is /home/deck/.local/share/Steam/steamapps/common/*
. This should be the path for all your installed games. Depending on your setup, if you have an SD card, it might change. So if this does not work for you, try checking the process metrics, find the one for your games and see which working_directory
they're using.process.name
to the drop areaIt should be like that before you click on "Save and Return"
The dashboard will look like:
To build visualisations with the GPU data, select the logs-*
data view and filter for event.dataset : "system.gpu"
, like that:
I'll leave the creation of the other visualizations as an exercise for you.
You can import the dashboards with the /api/kibana/dashboards/import
Kibana Dashboard API
curl -u USER:PASSWORD -H 'Content-Type: application/json' -H 'kbn-xsrf: true' -X POST https://YOUR-KIBANA-HOST/api/kibana/dashboards/import\?exclude\=index-pattern -d "@stead-deck-dashboard.ndjson"
Get the dashboard to import here.
To export a dashboard, use
curl -u USER:PASSWORD -H 'Content-Type: application/json' -H 'kbn-xsrf: true' https://YOUR-KIBANA-HOST/api/kibana/dashboards/export\?dashboard=bfcd09b3-effe-4a65-b58b-b6c3d528cc3e > steam-deck-dashboard.ndjson
To find the dashboard ID, open the dashboard, check the URL, it'll be something like that:
https://KIBANA-HOST/app/dashboards#/view/<dashboard-id>?
https://KIBANA-HOST/app/dashboards#/view/bfcd09b3-effe-4a65-b58b-b6c3d528cc3e?
It's great fun to use the Elastic Stack to monitor my Steam Deck, gaining insights into its performance, how games utilize resources, and identifying running programs and game binaries.
Most importantly, it's a fun way to get started with the Elastic Agent, ingesting monitoring data, and creating visualizations and dashboards. It also provides a glimpse into the vast amount of data we can collect, inspiring different ways to use it.
You can grab a free trial on Elastic Cloud or easily run your own Elastic Stack on Docker or download and run it manually.
1 post - 1 participant