Commit Graph

53 Commits

Author SHA1 Message Date
Nguyen Quang Huy edf170d03b Add signed off to commit (#1766)
- Fix error string should not be capitalized from [Golang coding convention](https://github.com/golang/go/wiki/CodeReviewComments#error-strings)
- Fix some typos

Signed-off-by: Nguyen Quang Huy <huynq0911@gmail.com>
2019-02-25 11:04:42 +01: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
Simon Pasquier b676fa79c0 *: update Makefile.common with new staticcheck (#1692)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-01-04 15:37:33 +01:00
stuart nelson 50b87ac720
Fixes #1570 (#1575)
The documentation stated that the `alertname=`
part of a matcher could be dropped and it would be
assumed that the first value was the alertname.
This behavior was only honored if there was a
single matcher, but failed if there were multiple.

Any time we have one or more matchers, check to
see if the first matcher fails parsing. If so,
assume it's intended to be used as the alertname,
and append that value to the matcher.

Signed-off-by: Stuart Nelson <stuartnelson3@gmail.com>
2018-10-08 13:06:12 +02:00
Martin Chodur 20bdaaf949 fix amtool: Fixed config path check in amtool (#1538)
Signed-off-by: Martin Chodur <m.chodur@seznam.cz>
2018-09-03 06:06:01 +02: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
Martin Chodur 5d222bce55 feat: added routing tools to amtool (#1511)
Signed-off-by: Martin Chodur <m.chodur@seznam.cz>
2018-08-22 16:41:09 +02:00
Julius Volz 6d0edbe630 Fix a bunch of unhandled errors (#1501)
...as discovered by "gosec" (many other ones reported, but not all make
a lot of sense to fix).

Signed-off-by: Julius Volz <julius.volz@gmail.com>
2018-08-05 15:38:25 +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
Bob Shannon 50e271678d Add support for adding alerts using amtool (#1461)
* Add support for adding alerts using amtool

Signed-off-by: Bob Shannon <bshannon@palantir.com>

* comment: Simplify return in addAlert

Signed-off-by: Bob Shannon <bshannon@palantir.com>
2018-07-16 16:29:04 +02:00
Simon Pasquier 5aac7c840b amtool: add support for stdin to check-config (#1431)
* amtool: add support for stdin to check-config

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

* Address Stuart's comment

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-07-09 19:27:04 +02:00
Kellen Fox b949f0dc19 Amtool: Implement filter by receiver fixes:#937 (#1402)
* Amtool: Implement filter by receiver

* Adds receiver flag to amtool alert query
* Adds receiver argument to alert http client
* Updates http client tests for added argument

Also works: scpecifying `receiver: "receiver-123"` in config file
automaticly filters all alerts shown

* Include receiver in amtool config docs

Now that I've implemented the receiver in amtool I should add the new
feature to the documentation.

*  #937 Add mention of supporting regex syntax to receiver flag
2018-06-07 09:21:12 +02:00
Max Inden 402a4aa4a2
Merge pull request #1381 from simonpasquier/add-missing-header
*: add missing license headers
2018-05-28 10:45:39 +02:00
Adam Shannon bf0db5b989 cli: print more config details (#1376)
Example output:

$ amtool check-config alertmanager.yaml
Checking 'alertmanager.yaml'  SUCCESS
Found:
 - global config
 - route
 - 0 inhibit rules
 - 13 receivers
 - 0 templates

Signed-off-by: Adam Shannon <adamkshannon@gmail.com>
2018-05-15 09:17:51 +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
stuart nelson 942be9d993
cli alert query: Expose --active and --unprocessed (#1370)
* cli alert query: Expose --active and --unprocessed

Support the new filter options in the alerts api
endpoint introduced by https://github.com/prometheus/alertmanager/pull/1366

Signed-off-by: stuart nelson <stuartnelson3@gmail.com>

* Update comment and client_test

Signed-off-by: stuart nelson <stuartnelson3@gmail.com>
2018-05-09 10:57:01 +02:00
stuart nelson 1c0c24b300
Update alerts argument order, rename expired to inhibited (#1360)
Signed-off-by: stuart nelson <stuartnelson3@gmail.com>
2018-05-04 10:43:38 +02:00
stuart nelson cfde256913 [amtool] fix silence import --help format 2018-04-24 11:46:24 +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
stuart nelson 360dba6d9a
Rename silence API Delete() -> Expire() (#1319)
Within alertmanager, expire is the term used,
since silences still "exist" but aren't in effect.

Signed-off-by: Stuart Nelson <stuartnelson3@gmail.com>
2018-04-11 12:30:18 +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
Simon Pasquier cb169a5ec6 parse: fix missing argument to fmt.Errorf (#1311) 2018-04-04 10:37:35 +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
Simon Pasquier 0c086e3b12 cli: extract client bindings of the v1 API (#1278)
* cli: extract client bindings of the v1 API from amtool

This is a continuation of [1] but the code is kept in the alertmanage
repository rather than having it in client_golang.

[1] https://github.com/prometheus/client_golang/pull/333

Co-Authored-By: Fabian Reinartz <fab.reinartz@gmail.com>
Co-Authored-By: Tristan Colgate <tcolgate@gmail.com>
Co-Authored-By: Corin Lawson <corin@responsight.com>
Co-Authored-By: stuart nelson <stuartnelson3@gmail.com>

* cli: fix httpSilenceAPI.Set() method

* vendor: remove github.com/prometheus/client_golang/api/alertmanager

* cli: don't use the model.Alert type
2018-03-28 19:19:04 +02:00
Dave Thompson d63c25a855 Set User object in alertmanager url. (#1279) 2018-03-13 14:56:20 +01:00
pasquier-s e8a92f65ef Run staticcheck as part of the build process (#1264)
This change also fixes potential issues highlighted by running
staticcheck.
2018-02-28 17:42:32 +01:00
benbradley 0db01af11e amtool silence update support dwy suffixes to expire flag (#1197) 2018-01-15 19:45:46 +01:00
Stuart Nelson 7d36d79aba Update silence query long help 2018-01-12 10:44:38 +01:00
Thomás S. Bregolin cdb44955cf Make --expired list only expired silences (#1176) (#1190)
This means there's no longer a way to list both active and expired
silences at the same time. This is the desired behaviour according to
consensus at https://github.com/prometheus/alertmanager/pull/1175
2018-01-12 10:35:06 +01:00
Colin Douch 17846f2e33 Fix updating silence comments (#1189)
Possibly another regression introduced by #976 . We use the wrong
variable to update comments in the `amtool silence update` command
which causes us to fail silently. This fixes that.
2018-01-10 17:05:03 +01: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
Colin Douch 873623eec5 Added ability to query for silences that will expire soon (#1120) 2017-12-12 15:36:05 +01:00
Binh Le dbff31dbf1 [amtool] - Add new command to update silence (#1123)
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.
2017-12-11 14:46:59 +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
Jose Donizetti fe390bc28a Improve amtool check-config use and description text (#1016) 2017-10-02 11:22:04 +02:00
Corentin Chary 25e4bb9965 amtool check-config (#978)
This is similar to `promtool check-config` and allows one
to validate the alertmanager configuration (as a git presubmit for example).

`govendor fetch github.com/spf13/{cobra,pflag}` was needed to
have support for `Args`.
2017-09-07 10:58:58 +02:00
Kellen Fox 09bc5dd8e5 Fixes #898 (#938)
Exit with error code from subcommands as well as root command
2017-08-02 23:04:07 +02:00
Matt Bostock 16232ce654 Update config file location in flag usage text (#895)
The config file location was changed in 305263e462. Update the flag usage text accordingly.
2017-07-05 13:09:03 +02:00
Frederic Branczyk c4c0875ba3
fix config JSON marshaling 2017-06-08 13:37:57 +02:00
Kellen Fox 305263e462 Fixes #831 Move config file to a more consistent location and update docs 2017-06-03 14:12:43 -07:00
David Guerrero 1f346a6724 fixing a typo in amtool help text (#829) 2017-05-26 11:27:09 +01:00
Fabian Reinartz 5aff15b30f Merge pull request #773 from prometheus/fixalertstat
Fix alert status handling in UI
2017-05-09 10:09:24 +02:00
Kellen Fox 6aece86ac1 Fixes #746
Found that we are only defining MarshalJSON for the Regexp type for
references not for the direct object

Also took the time to simplify the json.Unmarshal usage in cli/config.go
2017-05-08 11:25:25 -07:00
Fabian Reinartz 8170206070 Fix alert status handling in UI 2017-05-08 12:56:03 +02:00