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

Fix issue #1627 - stats usage #1629

Merged
merged 36 commits into from
Aug 7, 2024
Merged

Conversation

rg2011
Copy link
Contributor

@rg2011 rg2011 commented Aug 2, 2024

Fixes issue #1627 - comment #1627 (comment)

  • Removes push stats: local stats, periodic stat refresh, and documentation for the config.stats section.
  • Adds support for pull stats by exposing an openmetrics endpoint in the /metrics path of the northbound API.
  • Documents the /metrics endpoint.

The /metrics path is a convention for any openmetrics exporter.

@@ -1,3 +1,5 @@
- Add: openmetrics-compatible `/metrics` endpoint in nortbound API
- Deprecate: push-based stats
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should go beyond deprecation and remove the functionality (given that nobody is using it and, moreover, it probably doesn't work).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good with both, @AlvaroVega what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm agree on remove previous functionality.

CHANGES_NEXT_RELEASE Outdated Show resolved Hide resolved
Co-authored-by: Fermín Galán Márquez <fgalan@users.noreply.github.com>
@fgalan
Copy link
Member

fgalan commented Aug 2, 2024

Take care of lint:

/home/runner/work/iotagent-node-lib/iotagent-node-lib/lib/fiware-iotagent-lib.js
Error:   51:5   error  'logActions' is not defined  no-undef
Error:   65:9   error  'logActions' is not defined  no-undef
Error:   67:18  error  'logActions' is not defined  no-undef

/home/runner/work/iotagent-node-lib/iotagent-node-lib/lib/services/stats/statsRegistry.js
Error:   228:28  error  Expected '!==' and instead saw '!='          eqeqeq
Error:   229:22  error  'context' is not defined                     no-undef
Error:   236:36  error  Expected '!==' and instead saw '!='          eqeqeq
Error:   237:30  error  'context' is not defined                     no-undef
Error:   246:26  error  'context' is not defined                     no-undef
Error:   250:21  error  The array literal notation [] is preferable  no-array-constructor

@rg2011
Copy link
Contributor Author

rg2011 commented Aug 2, 2024

Take care of lint:

fixed.

@rg2011 rg2011 requested review from AlvaroVega and fgalan August 5, 2024 07:14
(currentConfig.deviceRegistry && currentConfig.deviceRegistry.type === 'mongodb') ||
(currentConfig.stats && currentConfig.stats.persistence === true)
) {
if (currentConfig.deviceRegistry && currentConfig.deviceRegistry.type === 'mongodb') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/telefonicaid/iotagent-node-lib/blob/master/doc/admin.md#stats section in documentation should be removed? Or it is still used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it has been removed, no longer used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I missed that... NTC

CHANGES_NEXT_RELEASE Outdated Show resolved Hide resolved
Co-authored-by: Fermín Galán Márquez <fgalan@users.noreply.github.com>
@@ -67,7 +68,8 @@ function init() {
* @param {String} token User token to identify against the PEP Proxies (optional).
*/
function sendUpdateValue(entityName, attributes, typeInformation, token, callback) {
entityHandler.sendUpdateValue(entityName, attributes, typeInformation, token, callback);
const newCallback = statsRegistry.withStats('updateEntityRequestsOk', 'updateEntityRequestsError', callback);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only here and raise/release alarm are feeding statsRegistry at this moment. It should be added also for create/delete groups/devices and so on ?

Copy link
Contributor Author

@rg2011 rg2011 Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only added metrics for things I want to alert on our monitoring systems. Currently, I want to create alerts:

  • If the number of failed updates increases much above average,
  • If the number of successful updates falls much below average,
  • if the number of alarms RAISE is higher than the number of alarms RELEASE.

So I only added metrics for those three use cases. It might be better to add metrics on demand, when some use case requires them.

Copy link
Member

@fgalan fgalan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Passing the ball to @AlvaroVega for extra review and LGTM before merging

Copy link
Member

@AlvaroVega AlvaroVega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AlvaroVega AlvaroVega merged commit 04bb324 into telefonicaid:master Aug 7, 2024
7 of 8 checks passed
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.

3 participants