-
Notifications
You must be signed in to change notification settings - Fork 46
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
Adding JSON metrics route option #52
Open
Sunny-fr
wants to merge
9
commits into
PayU:master
Choose a base branch
from
Sunny-fr:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+9
−5
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
179d3ae
Adding custom suffix for json
Sunny-fr bbfd34b
Adding custom suffix for json
Sunny-fr ca1a9de
Merge branch 'master' into master
kobik e26ffab
Merge branch 'master' into master
kobik fcb3ae8
Adding an optional params for json formatted metrics :
Sunny-fr 512c0c9
Merge branch 'master' into master
Sunny-fr 35cffee
Merge branch 'master' into master
Sunny-fr 7389c17
Adding an optional params for json formatted metrics :
Sunny-fr 23ae08f
Merge branch 'master' into master
Sunny-fr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ API and process monitoring with [Prometheus](https://prometheus.io) for Node.js | |
- Process Metrics as recommended by Prometheus [itself](https://prometheus.io/docs/instrumenting/writing_clientlibs/#standard-and-runtime-collectors) | ||
- Endpoint to retrieve the metrics - used for Prometheus scraping | ||
- Prometheus format | ||
- JSON format (`${path}.json`) | ||
- JSON format (default to `${path}.json`, can be changed in options) | ||
- Support custom metrics | ||
- [Http function to collect request.js HTTP request duration](#requestjs-http-request-duration-collector) | ||
|
||
|
@@ -61,6 +61,7 @@ app.use(apiMetrics()) | |
### Options | ||
|
||
- metricsPath - Path to access the metrics. `default: /metrics` | ||
- metricsJsonPath - Path to access the json formatted metrics. `default: {metricsPath}.json` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. default is /${metricsPath}.json, right? |
||
- defaultMetricsInterval - the interval to collect the process metrics in milliseconds. `default: 10000` | ||
- durationBuckets - Buckets for response time in seconds. `default: [0.001, 0.005, 0.015, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5]` | ||
- requestSizeBuckets - Buckets for request size in bytes. `default: [5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000]` | ||
|
@@ -88,6 +89,7 @@ curl http[s]://<host>:[port]/metrics.json | |
|
||
2. If you are using express framework and no route was found for the request (e.g: 404 status code), the request will not be collected. that's because we'll risk memory leak since the route is not a pattern but a hardcoded string. | ||
|
||
3. You can specify your own metrics path via options. see : `metricsJsonPath` | ||
|
||
## Custom Metrics | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,10 @@ const setupOptions = {}; | |
|
||
module.exports = (appVersion, projectName, framework = 'express') => { | ||
return (options = {}) => { | ||
const { metricsPath, defaultMetricsInterval = 10000, durationBuckets, requestSizeBuckets, responseSizeBuckets, useUniqueHistogramName, metricsPrefix, excludeRoutes, includeQueryParams } = options; | ||
const { metricsPath, metricsJsonPath, defaultMetricsInterval = 10000, durationBuckets, requestSizeBuckets, responseSizeBuckets, useUniqueHistogramName, metricsPrefix, excludeRoutes, includeQueryParams } = options; | ||
debug(`Init metrics middleware with options: ${JSON.stringify(options)}`); | ||
setupOptions.metricsRoute = metricsPath || '/metrics'; | ||
setupOptions.metricsJsonRoute = metricsJsonPath || `${setupOptions.metricsRoute}.json`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thinking of that again, IMO we need to sanitize |
||
setupOptions.excludeRoutes = excludeRoutes || []; | ||
setupOptions.includeQueryParams = includeQueryParams; | ||
setupOptions.defaultMetricsInterval = defaultMetricsInterval; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default is
/${metricsPath}.json
, right?