mirror of
https://github.com/prymitive/karma
synced 2026-05-05 03:16:51 +00:00
refactor(api): provide configured list of static labels in the API response
DOM data-* attributes are no longer used for this, feed react data store with this config so it can (re)render labels correctly
This commit is contained in:
@@ -33,15 +33,16 @@ type LabelsCountMap map[string]map[string]int
|
||||
|
||||
// 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"`
|
||||
AlertGroups map[string]AlertGroup `json:"groups"`
|
||||
TotalAlerts int `json:"totalAlerts"`
|
||||
Colors LabelsColorMap `json:"colors"`
|
||||
Filters []Filter `json:"filters"`
|
||||
Counters LabelsCountMap `json:"counters"`
|
||||
Status string `json:"status"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
Version string `json:"version"`
|
||||
Upstreams AlertmanagerAPISummary `json:"upstreams"`
|
||||
AlertGroups map[string]AlertGroup `json:"groups"`
|
||||
TotalAlerts int `json:"totalAlerts"`
|
||||
Colors LabelsColorMap `json:"colors"`
|
||||
Filters []Filter `json:"filters"`
|
||||
Counters LabelsCountMap `json:"counters"`
|
||||
StaticColorLabels []string `json:"staticColorLabels"`
|
||||
}
|
||||
|
||||
// Autocomplete is the structure of autocomplete object for filter hints
|
||||
|
||||
2
views.go
2
views.go
@@ -8,6 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/prymitive/unsee/internal/alertmanager"
|
||||
"github.com/prymitive/unsee/internal/config"
|
||||
"github.com/prymitive/unsee/internal/models"
|
||||
"github.com/prymitive/unsee/internal/slices"
|
||||
|
||||
@@ -50,6 +51,7 @@ func alerts(c *gin.Context) {
|
||||
resp.Timestamp = string(ts)
|
||||
resp.Version = version
|
||||
resp.Upstreams = getUpstreams()
|
||||
resp.StaticColorLabels = config.Config.Labels.Color.Static
|
||||
|
||||
// use full URI (including query args) as cache key
|
||||
cacheKey := c.Request.RequestURI
|
||||
|
||||
Reference in New Issue
Block a user