README: add sample Grafana panel
META: add README + update gitignore
neosApiClient: dirty fix for comma when multiple users specified
This small project is made as a temporary band-aid to export player stats of Headlesses to Prometheus in order to plan events better.
Dependencies:
Getting started:
git clone https://git.sr.ht/~jae/neos-metrics-exporter
cd neos-metrics-exporter
yarn
yarn dev
You should now be able to access the solution on https://localhost:3001
For production setup, it is recommended using Docker.
You can either build your own image or use the prebuilt one at rg.nl-ams.scw.cloud/jaexencont/nme:latest
.
Example of docker-compose.yml
file:
version: '3.9'
services:
nme:
image: rg.nl-ams.scw.cloud/jaexencont/nme:latest
environment:
- NODE_ENV=production
- USERS=j4,SynthImperium
Then into your Prometheus config (assumes Prometheus is running within the same Docker network):
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'nme'
scrape_interval: 15s
static_configs:
- targets: ['nme:3001']
An example of Grafana panel displaying player count per-session:
{
"datasource": {
"type": "prometheus",
"uid": "efbaf15f-f925-4085-90ec-1f89f671015a"
},
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "linear",
"barAlignment": 0,
"lineWidth": 1,
"fillOpacity": 0,
"gradientMode": "none",
"spanNulls": false,
"showPoints": "auto",
"pointSize": 5,
"stacking": {
"mode": "none",
"group": "A"
},
"axisPlacement": "auto",
"axisLabel": "",
"axisColorMode": "text",
"scaleDistribution": {
"type": "linear"
},
"axisCenteredZero": false,
"hideFrom": {
"tooltip": false,
"viz": false,
"legend": false
},
"thresholdsStyle": {
"mode": "off"
}
},
"color": {
"mode": "palette-classic"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 13,
"w": 12,
"x": 12,
"y": 5
},
"id": 264,
"options": {
"tooltip": {
"mode": "single",
"sort": "none"
},
"legend": {
"showLegend": true,
"displayMode": "list",
"placement": "bottom",
"calcs": []
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "efbaf15f-f925-4085-90ec-1f89f671015a"
},
"editorMode": "builder",
"exemplar": false,
"expr": "player_count{label!=\"total\"}",
"legendFormat": "{{label}}",
"range": true,
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "efbaf15f-f925-4085-90ec-1f89f671015a"
},
"editorMode": "code",
"expr": "sum(player_count{label=\"total\"})",
"hide": false,
"legendFormat": "Total",
"range": true,
"refId": "B"
}
],
"title": "Player Count",
"type": "timeseries"
}