iotagent-node-lib icon indicating copy to clipboard operation
iotagent-node-lib copied to clipboard

Add environment variable for config.stats.interval

Open rg2011 opened this issue 1 year ago • 5 comments

Component

Feature enhancement

Is your feature request related to a problem? Please describe

Stat collection would be easier to manage in dockerized environment if config.stats.interval could be overriden by an environment variable, as is the case for many other config settings.

Describe the solution you'd like

Add an IOTA_STATS_INTERVAL environment variable that overrides the value of config.stats.interval

Describe alternatives you've considered

Replace the whole config.js file with a kubernetes configmap, but that would make maintenance harder, if we have to track and replicate in our configmap any changes to the builtin config.js when a new version is released.

The systemd version you checked that didn't have the feature you are asking for

4.5.0

rg2011 avatar Jul 26 '24 08:07 rg2011

~PR #1628~

fgalan avatar Jul 29 '24 09:07 fgalan

I have been testing the changes in PR #1628 and they work, but I find the push model for statistics too cumbersome:

  • The kpis mongo collection has to be manually created as capped, or rotated periodically, otherwise it might grow unbounded.
  • To expose those metrics to telemetry systems such as Prometheus, an additional exporter has to be developed.

Besides, comments in PR #1628 suggest that these push stats have actually never been used.

All above considered, I am tempted to suggest deprecating the push mechanism altogether, and replacing it with an openmetrics endpoint in the northbound API.

  • Exposing the stats in openmetrics format would allow direct integration with Prometheus and any other compatible telemetry tool.
  • The app would not need to bother with global and local stats, nor timers to periodically push and clear them. Pull based telemetry tools manage the collection intervals themselves, and calculate the increments and rates between consecutive measures.

I might work on such an endpoint in another PR.

rg2011 avatar Aug 01 '24 08:08 rg2011

PR https://github.com/telefonicaid/iotagent-node-lib/pull/1629

fgalan avatar Aug 05 '24 10:08 fgalan

Now that PR #1629 has been merged, can this issue be closed?

fgalan avatar Aug 07 '24 12:08 fgalan

I tested the :latest image in our kubernetes environment and found out that the prometheus version available there actually requests openmetrics version 0.0.1, so I had to add support for that version too. I submitted PR #1640

rg2011 avatar Aug 08 '24 08:08 rg2011

Having releases version 4.6.0 including this issue, I think is time to close the issue. @rg2011 tell us otherwise, so we can reopen it.

fgalan avatar Sep 18 '24 14:09 fgalan