Skip to content

Comments

Update status impl#717

Merged
fabxc merged 21 commits intomasterfrom
update-status-impl
Apr 27, 2017
Merged

Update status impl#717
fabxc merged 21 commits intomasterfrom
update-status-impl

Conversation

@stuartnelson3
Copy link
Contributor

Adding on to #711

}
}
ih.marker.SetInhibited(fp, false)
ih.marker.SetStatus(fp, types.Active)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if this is semantically correct. It appears that alerts will be marked in the notify pipeline, so setting them to active here would be temporary until they get checked as part of the pipeline. Can someone confirm? @brancz

Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't know the real status until notify can re-check it again then maybe we should reset it into types.Unprocessed, wouldn't that make more sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it has to go through both the inhibit and silence exec stages, so it'll be set correctly.

types/types.go Outdated
type state uint8

const (
Unprocessed state = iota
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if Unprocessed is the best name for it, I was thinking about calling it New but that on the other hand might be mistaken for an alert that just fired rather than indicate what we really mean here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I'm not sure what name to provide. I don't feel strongly one way or the other.

types/types.go Outdated
status = "unknown"
}

// TODO: Do we want to return all values?
Copy link
Contributor

Choose a reason for hiding this comment

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

This would make sense for Silenced status as there might be multiple silences that match our alert. But this means that notify would need to check all, which I see that this PR is adding, so I would say yes, we should return everything.

@prymitive prymitive mentioned this pull request Apr 18, 2017
@stuartnelson3
Copy link
Contributor Author

Does this seem sane to people? @fabxc @brancz @mxinden

types/types.go Outdated
type State uint8

const (
Unprocessed State = iota
Copy link
Contributor

Choose a reason for hiding this comment

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

Always prefix enums with the original type.

The type should be AlertState to know what it's even about. Thereby the values would be AlertStateUnprocessed etc.

}

func TestAlertsGC(t *testing.T) {
dir, err := ioutil.TempDir("", "alerts_test")
Copy link
Contributor

Choose a reason for hiding this comment

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

defer os.RemoveAll(dir)

types/types.go Outdated
Unprocessed: "unprocessed",
Active: "active",
Silenced: "silenced",
Inhibited: "inhibited",
Copy link
Contributor

Choose a reason for hiding this comment

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

An alert can be silenced and inhibited. More so once we move towards a model where this is shown immediately and not just after initial processing.

So "unprocessed", "active", and "suppressed" might be more accurate? @brian-brazil

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds understandable to me

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there's a difference between silenced and inhibited from the user perspective and Alertmanager should distinguish between these two states. Inhibition and silencing is used for different purposes. One is "oh it's silenced, someone is working on it" the other is "oh it's caused by some other issue" (btw. there's no way to ACK an alert, so silences might be used as ACKs).
If alert is inhibited than it's clear that it's suppressed by another alert, so when that other alert is resolved our inhibited alert will fire. Silenced alert on the other hand will never fire while the silence is active. If you just see "suppressed" you won't know what that really means and whenever this alert will fire if there's an action to take in the near future (it won't if it's silenced).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, but then from AlertStatus we could infer what sort of suppressed it is: if it has silenceIDs in the silencedBy field, it's silenced, if it has alertIDs in the inhibitedBy field it's inhibited. I suppose I'm not a big fan of having to infer the state, though.

types/types.go Outdated
// AlertStatus stores the state and values associated with an Alert.
type AlertStatus struct {
status State
values []string
Copy link
Contributor

@fabxc fabxc Apr 21, 2017

Choose a reason for hiding this comment

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

Just having silence IDs here as a bunch of strings might fit with the UI currently offers, but it has semantically no real meaning from an API perspective.
What if we also want to show which alerts inhibited the given alert? How would we distinguish its ID from that of a silence.

I think the status should rather have "status", "silencedBy" (list of silence IDs), and "inhibitedBy" (list of alert IDs).

Also the attributes are both unexported so they shouldn't be marshalled by the JSON decoder, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AlertStatus implements the marshaler interface so we can convert the enum into a string representation, so that handles marshaling the unexported fields.

I flatten the AlertStatus inside APIAlert in dispatch.go:139, but I'm not sure if that's the "right" way to do it.

// distinguish AlertStateSuppressed between silenced
// and/or inhibited. In the future there will be unique
// identifiers for alerts.
ih.marker.SetInhibited(fp, "123")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put these semantics in place now even though we won't use them. This does lead to potential confusing behavior if we attempt to SetInhibited elsewhere before unique identifiers for alerts exist, but the symmetry with SetSilenced made sense to me.

// identifiers for alerts.
ih.marker.SetInhibited(fp, "123")
if inhibitedByFP, eq := r.hasEqual(lset); r.TargetMatchers.Match(lset) && eq {
ih.marker.SetInhibited(fp, fmt.Sprintf("%d", inhibitedByFP))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fabxc Does this look correct?

@fabxc
Copy link
Contributor

fabxc commented Apr 27, 2017

👍

@fabxc fabxc merged commit 6a909ab into master Apr 27, 2017
@fabxc fabxc deleted the update-status-impl branch April 27, 2017 12:18
@stuartnelson3
Copy link
Contributor Author

thanks for getting this started @prymitive !!!

@prymitive
Copy link
Contributor

Is there any current estimate when would the next release be out? One that would contain this and possibly #748

@brancz
Copy link
Member

brancz commented Apr 27, 2017

A patch release should go out very soon to release #750

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants