csgo_exporter

command module
v0.0.0-...-a1b8ec1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

README

CSGO Exporter banner

CSGO Exporter

GitHub release (latest by date) Go Reference Go Report Card CodeFactor Test / Build Docker Pulls GitHub all releases

This is a Prometheus exporter for Counter-Strike: Global Offensive. It provides statistics from diverse categories, including last matches.

An example of the output of this exporter can be found here.

Grafana Dashboard

This wouldn't be an exporter without its corresponding Grafana Dashboard.

Grafana Dashboard

This dashboard can be found with the ID 14629 using the Grafana import (dashboard link) or here in plain text.

Prerequisites

One of the two, depending on your running method.

Running this exporter

See Configuration in order to set the necessary params to run the exporter.

Using a binary

You can download the latest version of the binary built for your architecture here.

Using Docker

The exporter is also available as a Docker image in DockerHub and Github CR. You can run it using the following example and pass the configuration as environment variables:

$ docker run \
  --name csgo_exporter \
  -p 7355:7355 \
  -e STEAM_API_KEY=<your-api-key> \
  -e STEAM_NAME=<your-user-name> \
  -e STEAM_ID=<your-user-id> \
  kinduff/csgo_exporter:latest

Alternative, you can use ghcr.io/kinduff/csgo_exporter if you want to use the Github Container Registry.

Using the source

Optionally, you can download and build it from the sources. You have to retrieve the project sources by using one of the following way:

$ go get -u github.com/kinduff/csgo_exporter
# or
$ git clone https://github.com/kinduff/csgo_exporter.git

Install the needed vendors:

$ GO111MODULE=on go mod vendor

Then, build the binary:

$ go build -o csgo_exporter .

Configuration

You can use both environment variables or parameters in both the binary or the docker image. If you wish to use parameters, simply invoke the same environment variable but in downcase, or use the flag --help for more information.

Environment variable Description Default Required
HTTP_PORT The port the exporter will be running the HTTP server 73551
SCRAPE_INTERVAL Time in natural format to scrap statistics from the CS:GO APIs 15m
STEAM_API_KEY Your personal API key from Steam, get one using this link Yes
STEAM_ID 2 The Steam ID you want to fetch the data from for the player statistics Yes
STEAM_NAME If you don't want to provide a STEAM_ID you can provide your username, see the footnotes
FETCH_INVENTORY Boolean to determine if the exporter should fetch the player's inventory3 false
CURRENCY The price currency to display the average cost of the player inventory items EUR

Available Prometheus metrics

Metric name Description
csgo_stats_metric All the stats from the player, it includes last_match data, totals per weapon, among other cool things
csgo_total_kills_metric Total kills from a player per weapon
csgo_total_shots_metric Total shots from a player per weapon
csgo_total_hits_metric Total hits from a player per weapon
csgo_achievements_metric All achievements done by the player, with value 1 or 0 for achieved or not
csgo_playtime_metric Hours spent playing the game in minutes in different types, includes stats for each OS
csgo_news_metric The latest news from the CS: GO community, can be used in a table. Value is an epoch
csgo_user_inventory_metric The player's inventory and the cost of each item. Value is the average cost in the desired currency.

Contributors

Thanks goes to these wonderful people who had contributed to the project:

Simon Szustkowski
Simon Szustkowski

🖋
Oleg Zaytsev
Oleg Zaytsev

🖋
Jack
Jack

💻

Footnotes

  • [1]: This port is being assigned for fun, since the bomb code from Counter Strike is 7355608.
  • [2]: Please note that the STEAM_ID environment variable is not required if you provide a STEAM_NAME. If you want to save 1 HTTP call, provide both variables.
  • [3]: Inventory should be public, if it's not, the request will fail and the program will exit.

Documentation

Overview

Package main takes care of the initialization of the application.

Directories

Path Synopsis
Package config takes care of loading and exposing user configuration.
Package config takes care of loading and exposing user configuration.
internal
client
Package client takes care of JSON & XML API requests.
Package client takes care of JSON & XML API requests.
collector
Package collector handles the orchestration between the API and Prometheus.
Package collector handles the orchestration between the API and Prometheus.
data
Package data holds general data about CS:GO to be used as utils.
Package data holds general data about CS:GO to be used as utils.
handlers
Package handlers implements utility functions to respond and be passed to the http pkg.
Package handlers implements utility functions to respond and be passed to the http pkg.
metrics
Package metrics sets and initializes Prometheus metrics.
Package metrics sets and initializes Prometheus metrics.
model
Package model which provides structs to be used with the CSGO API.
Package model which provides structs to be used with the CSGO API.
server
Package server provides an HTTP server to serve the metrics and other endpoints.
Package server provides an HTTP server to serve the metrics and other endpoints.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL