refactor(api): move settings keys in the API response to a namespace

This commit is contained in:
Łukasz Mierzwa
2018-07-16 19:21:35 +02:00
parent 39c1050715
commit 2ee239a74c
2 changed files with 20 additions and 12 deletions

View File

@@ -158,19 +158,25 @@ func (ag *APIAlertGroup) DedupSharedMaps() {
}
}
// Settings is used to export unsee configuration that is used by UI
type Settings struct {
StaticColorLabels []string `json:"staticColorLabels"`
DefaultFilters []string `json:"defaultFilters"`
}
// AlertsResponse is the structure of JSON response UI will use to get alert data
type AlertsResponse struct {
Status string `json:"status"`
Timestamp string `json:"timestamp"`
Version string `json:"version"`
Upstreams AlertmanagerAPISummary `json:"upstreams"`
Silences map[string]map[string]Silence `json:"silences"`
AlertGroups map[string]APIAlertGroup `json:"groups"`
TotalAlerts int `json:"totalAlerts"`
Colors LabelsColorMap `json:"colors"`
Filters []Filter `json:"filters"`
Counters LabelsCountMap `json:"counters"`
StaticColorLabels []string `json:"staticColorLabels"`
Status string `json:"status"`
Timestamp string `json:"timestamp"`
Version string `json:"version"`
Upstreams AlertmanagerAPISummary `json:"upstreams"`
Silences map[string]map[string]Silence `json:"silences"`
AlertGroups map[string]APIAlertGroup `json:"groups"`
TotalAlerts int `json:"totalAlerts"`
Colors LabelsColorMap `json:"colors"`
Filters []Filter `json:"filters"`
Counters LabelsCountMap `json:"counters"`
Settings Settings `json:"settings"`
}
// Autocomplete is the structure of autocomplete object for filter hints

View File

@@ -47,7 +47,9 @@ func alerts(c *gin.Context) {
resp.Timestamp = string(ts)
resp.Version = version
resp.Upstreams = getUpstreams()
resp.StaticColorLabels = config.Config.Labels.Color.Static
resp.Settings = models.Settings{
StaticColorLabels: config.Config.Labels.Color.Static,
}
// use full URI (including query args) as cache key
cacheKey := c.Request.RequestURI