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

Commits on Aug 3, 2024

  1. Configuration menu
    Copy the full SHA
    935fead View commit details
    Browse the repository at this point in the history
  2. Ignore JetBrains project files

    If you open this project in GoLand, it will create a .idea/ directory which could have been tracked by Git.
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    f8ebc47 View commit details
    Browse the repository at this point in the history
  3. feat(prometheus): Remove Prometheusd and add global metrics

    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.
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    a7a6e25 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    a253643 View commit details
    Browse the repository at this point in the history
  5. feat(prometheus): Refactor creation of Counter/Gauge options objects

    When using newGaugeOpts/newCounterOpts, all objects will share the same namespace "mbmd"
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    50bfbf1 View commit details
    Browse the repository at this point in the history
  6. feat(prometheus): Implement approach of dynamically adding counters/g…

    …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.
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    0116e2f View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    817615e View commit details
    Browse the repository at this point in the history
  8. feat(prometheus): Delegate metric type storage to measurements.go

    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.
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    4c6342d View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    07bc41b View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    d933f2e View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    81e11f7 View commit details
    Browse the repository at this point in the history
  12. feat(prometheus): Create measurement metrics for device manufacturers

    Instead of creating only one instance of each Prometheus metric measurement, each metric will now differ in each device's manufacturer
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    eca3cff View commit details
    Browse the repository at this point in the history
  13. feat(prometheus): Add documentation

    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    bc1c5e8 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    deaa378 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    958afc7 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    229231d View commit details
    Browse the repository at this point in the history
  17. feat(prometheus): Add socket metrics and categorize static metrics

    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.
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    1287bc3 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    3d24da7 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    c540b47 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    2706e30 View commit details
    Browse the repository at this point in the history
  21. feat(prometheus): Change way of registering Prometheus metrics

    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 authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    6000a63 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    398b29b View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    69c2a5f View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    72bbef7 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    fb942f7 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    a9024f8 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    9fa4317 View commit details
    Browse the repository at this point in the history
  28. feat(prometheus): Move subsystem name into label, no panic on register

    Previously, log.Fatalf was used for logging if a metric registration to default Prometheus registry fails. However, I don't think there's a need to panic - logging should be enough
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    5809ed2 View commit details
    Browse the repository at this point in the history
  29. feat(prometheus): Add generalized device info

    Measurement labels are stripped to just serial_numbers as they can be accessed via Join with mbmd_device_info
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    b315eb9 View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    8d735c8 View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    b398b0a View commit details
    Browse the repository at this point in the history
  32. feat(prometheus): Cleanup

    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    0c6153c View commit details
    Browse the repository at this point in the history
  33. feat(prometheus): Integrate device name (by config) for unique metric ID

    If no device description is available, we cannot distinguish between all device structs which it makes also difficult to distinguish between metrics.
    
    Therefore I add the device name that the config specifies in order to make them "comparable"
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    95114bc View commit details
    Browse the repository at this point in the history
  34. feat(prometheus): Move SunSpec labels to name

    As these metrics are SunSpec specific, we integrate them into Prometheus metrics name
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    84d7062 View commit details
    Browse the repository at this point in the history
  35. feat(prometheus): Change help texts and units' full names

    Full names now use the plural form.
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    331c3da View commit details
    Browse the repository at this point in the history
  36. feat(prometheus): Add conversion funcs for unit

    Add conversion funcs in order to display measurement values in units specifically set for Prometheus.
    
    Starting with this commit, Kilowatt-hours are converted to Joules.
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    76bf539 View commit details
    Browse the repository at this point in the history
  37. Configuration menu
    Copy the full SHA
    ba20cc3 View commit details
    Browse the repository at this point in the history
  38. Configuration menu
    Copy the full SHA
    4d2d07e View commit details
    Browse the repository at this point in the history
  39. feat(prometheus): Change some metrics descriptions

    This is purely a change of expressions
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    8d758e7 View commit details
    Browse the repository at this point in the history
  40. feat(prometheus): Add device name label to Measurement metrics

    This can be quite useful in case the serial number of the smart meter is missing
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    b1b4acf View commit details
    Browse the repository at this point in the history
  41. refactor(prometheus): Change some measurement names and their Prometh…

    …eus names
    
    This also renames measurementOptions functions:
    - withPrometheusDescription -> withPrometheusHelpText
    - withGenericPrometheusDescription -> withGenericPrometheusHelpText
    - generatePrometheusDescription -> generatePrometheusHelpText
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    9a1339b View commit details
    Browse the repository at this point in the history
  42. refactor(prometheus): Refactor conversion map to static function

    Prometheus metrics are now automatically converted to a measurement's elementary unit.
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    71c23f7 View commit details
    Browse the repository at this point in the history
  43. refactor(prometheus): Refactor unit logic and update measurement desc…

    …riptions
    
    Unit stuff is now in a separate package called `units`.
    units.go has been completely refactored to use the functional options pattern as well.
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    f7b7d23 View commit details
    Browse the repository at this point in the history
  44. Configuration menu
    Copy the full SHA
    91a515a View commit details
    Browse the repository at this point in the history
  45. refactor(prometheus): Add Prometheus names for "String N Generation" …

    …measurement
    
    Prometheus (partial) names: string_n_energy_generated
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    703aaa2 View commit details
    Browse the repository at this point in the history
  46. Configuration menu
    Copy the full SHA
    0e30516 View commit details
    Browse the repository at this point in the history
  47. cleanup(prometheus): Remove metrics in scan.go

    Bus scan metrics are pointless as they're used for diagnosis purposes.
    As they're not registered and no REST is available, we can remove these metrics.
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    63bdaea View commit details
    Browse the repository at this point in the history
  48. refactor(prometheus): Rename prometheus_metrics package to simply pro…

    …metheus
    
    Also removes debug message of printing all measurement names.
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    9871692 View commit details
    Browse the repository at this point in the history
  49. feat(prometheus): Add custom collector for gauges and counters

    This allows us to pass a measurement's timestamp and using setters on gauges.
    kereis authored and SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    3ea5024 View commit details
    Browse the repository at this point in the history
  50. Configuration menu
    Copy the full SHA
    7b795a1 View commit details
    Browse the repository at this point in the history
  51. go mod update

    SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    f7f8eb9 View commit details
    Browse the repository at this point in the history
  52. fix rebase errors

    SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    f246cb4 View commit details
    Browse the repository at this point in the history
  53. Configuration menu
    Copy the full SHA
    96880f3 View commit details
    Browse the repository at this point in the history
  54. Configuration menu
    Copy the full SHA
    389ac76 View commit details
    Browse the repository at this point in the history
  55. Configuration menu
    Copy the full SHA
    4de4f3f View commit details
    Browse the repository at this point in the history
  56. Configuration menu
    Copy the full SHA
    ef02f5c View commit details
    Browse the repository at this point in the history
  57. go mod update to also 1.22.0

    # Conflicts:
    #	go.mod
    #	go.sum
    SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    0545de7 View commit details
    Browse the repository at this point in the history
  58. Refactor prometheus integration

    remove collectors for device, handlers, publishers and sockets as they
    are superfluous and uninteresting.
    SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    827944a View commit details
    Browse the repository at this point in the history
  59. Fix websocket path

    SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    4b482bb View commit details
    Browse the repository at this point in the history
  60. Configuration menu
    Copy the full SHA
    2fd6481 View commit details
    Browse the repository at this point in the history
  61. update readme

    SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    b90471c View commit details
    Browse the repository at this point in the history
  62. gofumpt formatting

    SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    c5df405 View commit details
    Browse the repository at this point in the history
  63. Configuration menu
    Copy the full SHA
    fe1966b View commit details
    Browse the repository at this point in the history
  64. Configuration menu
    Copy the full SHA
    b73f757 View commit details
    Browse the repository at this point in the history
  65. promtheus: change the structure of a measurement. move unit to label/val

    reduces the name FQ name of measurement und moves the unit with its abbreviation
    into the label/value section.
    SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    98e4cf3 View commit details
    Browse the repository at this point in the history
  66. fix tests, add tests

    SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    f0384f0 View commit details
    Browse the repository at this point in the history
  67. Configuration menu
    Copy the full SHA
    ba70d02 View commit details
    Browse the repository at this point in the history
  68. Configuration menu
    Copy the full SHA
    0af4f49 View commit details
    Browse the repository at this point in the history
  69. Configuration menu
    Copy the full SHA
    59db7aa View commit details
    Browse the repository at this point in the history
  70. Dockerfile: remove make install step

    because contains code gen programs
    SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    03f12d8 View commit details
    Browse the repository at this point in the history
  71. remove arithmetics of conversion kwh to joules

    it does not make sense and make grafana implementation more difficult.
    Ot it's me ;-)
    SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    5de63fb View commit details
    Browse the repository at this point in the history
  72. Configuration menu
    Copy the full SHA
    7d8266a View commit details
    Browse the repository at this point in the history
  73. Sunspec.Query: simplify code

    use direct map access instead of iterating over it.
    SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    9fb0e7f View commit details
    Browse the repository at this point in the history
  74. Configuration menu
    Copy the full SHA
    d0f15dd View commit details
    Browse the repository at this point in the history
  75. MeasurementCounterCollector.Set check if current value is lower

    than previous value, if set. if the current value is lower than we skip that value
    SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    af44c5a View commit details
    Browse the repository at this point in the history
  76. go mod update all

    SchumacherFM committed Aug 3, 2024
    Configuration menu
    Copy the full SHA
    af4e8bf View commit details
    Browse the repository at this point in the history