Commit Graph

7 Commits

Author SHA1 Message Date
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