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

WIP for Kibana alerting o11y project #2642

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,3 +684,7 @@ Agent.prototype.registerMetric = function (name, labelsOrCallback, callback) {

this._metrics.getOrCreateGauge(name, callback, labels)
}

Agent.prototype.registerMetricCounter = function (name, dimensions) {
return this._metrics.getOrCreateCounter(name, dimensions)
}
13 changes: 12 additions & 1 deletion lib/metrics/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ class MetricsReporter extends Reporter {
}

if (metric.metricImpl.constructor.name === 'Counter') {
metric.metricImpl.reset()
// We need a way to avoid ignoring metrics that might go stale
// because we want values for each counter to appear in every document
// This is not a great check but there does not seem to be a way
// to provide meta data about a metric to enable to better check
if (!metric.name.startsWith('kibana')) {
metric.metricImpl.reset()
}
}
}

Expand All @@ -68,6 +74,11 @@ class MetricsReporter extends Reporter {
// if a metric is a counting metric and that count is
// zero, then the metric is considered stale
if (metric.metricImpl && metric.metricImpl._count === 0) {
// We need a way to avoid ignoring metrics that might go stale
// because we want values for each counter to appear in every document
// This is not a great check but there does not seem to be a way
// to provide meta data about a metric to enable to better check
if (metric.name.startsWith('kibana')) return false
return true
}
return false
Expand Down