Custom karma name (#994)

* feat: feat: add karma.name parameter

* fix(backend): remove duplicated 'name'

* feat(docs): mention karma:name in docs

* feat(demo): set custom title for demo
This commit is contained in:
Nicolas Ledez
2019-10-05 13:17:09 +02:00
committed by Łukasz Mierzwa
parent 7d96ff2eb4
commit ade15ae06d
8 changed files with 37 additions and 1 deletions

View File

@@ -86,6 +86,7 @@ func index(c *gin.Context) {
defaultsB64 := base64.StdEncoding.EncodeToString(defaults)
c.HTML(http.StatusOK, "ui/build/index.html", gin.H{
"KarmaName": config.Config.Karma.Name,
"Version": version,
"SentryDSN": config.Config.Sentry.Public,
"DefaultFilter": filtersB64,

View File

@@ -32,6 +32,8 @@ grid:
critical: 1
warning: 2
info: 3
karma:
name: karma-demo
labels:
color:
static:

View File

@@ -321,6 +321,27 @@ grid:
info: 3
```
### Karma
`karma` section allows configuring miscellaneous internal options.
Syntax:
```YAML
karma:
name: string
```
- `name` - name of given karma instance, this is currently used for the browser
tab title.
Defaults:
```YAML
karma:
name: karma
```
### Labels
`labels` section allows configuring how alert labels will be rendered in the

View File

@@ -27,6 +27,8 @@ debug: false
filters:
default:
- "@receiver=by-cluster-service"
karma:
name: karma-prod
labels:
color:
static:

View File

@@ -37,6 +37,8 @@ func init() {
pflag.Bool("alertmanager.proxy", false,
"Proxy all client requests to Alertmanager via karma (only used with simplified config)")
pflag.String("karma.name", "karma", "Name for the karma instance")
pflag.Bool(
"annotations.default.hidden", false,
"Hide all annotations by default unless explicitly listed in the 'visible' list")
@@ -162,6 +164,7 @@ func (config *configSchema) Read() {
config.Grid.Sorting.Order = v.GetString("grid.sorting.order")
config.Grid.Sorting.Reverse = v.GetBool("grid.sorting.reverse")
config.Grid.Sorting.Label = v.GetString("grid.sorting.label")
config.Karma.Name = v.GetString("karma.name")
config.Labels.Color.Custom = CustomLabelColors{}
config.Labels.Color.Static = v.GetStringSlice("labels.color.static")
config.Labels.Color.Unique = v.GetStringSlice("labels.color.unique")

View File

@@ -30,6 +30,7 @@ func resetEnv() {
"CUSTOM_JS",
"DEBUG",
"FILTERS_DEFAULT",
"KARMA_NAME",
"LABELS_COLOR_STATIC",
"LABELS_COLOR_UNIQUE",
"LABELS_KEEP",
@@ -91,6 +92,8 @@ grid:
label: alertname
customValues:
labels: {}
karma:
name: another karma
labels:
keep:
- foo
@@ -171,6 +174,7 @@ func TestReadConfig(t *testing.T) {
os.Setenv("CUSTOM_JS", "/custom.js")
os.Setenv("DEBUG", "true")
os.Setenv("FILTERS_DEFAULT", "@state=active foo=bar")
os.Setenv("KARMA_NAME", "another karma")
os.Setenv("LABELS_COLOR_STATIC", "a bb ccc")
os.Setenv("LABELS_COLOR_UNIQUE", "f gg")
os.Setenv("LABELS_KEEP", "foo bar")

View File

@@ -66,6 +66,9 @@ type configSchema struct {
} `yaml:"customValues" mapstructure:"customValues"`
}
}
Karma struct {
Name string
}
Labels struct {
Keep []string
Strip []string

View File

@@ -19,7 +19,7 @@
href="%PUBLIC_URL%/custom.css"
media="screen"
/>
<title>karma</title>
<title>{{ .KarmaName }}</title>
</head>
<body>
<noscript>