feat(alerta-service): Add custom severities to Alerta handler#2584
Open
sp1r wants to merge 1 commit intoinfluxdata:masterfrom
Open
feat(alerta-service): Add custom severities to Alerta handler#2584sp1r wants to merge 1 commit intoinfluxdata:masterfrom
sp1r wants to merge 1 commit intoinfluxdata:masterfrom
Conversation
8237138 to
8a251ed
Compare
Fix influxdata#2056 This commit allows usage of all or some Alerta Severities. It provides two keywords to fine tune kapacitor built-in severities. 1. First, you can rename kapacitor serverity levels: crit, warn, info, ok to any other severities configured in your Alerta: |alert() // ... .alerta() // ... .renameSeverity('crit', 'major') .renameSeverity('info', 'notice') I suppose this will cover most of the cases. But if you do want a lot of severity levels: 2. You can add custom severity levels, which will be avaluated on Alerta handler level after built-in alert was triggered. |alert() // ... .warn(lambda: "cpu" > 50) .alerta() // ... .addSeverity('minor', 3, lambda: "cpu" > 60) .addSeverity('major', 2, lambda: "cpu" > 70) .addSeverity('critical', 1, lambda: "cpu" > 80) .addSeverity('fatal', 0, lambda: "cpu" > 90) Note: evaluation of addSeverity condition only happen after build-in alert is triggered, so you need some entry point (like .warn() in exmple), which should cover all range of values interesting to you. Note: this severities use Alerta's code order - higher severity has lower code (0 for fatal, 9 for ok) Note: .addSeverity() is quite useless in combination with .stateChangesOnly(), but Alerta has decent deduplication mechanism, so it shouldn't be a problem
8a251ed to
a7c1fa8
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix #2056
This commit allows usage of all or some Alerta Severities. It provides two keywords to fine tune kapacitor built-in severities.
First, you can rename kapacitor serverity levels: crit, warn, info, ok to any other severities configured in your Alerta:
|alert()
// ...
.alerta()
// ...
.renameSeverity('crit', 'major')
.renameSeverity('info', 'notice')
I suppose this will cover most of the cases. But if you do want a lot of severity levels:
You can add custom severity levels, which will be avaluated on Alerta handler level after built-in alert was triggered.
|alert()
// ...
.warn(lambda: "cpu" > 50)
.alerta()
// ...
.addSeverity('minor', 3, lambda: "cpu" > 60)
.addSeverity('major', 2, lambda: "cpu" > 70)
.addSeverity('critical', 1, lambda: "cpu" > 80)
.addSeverity('fatal', 0, lambda: "cpu" > 90)
Note: evaluation of addSeverity condition only happen after build-in alert is triggered, so you need some entry point (like .warn() in exmple), which should cover all range of values interesting to you.
Note: this severities use Alerta's code order - higher severity has lower code (0 for fatal, 9 for ok)
Note: .addSeverity() is quite useless in combination with .stateChangesOnly(), but Alerta has decent deduplication mechanism, so it shouldn't be a problem
Required for all non-trivial PRs