Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Prometheus support v2 #342

Open
wants to merge 76 commits into
base: master
Choose a base branch
from

Conversation

SchumacherFM
Copy link

This is a refactored version of #195 by @kereis

  • Updates to the status screen of the webinterface to add model and SN
  • Remove too many prometheus measurements like: monitoring websocket connections, modbus connections but keeps of course all modbus measured values
  • some other minor refactorings

This PR runs at the moment at my home with SolarEdge SE10K, SE17K and the Meter.

vkz-screen-new

IMHO #195 can be closed.

Waiting for your review(s).

If you open this project in GoLand, it will create a .idea/ directory which could have been tracked by Git.
Some metrics are implemented in handler.go and scan.go.
Each metrics is accessible via global variable.
Helper method UpdateMeasurementMetric adds flexibility to updating specific measurement without hardcoding Prometheus Metric in certain places.
When using newGaugeOpts/newCounterOpts, all objects will share the same namespace "mbmd"
…auges of measurements

Instead of creating a new counter/gauges for a measurement by hand, we simply just add a newly added measurement to the appropriate counterVeh/gaugesVeh map. This also means that everytime a new measurement in meters.Measurement is introduced, the maps in prometheus.go need to be updated as well.
Instead of actively managing and storing each measurement in gauges and counters map respectively, in measurements.go, each entry in `iec` is assigned a PrometheusMetricType.

When prometheus_metrics.Init is called, the appropriate prometheus.Metric will be initialized and will still be stored in gauges/counters map, but its content now dynamically changes based on meters.Measurements actually enum entries, making meters.Measurements the single instance of responsibility for handling metric types.
Instead of creating only one instance of each Prometheus metric measurement, each metric will now differ in each device's manufacturer
Each static metrics is now categorized by interface `collectable`. `collectable.Collect()` will be called when all static metrics are registered to the default Prometheus registry.
When using `prometheus.MustRegister(...)`, the app will panic if a slice entry is nil. Meanwhile fail fast isn't bad, the stack trace doesn't provide enough/precise information about the panic.

`prometheus.Register(prometheus.Collector)` however returns an error object which makes it much easier to troubleshoot metric registrations.
kereis and others added 28 commits August 3, 2024 10:09
This allows us to pass a measurement's timestamp and using setters on gauges.
# Conflicts:
#	go.mod
#	go.sum
remove collectors for device, handlers, publishers and sockets as they
are superfluous and uninteresting.
reduces the name FQ name of measurement und moves the unit with its abbreviation
into the label/value section.
because contains code gen programs
it does not make sense and make grafana implementation more difficult.
Ot it's me ;-)
use direct map access instead of iterating over it.
than previous value, if set. if the current value is lower than we skip that value
@SchumacherFM
Copy link
Author

hello @andig, is there any interest in merging that code? I aware of your lack of time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants