-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Show alerts in UI; add no-op silence dialog; cleanups. #3
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
13b106b
Ensure flag parsing on startup.
juliusv 436643f
Cleanup: rename "element" to "event".
juliusv 71a9d4a
Ensure minimum repeat rate for events.
juliusv 827d3c3
Show actual alerts in UI and add no-op silence dialog.
juliusv ed289d5
Remove crufty logging statement.
juliusv 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
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 |
---|---|---|
|
@@ -20,6 +20,7 @@ import ( | |
) | ||
|
||
const ( | ||
minimumRepeatRate = 5 * time.Minute | ||
minimumRefreshPeriod = 5 * time.Minute | ||
notificationRetryPeriod = 1 * time.Minute | ||
) | ||
|
@@ -172,11 +173,11 @@ func (a *Aggregator) aggregate(req *aggregateEventsRequest, s SummaryReceiver) { | |
return | ||
} | ||
log.Println("aggregating", *req) | ||
for _, element := range req.Events { | ||
for _, event := range req.Events { | ||
for _, r := range a.Rules { | ||
log.Println("Checking rule", r, r.Handles(element)) | ||
if r.Handles(element) { | ||
fp := element.Fingerprint() | ||
log.Println("Checking rule", r, r.Handles(event)) | ||
if r.Handles(event) { | ||
fp := event.Fingerprint() | ||
aggregation, ok := a.Aggregates[fp] | ||
if !ok { | ||
expTimer := time.AfterFunc(minimumRefreshPeriod, func() { | ||
|
@@ -192,7 +193,7 @@ func (a *Aggregator) aggregate(req *aggregateEventsRequest, s SummaryReceiver) { | |
a.Aggregates[fp] = aggregation | ||
} | ||
|
||
aggregation.Ingest(element) | ||
aggregation.Ingest(event) | ||
aggregation.SendNotification(s) | ||
break | ||
} | ||
|
@@ -213,6 +214,13 @@ type aggregatorResetRulesRequest struct { | |
|
||
func (a *Aggregator) replaceRules(r *aggregatorResetRulesRequest) { | ||
log.Println("Replacing", len(r.Rules), "aggregator rules...") | ||
|
||
for _, rule := range r.Rules { | ||
if rule.RepeatRate < minimumRepeatRate { | ||
log.Println("Rule repeat rate too low, setting to minimum value") | ||
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. Cruft. 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. Was planning on keeping this, since it shouldn't happen unless no proper repeat rate is passed in from outside. |
||
rule.RepeatRate = minimumRepeatRate | ||
} | ||
} | ||
a.Rules = r.Rules | ||
|
||
r.Response <- new(aggregatorResetRulesResponse) | ||
|
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2013 Prometheus Team | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package web | ||
|
||
import ( | ||
"html/template" | ||
"time" | ||
) | ||
|
||
func timeSince(t time.Time) string { | ||
return time.Now().Round(time.Second / 10).Sub(t.Round(time.Second / 10)).String() | ||
} | ||
|
||
var webHelpers = template.FuncMap{ | ||
"timeSince": timeSince, | ||
} |
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 |
---|---|---|
@@ -1,3 +1,15 @@ | ||
body { | ||
padding-top: 60px; | ||
} | ||
|
||
#create_silence_modal th { | ||
text-align: left; | ||
} | ||
|
||
.add_silence_form { | ||
display: inline; | ||
} | ||
|
||
.del_label_button { | ||
margin-bottom: 10px; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
function clearSilenceLabels() { | ||
$("#silence_label_table").empty(); | ||
} | ||
|
||
function addSilenceLabel(label, value) { | ||
if (!label) { | ||
label = ""; | ||
} | ||
if (!value) { | ||
value = ""; | ||
} | ||
$("#silence_label_table").append( | ||
'<tr>' + | ||
' <td><input class="input-large" type="text" placeholder="label regex" value="' + label + '"></td>' + | ||
' <td><input class="input-large" type="text" placeholder="value regex" value="' + value + '"></td>' + | ||
' <td><button class="btn del_label_button"><i class="icon-minus"></i></button></td>' + | ||
'</tr>'); | ||
bindDelLabel(); | ||
} | ||
|
||
function bindDelLabel() { | ||
$(".del_label_button").unbind("click"); | ||
$(".del_label_button").click(function() { | ||
$(this).parents("tr").remove(); | ||
}); | ||
} | ||
|
||
function init() { | ||
$("#new_silence_btn").click(function() { | ||
clearSilenceLabels(); | ||
}); | ||
|
||
$(".add_silence_btn").click(function() { | ||
clearSilenceLabels(); | ||
|
||
var form = $(this).parents("form"); | ||
var labels = form.children('input[name="label[]"]'); | ||
var values = form.children('input[name="value[]"]'); | ||
for (var i = 0; i < labels.length; i++) { | ||
addSilenceLabel(labels.get(i).value, values.get(i).value); | ||
} | ||
}); | ||
|
||
$("#add_label_button").click(function() { | ||
addSilenceLabel("", ""); | ||
}); | ||
} | ||
|
||
$(init); |
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
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
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.
Cruft.
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.
Removed.