Coder Social home page Coder Social logo

sails-hook-prometheus's Introduction

Hi there ๐Ÿ‘‹

sails-hook-prometheus's People

Contributors

danielrataj avatar dependabot[bot] avatar whipstercz avatar yash2503 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

sails-hook-prometheus's Issues

Only the first metric in a file gets registered

This is my Counter metrics. As you can see i have multiple in one file.

`
/* global sails */

const LoginAttemptCounter = sails.hooks.prometheus.counter.setup({
  name: 'app_login_attempt',
  help: 'Track the status of login attempts (success or failed).',
  labelNames: ['status', 'code'],
})

const InitiateOnboardingCounter = sails.hooks.prometheus.counter.setup({
  name: 'initiate_onboarding',
  help: 'Track the status of onboarding initiation.',
  labelNames: ['status', 'code', 'step'],
})

const ImageUploadCounter = sails.hooks.prometheus.counter.setup({
  name: 'image_upload',
  help: 'Track the status of image upload.',
  labelNames: ['status', 'code'],
})

const ImageDownloadCounter = sails.hooks.prometheus.counter.setup({
  name: 'image_download',
  help: 'Track the status of image download.',
  labelNames: ['status', 'code'],
})

const FaceVerificationCounter = sails.hooks.prometheus.counter.setup({
  name: 'face_verification',
  help: 'Track the status of facial verification.',
  labelNames: ['status', 'code'],
})

const CompleteOnboardingCounter = sails.hooks.prometheus.counter.setup({
  name: 'complete_onboarding',
  help: 'Track the status of the complete onboarding step.',
  labelNames: ['status', 'code'],
})


module.exports = {
  /**
   * Track login attempts metrics.
   */
  loginAttempts: {
    success: (code = 200) =>
      LoginAttemptCounter.inc({ amount: 1, labels: { status: 'success', code } }),
    failed: (code = 400) =>
      LoginAttemptCounter.inc({ amount: 1, labels: { status: 'failed', code } }),
  },

  /**
   * Track initiate-onboarding metrics.
   */
  initiateOnboarding: {
    success: (code = 200) =>
      InitiateOnboardingCounter.inc({ amount: 1, labels: { status: 'success', code } }),
    failed: (code = 400, step) =>
      InitiateOnboardingCounter.inc({ amount: 1, labels: { status: 'failed', code, step } }),
  },

  /**
   * Track image upload metrics.
   */
  imageUpload: {
    success: (code = 200) =>
      ImageUploadCounter.inc({ amount: 1, labels: { status: 'success', code } }),
    failed: (code = 400) =>
      ImageUploadCounter.inc({ amount: 1, labels: { status: 'failed', code } }),
  },

  /**
   * Track image download metrics.
   */
  imageDownload: {
    success: (code = 200) =>
      ImageDownloadCounter.inc({ amount: 1, labels: { status: 'success', code } }),
    failed: (code = 400) =>
      ImageDownloadCounter.inc({ amount: 1, labels: { status: 'failed', code } }),
  },

  /**
   * Track image face verification.
   */
  faceVerification: {
    success: (code = 200) =>
      FaceVerificationCounter.inc({ amount: 1, labels: { status: 'success', code } }),
    failed: (code = 400) =>
      FaceVerificationCounter.inc({ amount: 1, labels: { status: 'failed', code } }),
  },

  /**
   * Track image download metrics.
   */
  completeOnboarding: {
    success: (code = 200) =>
      CompleteOnboardingCounter.inc({ amount: 1, labels: { status: 'success', code } }),
    failed: (code = 400) =>
      CompleteOnboardingCounter.inc({ amount: 1, labels: { status: 'failed', code } }),
  },
};

`

However, when i run the application only the first counter in this file seems to get registered.

Use a prefix for the /metrics endpoint

Would be possible to introduce a config parameter to personalize the /metrics endpoint (i.e. /api/v1/metrics)?

We would like to use this, but are stuck on this.

TYIA

HTTP Metrics Failed Request Not Visible

The HTTP metrics is only showing the request where the status code is 200. Whenever a request failed, the counter for that failed request increases (http_request_duration_seconds_count works fine) but http_request_duration_seconds_sum doesn't show the failed request i.e. status code 4xx

Do it works with sockets?

verbose: verbo: Interpreting socket.io message as VR (virtual request) to "put /api/v1/login"...
silly:      : Handling virtual request :: Running virtual querystring parser...
silly:      : Handling virtual request :: Running virtual body parser...
silly:      : Handling virtual request :: Running final "error" handler...
error: error: Sending 500 ("Server Error") response:
 TypeError: Cannot read property 'statusCode' of undefined
    at all /* (/certifirm/SailsBE_dev/node_modules/sails-hook-prometheus/src/index.js:43:36)
    at routeTargetFnWrapper (/certifirm/SailsBE_dev/node_modules/sails/lib/router/bind.js:392:9)
    at Layer.handle [as handle_request] (/certifirm/SailsBE_dev/node_modules/router/lib/layer.js:93:5)
    at next (/certifirm/SailsBE_dev/node_modules/router/lib/route.js:144:13)
    at Route.dispatch (/certifirm/SailsBE_dev/node_modules/router/lib/route.js:109:3)
    at handle (/certifirm/SailsBE_dev/node_modules/router/index.js:520:11)
    at Layer.handle [as handle_request] (/certifirm/SailsBE_dev/node_modules/router/lib/layer.js:93:5)
    at /certifirm/SailsBE_dev/node_modules/router/index.js:296:22
    at param (/certifirm/SailsBE_dev/node_modules/router/index.js:373:14)
    at param (/certifirm/SailsBE_dev/node_modules/router/index.js:384:14)
    at Function.process_params (/certifirm/SailsBE_dev/node_modules/router/index.js:429:3)
    at next (/certifirm/SailsBE_dev/node_modules/router/index.js:290:10)
    at next (/certifirm/SailsBE_dev/node_modules/router/lib/route.js:124:14)
    at logRequest (/certifirm/SailsBE_dev/node_modules/sails-hook-apianalytics/lib/private/log-request.middleware.js:109:10)
    at routeTargetFnWrapper (/certifirm/SailsBE_dev/node_modules/sails/lib/router/bind.js:392:9)
    at Layer.handle [as handle_request] (/certifirm/SailsBE_dev/node_modules/router/lib/layer.js:93:5)
    at next (/certifirm/SailsBE_dev/node_modules/router/lib/route.js:144:13)
    at Route.dispatch (/certifirm/SailsBE_dev/node_modules/router/lib/route.js:109:3)
    at handle (/certifirm/SailsBE_dev/node_modules/router/index.js:520:11)
    at Layer.handle [as handle_request] (/certifirm/SailsBE_dev/node_modules/router/lib/layer.js:93:5)
    at /certifirm/SailsBE_dev/node_modules/router/index.js:296:22
    at param (/certifirm/SailsBE_dev/node_modules/router/index.js:373:14)
    at param (/certifirm/SailsBE_dev/node_modules/router/index.js:384:14)
    at Function.process_params (/certifirm/SailsBE_dev/node_modules/router/index.js:429:3)
    at next (/certifirm/SailsBE_dev/node_modules/router/index.js:290:10)
    at next (/certifirm/SailsBE_dev/node_modules/router/lib/route.js:124:14)
    at fn (/certifirm/SailsBE_dev/api/hooks/custom/index.js:173:47)
    at routeTargetFnWrapper (/certifirm/SailsBE_dev/node_modules/sails/lib/router/bind.js:375:23)
    at /certifirm/SailsBE_dev/node_modules/sails/lib/router/bind.js:455:14
    at Layer.handle [as handle_request] (/certifirm/SailsBE_dev/node_modules/router/lib/layer.js:93:5)
    at next (/certifirm/SailsBE_dev/node_modules/router/lib/route.js:144:13)
    at Route.dispatch (/certifirm/SailsBE_dev/node_modules/router/lib/route.js:109:3)
    at handle (/certifirm/SailsBE_dev/node_modules/router/index.js:520:11)
    at Layer.handle [as handle_request] (/certifirm/SailsBE_dev/node_modules/router/lib/layer.js:93:5)

Issue when .inc() with empty arguments

When we use method "inc()" without arguments, we got an error:

TypeError: Cannot read property 'amount' of undefined at Object.inc (/Users/drataj/workspace/test-project/node_modules/sails-hook-prometheus/src/index.js:100:14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.