Commit Graph

20 Commits

Author SHA1 Message Date
Kiril Vladimirov f503012c0b cli: Parse properly all matcher types
Signed-off-by: Kiril Vladimirov <kiril@vladimiroff.org>
2021-02-16 14:22:59 +02:00
Paul Gier 6561774f9e cli: fix some command output formatting
- remove brackets around silence ID when adding new silence
- fix simple formatting of show config

Signed-off-by: Paul Gier <pgier@redhat.com>
2019-03-29 09:11:09 -05:00
Paul Gier 74fa2236f7 cli: update amtool to use apiv2
Includes godoc improvements

Signed-off-by: Paul Gier <pgier@redhat.com>
2019-03-29 09:11:09 -05:00
Hrishikesh Barman dc74b6a15b support for assuming first label is alertname in silence add and query (#1693)
* simplified setting first assumed alertname in cli/silence_query.go
* added assumed first label to alertname when adding silences

Signed-off-by: Hrishikesh Barman <hrishikeshbman@gmail.com>
2019-01-07 13:49:41 +01:00
Dave Barboza 34bc54cee1 Fix rfc3339 example texts (#1526)
Signed-off-by: Dave Barboza <dxbarboza@gmail.com>
2018-08-23 16:17:27 +02:00
stuart nelson bd6100793f
Add timeout support to amtool commands (#1471)
Signed-off-by: stuart nelson <stuartnelson3@gmail.com>
2018-07-17 09:50:48 +02:00
Simon Pasquier 0ebaeccd4b *: add missing license headers
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-05-14 17:37:13 +02:00
Simon Pasquier dc5fc02d22 [amtool] use kingpin.v2 (#1330)
* Use default values to store values from config
* fix typo and reserved keywork
* move to long help texts
* add one more unit test for resolver
* update comments

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-04-24 09:35:15 +02:00
stuart nelson e7bc6e2935
Move amtool to modular structure (#1321)
* Move amtool to modular structure

Signed-off-by: Stuart Nelson <stuartnelson3@gmail.com>

* Move toplevel setup back into root.go

Signed-off-by: Stuart Nelson <stuartnelson3@gmail.com>

* Remove confusing alert struct name overwriting

A local variable within the alert subcommand was
using the name of the struct within that file.

Signed-off-by: Stuart Nelson <stuartnelson3@gmail.com>

* change local var name shadowing struct name

Signed-off-by: Stuart Nelson <stuartnelson3@gmail.com>
2018-04-13 13:34:16 +02:00
Simon Pasquier c92ed69ce8 Split cli package (#1314)
* cli: move commands to cli/cmd

* cli: use StatusAPI interface for config command

* cli: use SilenceAPI interface for silence commands

* cli: use AlertAPI for alert command

* cli: move back commands to cli package

And move API client code to its own package.

* cli: remove unused structs
2018-04-11 11:17:41 +02:00
stuart nelson 19715022a4
[amtool] update silence add and update flags (#1298)
* Update silence add/update flags

- Change --expires/-e to --duration/-d
- Change --expires-on to --end
- Add --start

* update subcommand returns ID of new silence

The silences printed before were accurate, except
they had the old ID. Now the new ID is returned.

* Duration is added to silence.StartsAt

When a user supplies a duration to update a
silence, it is applied to silence.StartsAt after
any potential changes to the silence's start time.
2018-03-29 12:11:31 +02:00
stuart nelson 7b787dab05
Re-introduce prometheus durations in amtool silence creation (#1185)
* Fixes #1183

* Update expires comment

The default time is already output thanks to
kingpin.
2018-01-09 10:47:41 +01:00
Calle Pettersson 608848390f Switch amtool to kingpin (#976)
* Switch cmd/amtool to kingpin

* Touch-ups

* Implement long help

* Add missing short-form of --output

* Fix backwards compatibility for config file options

* Fix vendoring

* Review fixes

* Fix flag word order
2017-12-22 11:17:13 +01:00
Binh Le 9b127147bd [amtool] - Add a new `silence import` command (#1082)
* Add a new `silence import` command to amtool

This command read silences data from a query JSON output and import to
alertmanager. It allows `amtool` to be used as a backup/restore tool for
silences, i.e. #1000

Backup / export:

```
amtool silence -o json > silences.json
```

Restore / import:

```
amtool silence import silences.json
```

* Add a WaitGroup barrier

Move error channel reading to a goroutine to prevent deadlock and thus
add a WaitGroup to synchronize.
2017-12-07 13:12:00 +01:00
Jose Donizetti 7151cd4bfc Clean code style - amtool errors (#1099) 2017-11-12 11:43:48 -05:00
Binh Le ea9a584e8d Allow 'd', 'w', 'y' to be specified at time suffix when creating silence (#1091)
The time.ParseDuration refused to parse them with the reason that a day
can be shorter or longer than 24 hours. But they are already accepted in
Prometheus range query and a custom parser is included in Prometheus
common package so there's no reason amtool cannot use that.

This will be handy in cases you need to create silence for longer periods,
which are unfortunately common.
2017-11-11 14:51:33 +01:00
Julius Volz 9b72c10134 Minor code cleanups 2017-11-01 23:08:34 +01:00
Corentin Chary 21a2e5393f cli/silence_add: don't ingore errors when getting current user (#1031)
I had a system where amtool would segfault on startup because of
that.
2017-10-09 10:10:27 +02:00
Kellen Fox b2c656a071 Add command wrapper to handle printing errors for any subcommands (#724)
Fixes #721

I was using the RunE method of cobra.Command which does things with an
error returned from a function. I doesn't seem possible to keep it from
printing usage every time, so I've make a wrapper to use the other
function.
2017-04-21 14:50:02 +02:00
Kellen Fox 3aab66ec3a Amtool implementation (#636)
* Implement alertmanager cli tool 'amtool'

The primary goal of an alertmanager tool is to provide a cli interface
for the prometheus alertmanager.

My vision for this tool has two parts:
  - Silence management (query, add, delete)

  - Alert management (query, maybe more in future?)

Resolves: #567
2017-04-20 11:04:17 +02:00