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

Expose alert fingerprint in the API #786

Merged
merged 4 commits into from
Aug 18, 2017
Merged
Changes from 3 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
7 changes: 4 additions & 3 deletions api/api.go
Original file line number Diff line number Diff line change
@@ -343,9 +343,10 @@ func (api *API) listAlerts(w http.ResponseWriter, r *http.Request) {
}

apiAlert := &dispatch.APIAlert{
Alert: &a.Alert,
Status: status,
Receivers: receivers,
Alert: &a.Alert,
Status: status,
Receivers: receivers,
Fingerprint: fmt.Sprintf("%x", a.Fingerprint()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prymitive When I curl Alertmanager it does not expose the Fingerprint base16 encoded. I looked through the common package and found the String function. Would you mind changing it again to Fingerprint: a.Fingerprint().String(), then we are consistent across projects. I know there are plans to get rid of the commons repo in the future, but as we are using Fingerprint from the repo anyways, we might as well use Fingerprint.String(). Let me know if this sounds reasonable to you.

//cc @fabxc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, thanks

"fingerprint": "6f02aa263df152bc"

}

res = append(res, apiAlert)
10 changes: 6 additions & 4 deletions dispatch/dispatch.go
Original file line number Diff line number Diff line change
@@ -80,8 +80,9 @@ type AlertBlock struct {
// annotated with silencing and inhibition info.
type APIAlert struct {
*model.Alert
Status types.AlertStatus `json:"status"`
Receivers []string `json:"receivers"`
Status types.AlertStatus `json:"status"`
Receivers []string `json:"receivers"`
Fingerprint string `json:"fingerprint"`
}

// AlertGroup is a list of alert blocks grouped by the same label set.
@@ -136,8 +137,9 @@ func (d *Dispatcher) Groups(matchers []*labels.Matcher) AlertOverview {
}
status := d.marker.Status(a.Fingerprint())
aa := &APIAlert{
Alert: a,
Status: status,
Alert: a,
Status: status,
Fingerprint: fmt.Sprintf("%x", a.Fingerprint()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment in api/api.go in regards to using Fingerprint.String().

}

if !matchesFilterLabels(aa, matchers) {