statfactory

by ftvkyo

Exports live game metrics (production, pollution, evolution, kills, players, and more) to Prometheus for use with Grafana.

Utilities
2 months ago
2.1
18

Changelog

Version: 0.0.10
Date: 2026-09-13
  Bugfixes:
    - Fix a crash ("Arguments count error for 'get_inventory': Expected 1 argument but 2 were
      given") on every cargo pod launch, introduced in 0.0.7. snapshot_cargo_contents called
      cargo_pod:get_inventory(...)/inventory:get_contents() with colon syntax, which passes an
      extra implicit self argument on top of the real one - unlike this file's own gauge/counter
      objects (real Lua OOP, colon genuinely required), Factorio's own API methods here need dot
      syntax with only the real argument, matching every other Factorio API call already in this
      file (e.g. force.get_kill_count_statistics(surface)). Audited every other method call in
      the file for the same mistake; found no others.
Version: 0.0.8
Date: 2026-09-13
  Features:
    - Track each player's identity color (player_color) as a #rrggbb hex label, so a
      Grafana "Config from query results" transform can dynamically color other panels'
      per-player series to match, instead of a hand-maintained static override per player.
Version: 0.0.7
Date: 2026-09-13
  Features:
    - Track trains by state per surface (train_state), to spot stuck or congested rail networks at
      a glance.
    - Track seconds since the last train arrived at a station (train_arrival_time), and per-leg
      trip/wait time between stations (train_trip_time, train_wait_time).
    - Track items launched and delivered via cargo pod (items_launched, items_delivered), to catch
      cargo that launches but never arrives.
    - Track space platforms by state (platform_state).
    - Track physical train-stop entities by name (train_stops) - several stops commonly share one
      logical name, so this also indicates how many stops each train_arrival_time/train_trip_time/
      train_wait_time station label aggregates across.
Version: 0.0.6
Date: 2026-09-12
  Bugfixes:
    - Fix a crash ("Collector id `factorio_players_connected` is already registered") on every
      existing save on upgrade to 0.0.5 — its on_configuration_changed fix called all of init(),
      including load(), duplicating the registration on_load already made moments earlier in the
      same startup. Storage backfill is now its own function, called alone from
      on_configuration_changed.
Version: 0.0.5
Date: 2026-09-12
  Bugfixes:
    - Fix a crash ("attempt to index field 'current_research' (a nil value)") on every save that
      was started before 0.0.4 added storage.current_research — that field was only backfilled on
      on_init, which never re-runs for an existing save. Now also backfilled via
      on_configuration_changed, which does.
Version: 0.0.4
Date: 2026-09-12
  Features:
    - Track research progress and the currently active technology per force.
  Changes:
    - Refresh pollution, evolution, kills, and production every second instead of every 10 seconds,
      matching the export interval — only the area_paved drift correction stays on its own (5 minute)
      timer, since it recounts tiles across the whole surface.
Version: 0.0.3
Date: 2026-09-05
  Features:
    - Track item and fluid production/consumption per surface and force.
  Bugfixes:
    - Correct area_paved drift caused by nukes/reactor explosions destroying tiles outside the
      normal built/mined tile events.
    - Populate player count gauges immediately on init instead of waiting for the first join/leave
      event.
    - Fix misleading/incorrect assert messages in the Prometheus library.
  Changes:
    - Update to Factorio 2.1.
Version: 0.0.2
Date: 2025-08-30
  Features:
    - Track kills per surface, force, and entity.
Version: 0.0.1
Date: 2025-08-22
  Major Features:
    - Initial release.
    - Track connected/total players and player deaths.
    - Track area paved per surface and tile type.
    - Track pollution level, production, and consumption per surface.
    - Track evolution factor per surface, broken down by cause.
    - Track rockets launched and researches finished.