remijouannet / graftorio2

(fork of graftorio) factorio mod for creating grafana dashboard
MIT License
77 stars 21 forks source link

Refined power metrics #21

Open ben-thul opened 1 year ago

ben-thul commented 1 year ago

Is it possible to get all of the information that's available in the in-game power dashboard through grafana? For example, I see that I can get per entity type (e.g. 'radar', 'pumpjack') consumption stats, but do I detect an underpower situation? The in-game dashboard will show XW/YW (hopefully X=Y).

Similarly, I can see the power being produced on a per entity type (e.g. 'solar panel', 'steam turbine') but how do I detect if I'm getting close to not producing enough to satisfy demand? The in-game dashboard shows maximum production capacity for a given network in addition to how much is currently being used.

Rounding out what I see in the in-game dashboard but cannot find in the grafana metrics is accumulator charge statistics. I see how much power is being consumed/produced by them, but not charge over time.

Having these would be useful in preventing and detecting power issues. Thanks for everything so far!

Kariton commented 1 year ago

you mean like this?

Consumption

sum by (name) (rate(factorio_power_production_input[$__rate_interval]))

Production

sum by (name) (rate(factorio_power_production_output[$__rate_interval]))

It totally is. You might want to have a look at #11

ben-thul commented 1 year ago

I don't think it is. Comparing what comes out of those queries with what is shown in the in game dashboard, it looks like what those bring back is what is currently being produced, not what is capable of being produced. For example, in my current game I am producing 768 MW but am capable of producing 1.2 GW (see screenshot). Both numbers are interesting. image

Kariton commented 1 year ago

Oh - I misunderstood you at some point.

Yeah, a "capable of production" metric is indeed missing. As well as accumulator charge. Both would be extremely helpful.

I have a graph were I tried to "see" power issues. Haven't verified yet that I could actually see power outages.

sum(rate(factorio_power_production_output[$__rate_interval]))) - (
    sum(rate(factorio_power_production_input[$__rate_interval])

image

Maybe it would not fluctuate that way or something.

ben-thul commented 1 year ago

In my ideal, I'd be able to set up a dashboard panel with production potential minus consumption and, when that's within some threshold (whether that's percentage-based or something like "less than half the output of a solar power city block"), that would be signal to address what is about to be a power issue.