-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[amtool] - Add new command to update silence #1123
Conversation
@lebinh I know most of amtool code isn't tested. But I really would like to change that. Especially on new code. Do you mind writing tests here? |
Okay, I'll try to add some test soon |
I'll take a look at this tomorrow. Can you resolve the conflicts? |
This adds a new command, update (and also its alias, extend), to update existing silence in Alertmanager. User can use this command to update the expiration or comment on existing silences. The API already support this so I only expose the same functionality to amtool. Don't allow update CreatedBy field as it is "Created" not "Updated", so we should keep the original author.
bf70b81
to
5991fff
Compare
Resolved, although I haven't got around to add any test yet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few small requests.
I'm not sure if users would want to update date.start
on a silence, to be honest. If that's not something you're interested in we can leave it out and just update the flag name for date.end
, and if people want date.start
it can be added later.
Aliases: []string{"extend"}, | ||
Args: cobra.MinimumNArgs(1), | ||
Short: "Update silences", | ||
Long: `Extend or update existing silence in Alertmanager.`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update this with a longer description, with a usage example? It would also be good to note that expires-on
will override expires
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'dd add that in once we decided on the parameter names :)
} | ||
|
||
func init() { | ||
updateCmd.Flags().StringP("expires", "e", "", "Duration of silence (100h)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking we should rename these. Maybe expires
should become duration
, with d
as the short flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just following the parameter names in silence add
command here. duration
does make more sense than expires
though, but if we are going to change we need to update add
command as well. That will be a breaking change though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point
|
||
func init() { | ||
updateCmd.Flags().StringP("expires", "e", "", "Duration of silence (100h)") | ||
updateCmd.Flags().String("expire-on", "", "Expire at a certain time (Overwrites expires) RFC3339 format 2006-01-02T15:04:05Z07:00") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In alertmanager, you can also update the starting time when editing a silence.
How about adding that as well, and naming the flags date.start
and date.end
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, thinking more about the name .. not sure i like date
. @grobie , naming guru, any recommendation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just follow the field names in Alertmanager API, startsAt
and endsAt
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hrm, those are more json-idiomatic names. for a CLI I think something different would be more appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing out the consistency you were maintaining with silence add
.
I'll go ahead and merge this. Would you like to prepare another PR that updates both update
and add
's API?
I'm thinking we change expires
to duration
, and expire-on
to date.end
, and add date.start
to both commands.
…ave item suffix (prometheus#1123) In some cases the file might be called "temp" instead of the usual format "temp<index>_<item>" as described in the kernel docs: https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface In this case, treat this as an _input file containing the current temperature reading. Fixes prometheus#1122 Signed-off-by: Paul Gier <pgier@redhat.com>
…ave item suffix (prometheus#1123) In some cases the file might be called "temp" instead of the usual format "temp<index>_<item>" as described in the kernel docs: https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface In this case, treat this as an _input file containing the current temperature reading. Fixes prometheus#1122 Signed-off-by: Paul Gier <pgier@redhat.com>
* collector/diskstats: don't fail if there are extra stats, just ignore… (prometheus#1125) * collector/diskstats: don't fail if there are extra stats, just ignore them Signed-off-by: Paul Gier <pgier@redhat.com> Signed-off-by: Ben Kochie <superq@gmail.com> * collector/hwmon_linux: handle temperature sensor file which doesn't have item suffix (prometheus#1123) In some cases the file might be called "temp" instead of the usual format "temp<index>_<item>" as described in the kernel docs: https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface In this case, treat this as an _input file containing the current temperature reading. Fixes prometheus#1122 Signed-off-by: Paul Gier <pgier@redhat.com> Signed-off-by: Ben Kochie <superq@gmail.com> * Handle 'Unknown' as measurement value. (prometheus#1113) We use the output-compatible perccli and storcli.py does not handle 'Unknown' as a result: ``` sg="Error parsing \"/var/lib/node_exporter/perccli.prom\": text format parsing error in line 222: expected float as value, got \"Unknown\"" source="textfile.go:212" ``` I know, the perccli should not return 'Unknown' but this error breaks all other useful measurements because the prom file is not parsable. My if condition fixes this. Signed-off-by: Andreas Wirooks <4233401+nudgegoonies@users.noreply.github.com> Signed-off-by: Ben Kochie <superq@gmail.com> * circleci: switch to 2.1 config Signed-off-by: Ben Kochie <superq@gmail.com> * Convert to Go modules (prometheus#1178) * Convert to Go modules * Update promu config. * Convert to Go modules. * Update vendoring. * Update Makefile.common. * Update circleci config. * Use Prometheus release tar for promtool. * Fixup unpack * Use temp dir for unpacking tools. * Use BSD compatible tar command. * OpenBSD mkdir doesn't support `-v`. Signed-off-by: Ben Kochie <superq@gmail.com> * Add fallback for missing /proc/1/mounts (prometheus#1172) * Add fallback for missing /proc/1/mounts On some systems, `/proc/1/mounts` is hidden from non-root users due to the `hidepid` procfs feature. Attempt to fallback to `/proc/mounts` if `/proc/1/mounts` is not found. Signed-off-by: Ben Kochie <superq@gmail.com> * Add tests. Signed-off-by: Ben Kochie <superq@gmail.com> * Add CHANGELOG entry. Signed-off-by: Ben Kochie <superq@gmail.com> * Release v0.17.0 (prometheus#1168) * Update CHANGELOG * Update VERSION Signed-off-by: Ben Kochie <superq@gmail.com>
This adds a new command,
update
(and also its alias,extend
), to updateexisting silence in Alertmanager. User can use this command to update the
expiration or comment on existing silences. The API already support this
so I only expose the same functionality to amtool.
Don't allow update CreatedBy field as it is "Created" not "Updated", so
we should keep the original author.
Sample usage: