Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alertmanager ttl #6371

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/prometheus-operator/prometheus-operator

go 1.22
go 1.22.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this change intentional?


require (
github.com/alecthomas/kingpin/v2 v2.4.0
Expand Down
5 changes: 5 additions & 0 deletions jsonnet/prometheus-operator/alertmanagerconfigs-crd.json
Original file line number Diff line number Diff line change
Expand Up @@ -2721,6 +2721,11 @@
"description": "The token file that contains the registered application's API token, see https://pushover.net/apps. Either `token` or `tokenFile` is required. It requires Alertmanager >= v0.26.0.",
"type": "string"
},
"ttl": {
"description": "time to live for the alert notification",
"format": "int64",
"type": "integer"
},
"url": {
"description": "A supplementary URL shown alongside the message.",
"type": "string"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2567,6 +2567,11 @@
description: "The token file that contains the registered application's API token, see https://pushover.net/apps. Either `token` or `tokenFile` is required. It requires Alertmanager >= v0.26.0.",
type: 'string',
},
ttl: {
description: 'time to live for the alert notification',
format: 'int64',
type: 'integer',
},
url: {
description: 'A supplementary URL shown alongside the message.',
type: 'string',
Expand Down
1 change: 1 addition & 0 deletions pkg/alertmanager/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
// https://github.com/prometheus/alertmanager/issues/1985
type alertmanagerConfig struct {
Global *globalConfig `yaml:"global,omitempty" json:"global,omitempty"`
TTL duration `yaml:"ttl,omitempty" json:"ttl,omitempty"`

Check failure on line 32 in pkg/alertmanager/types.go

View workflow job for this annotation

GitHub Actions / Golang linter

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/prometheus-operator/prometheus-operator) (gci)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a linting problem here, you can fix it by running make format :)

Route *route `yaml:"route,omitempty" json:"route,omitempty"`
InhibitRules []*inhibitRule `yaml:"inhibit_rules,omitempty" json:"inhibit_rules,omitempty"`
Receivers []*receiver `yaml:"receivers,omitempty" json:"receivers,omitempty"`
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/monitoring/v1alpha1/alertmanager_config_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"errors"
"fmt"
"strings"
"time"

monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"

Expand Down Expand Up @@ -783,6 +784,9 @@ type PushoverConfig struct {
// Notification title.
// +optional
Title string `json:"title,omitempty"`
// time to live for the alert notification
// +optional
TTL time.Duration `json:"ttl,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TTL time.Duration `json:"ttl,omitempty"`
TTL *Duration `json:"ttl,omitempty"`

We have a custom Duration type, which has some useful validations on the API level. Could we use this one instead?

Also, we follow k8s API conventions as much as possible, which means we want to use pointers for optional fields.

// Notification message.
// +optional
Message string `json:"message,omitempty"`
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/monitoring/v1beta1/alertmanager_config_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"errors"
"fmt"
"strings"
"time"

monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"

Expand Down Expand Up @@ -778,6 +779,9 @@ type PushoverConfig struct {
// Notification message.
// +optional
Message string `json:"message,omitempty"`
// time to live for the alert notification
// +optional
TTL time.Duration `json:"ttl,omitempty"`
// A supplementary URL shown alongside the message.
// +optional
URL string `json:"url,omitempty"`
Expand Down
Loading