Skip to content

Commit

Permalink
vmalertmanagerconfig: add fields entity, actions and `update_aler…
Browse files Browse the repository at this point in the history
  • Loading branch information
Haleygo committed Nov 23, 2023
1 parent 45bfa36 commit 6628356
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 3 deletions.
Binary file added .DS_Store
Binary file not shown.
7 changes: 7 additions & 0 deletions api/v1beta1/vmalertmanagerconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,13 @@ type OpsGenieConfig struct {
// List of responders responsible for notifications.
// +optional
Responders []OpsGenieConfigResponder `json:"responders,omitempty"`
// Optional field that can be used to specify which domain alert is related to.
Entity string `json:"entity,omitempty"`
// Comma separated list of actions that will be available for the alert.
Actions string `json:"actions,omitempty"`
// Whether to update message and description of the alert in OpsGenie if it already exists
// By default, the alert is never updated in OpsGenie, the new message only appears in activity log.
UpdateAlerts bool `json:"update_alerts,omitempty"`
// HTTP client configuration.
// +optional
HTTPConfig *HTTPConfig `json:"http_config,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions api/victoriametrics/v1beta1/additional.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ func (l *License) IsProvided() bool {

// MaybeAddToArgs conditionally adds license commandline args into given args
func (l *License) MaybeAddToArgs(args []string, secretMountDir string) []string {
if !l.IsProvided() {
if l == nil || !l.IsProvided() {
return args
}
if l.Key != nil {
Expand All @@ -595,7 +595,7 @@ func (l *License) MaybeAddToArgs(args []string, secretMountDir string) []string

// MaybeAddToVolumes conditionally mounts secret with license key into given volumes and mounts
func (l *License) MaybeAddToVolumes(volumes []v1.Volume, mounts []v1.VolumeMount, secretMountDir string) ([]v1.Volume, []v1.VolumeMount) {
if l.KeyRef == nil {
if l == nil || l.KeyRef == nil {
return volumes, mounts
}
volumes = append(volumes, v1.Volume{
Expand Down
15 changes: 15 additions & 0 deletions api/victoriametrics/v1beta1/vmagent_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ func TestVMAgent_sanityCheck(t *testing.T) {
},
},
},
{
name: "relabeling with if array",
spec: VMAgentSpec{
RemoteWrite: []VMAgentRemoteWriteSpec{{URL: "http://some-rw"}},
InlineRelabelConfig: []RelabelConfig{
{
Action: "drop_metrics",
If: []string{
"{job=~\"aaa.*\"}",
"{job=~\"bbb.*\"}",
},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
7 changes: 7 additions & 0 deletions api/victoriametrics/v1beta1/vmalertmanagerconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,13 @@ type OpsGenieConfig struct {
// List of responders responsible for notifications.
// +optional
Responders []OpsGenieConfigResponder `json:"responders,omitempty"`
// Optional field that can be used to specify which domain alert is related to.
Entity string `json:"entity,omitempty"`
// Comma separated list of actions that will be available for the alert.
Actions string `json:"actions,omitempty"`
// Whether to update message and description of the alert in OpsGenie if it already exists
// By default, the alert is never updated in OpsGenie, the new message only appears in activity log.
UpdateAlerts bool `json:"update_alerts,omitempty"`
// HTTP client configuration.
// +optional
HTTPConfig *HTTPConfig `json:"http_config,omitempty"`
Expand Down
6 changes: 6 additions & 0 deletions controllers/factory/alertmanager/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,9 @@ func (cb *configBuilder) buildOpsGenie(og operatorv1beta1.OpsGenieConfig) error
toYamlString("tags", og.Tags)
toYamlString("note", og.Note)
toYamlString("api_url", og.APIURL)
toYamlString("entity", og.Entity)
toYamlString("Actions", og.Actions)

if og.APIURL != "" {
err := parseURL(og.APIURL)
if err != nil {
Expand All @@ -970,6 +973,9 @@ func (cb *configBuilder) buildOpsGenie(og operatorv1beta1.OpsGenieConfig) error
if og.SendResolved != nil {
temp = append(temp, yaml.MapItem{Key: "send_resolved", Value: *og.SendResolved})
}
if og.UpdateAlerts {
temp = append(temp, yaml.MapItem{Key: "update_alerts", Value: og.UpdateAlerts})
}

var responders []yaml.MapSlice
for _, responder := range og.Responders {
Expand Down
2 changes: 1 addition & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ aliases:

## Next release

- TODO
- [vmalertmanagerconfig](./api.html#vmalertmanagerconfig): add fields `entity`, `actions` and `update_alerts` for opsgenie_configs according to https://prometheus.io/docs/alerting/latest/configuration/#opsgenie_config.

<a name="v0.39.3"></a>
## [v0.39.3](https://github.com/VictoriaMetrics/operator/releases/tag/v0.39.3) - 16 Nov 2023
Expand Down
Binary file added manager
Binary file not shown.

0 comments on commit 6628356

Please sign in to comment.