Skip to content

Commit

Permalink
Sync ui-rewrite with master (prometheus#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden authored May 10, 2017
1 parent 6784e30 commit d463f1c
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 178 deletions.
45 changes: 28 additions & 17 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
## v0.6.2 / 2017-05-09

* [BUGFIX] Correctly link to silences from alert again
* [BUGFIX] Correctly hide silenced/show active alerts in UI again
* [BUGFIX] Fix regression of alerts not being displayed until first processing
* [BUGFIX] Fix internal usage of wrong lock for silence markers
* [BUGFIX] Adapt amtool's API parsing to recent API changes
* [BUGFIX] Correctly marshal regexes in config JSON response
* [ENHANCEMENT] Anchor silence regex matchers to be consistent with Prometheus
* [ENHANCEMENT] Error if root route is using `continue` keyword

## v0.6.1 / 2017-04-28

- [BUGFIX] Fix incorrectly serialized hash for notification providers.
- [ENHANCEMENT] Add config hash metric.
- [ENHANCEMENT] Add processing status field to alerts.
* [BUGFIX] Fix incorrectly serialized hash for notification providers.
* [ENHANCEMENT] Add config hash metric.
* [ENHANCEMENT] Add processing status field to alerts.

## v0.6.0 / 2017-04-25

- [BUGFIX] Add `groupKey` to `alerts/groups` endpoint https://github.com/prometheus/alertmanager/pull/576
- [BUGFIX] Only notify on firing alerts https://github.com/prometheus/alertmanager/pull/595
- [BUGFIX] Correctly marshal regex's in config for routing tree https://github.com/prometheus/alertmanager/pull/602
- [BUGFIX] Prevent panic when failing to load config https://github.com/prometheus/alertmanager/pull/607
- [BUGFIX] Prevent panic when alertmanager is started with an empty `-mesh.peer` https://github.com/prometheus/alertmanager/pull/726
- [CHANGE] Add `DELETE` as accepted CORS method https://github.com/prometheus/alertmanager/pull/641
- [CHANGE] Rename VictorOps config variables https://github.com/prometheus/alertmanager/pull/667
- [CHANGE] Switch to using `gogoproto` for protobuf https://github.com/prometheus/alertmanager/pull/715
- [CHANGE] No longer generate releases for openbsd/arm https://github.com/prometheus/alertmanager/pull/732
- [ENHANCEMENT] Add `reReplaceAll` template function https://github.com/prometheus/alertmanager/pull/639
- [ENHANCEMENT] Expose mesh peers on status page https://github.com/prometheus/alertmanager/pull/644
- [ENHANCEMENT] Allow label-based filtering alerts/silences through API https://github.com/prometheus/alertmanager/pull/633
- [ENHANCEMENT] Include notifier type in logs and errors https://github.com/prometheus/alertmanager/pull/702
- [ENHANCEMENT] Add commandline tool for interacting with alertmanager https://github.com/prometheus/alertmanager/pull/636
* [BUGFIX] Add `groupKey` to `alerts/groups` endpoint https://github.com/prometheus/alertmanager/pull/576
* [BUGFIX] Only notify on firing alerts https://github.com/prometheus/alertmanager/pull/595
* [BUGFIX] Correctly marshal regex's in config for routing tree https://github.com/prometheus/alertmanager/pull/602
* [BUGFIX] Prevent panic when failing to load config https://github.com/prometheus/alertmanager/pull/607
* [BUGFIX] Prevent panic when alertmanager is started with an empty `-mesh.peer` https://github.com/prometheus/alertmanager/pull/726
* [CHANGE] Add `DELETE` as accepted CORS method https://github.com/prometheus/alertmanager/pull/641
* [CHANGE] Rename VictorOps config variables https://github.com/prometheus/alertmanager/pull/667
* [CHANGE] Switch to using `gogoproto` for protobuf https://github.com/prometheus/alertmanager/pull/715
* [CHANGE] No longer generate releases for openbsd/arm https://github.com/prometheus/alertmanager/pull/732
* [ENHANCEMENT] Add `reReplaceAll` template function https://github.com/prometheus/alertmanager/pull/639
* [ENHANCEMENT] Expose mesh peers on status page https://github.com/prometheus/alertmanager/pull/644
* [ENHANCEMENT] Allow label-based filtering alerts/silences through API https://github.com/prometheus/alertmanager/pull/633
* [ENHANCEMENT] Include notifier type in logs and errors https://github.com/prometheus/alertmanager/pull/702
* [ENHANCEMENT] Add commandline tool for interacting with alertmanager https://github.com/prometheus/alertmanager/pull/636

## v0.5.1 / 2016-11-24

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.1
0.6.2
10 changes: 3 additions & 7 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,7 @@ func (api *API) alertGroups(w http.ResponseWriter, req *http.Request) {
type APIAlert struct {
*model.Alert

Status types.AlertState `json:"status"`
InhibitedBy []string `json:"inhibitedBy"`
SilencedBy []string `json:"silencedBy"`
Status types.AlertStatus `json:"status"`
}

func (api *API) listAlerts(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -289,10 +287,8 @@ func (api *API) listAlerts(w http.ResponseWriter, r *http.Request) {
status := api.getAlertStatus(a.Fingerprint())

apiAlert := &APIAlert{
Alert: &a.Alert,
Status: status.Status,
SilencedBy: status.SilencedBy,
InhibitedBy: status.InhibitedBy,
Alert: &a.Alert,
Status: status,
}

res = append(res, apiAlert)
Expand Down
6 changes: 3 additions & 3 deletions cli/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type alertmanagerAlertResponse struct {

type alertGroup struct {
Labels model.LabelSet `json:"labels"`
GroupKey uint64 `json:"groupKey"`
GroupKey string `json:"groupKey"`
Blocks []*alertBlock `json:"blocks"`
}

Expand Down Expand Up @@ -103,7 +103,7 @@ func fetchAlerts(filter string) ([]*dispatch.APIAlert, error) {

err = json.NewDecoder(res.Body).Decode(&alertResponse)
if err != nil {
return []*dispatch.APIAlert{}, errors.New("Unable to decode json response")
return []*dispatch.APIAlert{}, fmt.Errorf("Unable to decode json response: %s", err)
}

if alertResponse.Status != "success" {
Expand Down Expand Up @@ -158,7 +158,7 @@ func queryAlerts(cmd *cobra.Command, args []string) error {

if !showSilenced {
// If any silence mutes this alert don't show it
if alert.Status == types.AlertStateSuppressed && len(alert.SilencedBy) > 0 {
if alert.Status.State == types.AlertStateSuppressed && len(alert.Status.SilencedBy) > 0 {
continue
}
}
Expand Down
6 changes: 2 additions & 4 deletions cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,10 @@ func fetchConfig() (Config, error) {
}

defer res.Body.Close()
decoder := json.NewDecoder(res.Body)

err = decoder.Decode(&configResponse)
err = json.NewDecoder(res.Body).Decode(&configResponse)
if err != nil {
panic(err)
return Config{}, err
return configResponse.Data, err
}

if configResponse.Status != "success" {
Expand Down
8 changes: 7 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"time"

"encoding/json"

"github.com/prometheus/common/model"
"gopkg.in/yaml.v2"
)
Expand Down Expand Up @@ -51,6 +52,11 @@ func Load(s string) (*Config, error) {
return nil, errors.New("no route provided in config")
}

// Check if continue in root route.
if cfg.Route.Continue {
return nil, errors.New("cannot have continue in root route")
}

cfg.original = s
return cfg, nil
}
Expand Down Expand Up @@ -498,7 +504,7 @@ func (re *Regexp) UnmarshalJSON(data []byte) error {
}

// MarshalJSON implements the json.Marshaler interface.
func (re *Regexp) MarshalJSON() ([]byte, error) {
func (re Regexp) MarshalJSON() ([]byte, error) {
if re.Regexp != nil {
return json.Marshal(re.String())
}
Expand Down
23 changes: 23 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,26 @@ route:
t.Errorf("\nexpected:\n%v\ngot:\n%v", expected, err.Error())
}
}

func TestContinueErrorInRouteRoot(t *testing.T) {
in := `
route:
receiver: team-X-mails
continue: true
receivers:
- name: 'team-X-mails'
`

_, err := Load(in)

expected := "cannot have continue in root route"

if err == nil {
t.Fatalf("no error returned, expeceted:\n%q", expected)
}
if err.Error() != expected {
t.Errorf("\nexpected:\n%q\ngot:\n%q", expected, err.Error())
}

}
11 changes: 3 additions & 8 deletions dispatch/dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ type AlertBlock struct {
// annotated with silencing and inhibition info.
type APIAlert struct {
*model.Alert

Status types.AlertState
InhibitedBy []string `json:"inhibitedBy"`
SilencedBy []string `json:"silencedBy"`
Status types.AlertStatus `json:"status"`
}

// AlertGroup is a list of alert blocks grouped by the same label set.
Expand Down Expand Up @@ -138,10 +135,8 @@ func (d *Dispatcher) Groups(matchers []*labels.Matcher) AlertOverview {
}
status := d.marker.Status(a.Fingerprint())
aa := &APIAlert{
Alert: a,
Status: status.Status,
SilencedBy: status.SilencedBy,
InhibitedBy: status.InhibitedBy,
Alert: a,
Status: status,
}

if !matchesFilterLabels(aa, matchers) {
Expand Down
4 changes: 2 additions & 2 deletions provider/mem/mem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ func TestAlertsGC(t *testing.T) {
}

s := marker.Status(a.Fingerprint())
if s.Status != types.AlertStateUnprocessed {
t.Errorf("marker %d didn't get GC'd", i)
if s.State != types.AlertStateUnprocessed {
t.Errorf("marker %d didn't get GC'd: %v", i, s)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion types/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (m *Matcher) Init() error {
if !m.IsRegex {
return nil
}
re, err := regexp.Compile(m.Value)
re, err := regexp.Compile("^(?:" + m.Value + ")$")
if err == nil {
m.regex = re
}
Expand Down
Loading

0 comments on commit d463f1c

Please sign in to comment.