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

Add sentry support #6

Merged
merged 3 commits into from
Sep 21, 2018
Merged
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

## v0.3.0

[PR#6](https://github.com/ContainerSolutions/helm-monitor/pull/6):

- add Sentry support
- adjust documentation and command line helpers

## v0.2.0

[PR#5](https://github.com/ContainerSolutions/helm-monitor/pull/5):
Expand Down
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Helm Monitor plugin
===================

> Monitor a release, rollback to a previous version depending on the result of
a PromQL (Prometheus), Lucene or DSL query (ElasticSearch).
a PromQL (Prometheus), events (Sentry), Lucene or DSL query (ElasticSearch).

![Helm monitor failure](helm-monitor-failure.png)

Expand Down Expand Up @@ -69,6 +69,23 @@ $ helm monitor elasticsearch --elasticsearch=http://elasticsearch:9200 \
'status:500 AND kubernetes.labels.app:app AND version:2.0.0'
```

### Sentry

Monitor the **peeking-bunny** release against a Sentry server, a rollback is
initiated if the number of events is over 0 for the release 2.0.0:

```bash
$ helm monitor sentry my-app \
--api-key <SENTRY_API_KEY> \
--organization sentry \
--project my-project \
--sentry http://sentry:9000 \
--tag release=2.0.0 \
--regexp
'Error with database connection.*'
```


## Docker

You can also use the Helm monitor backed Docker image to monitor:
Expand Down
7 changes: 4 additions & 3 deletions cmd/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
var (
settings helm_env.EnvSettings
monitor *monitorCmd
verbose bool
)

type monitorCmd struct {
Expand All @@ -25,7 +26,6 @@ type monitorCmd struct {
interval int64
rollbackTimeout int64
timeout int64
verbose bool
wait bool
}

Expand Down Expand Up @@ -56,7 +56,7 @@ func prettyError(err error) error {
}

func debug(format string, args ...interface{}) {
if monitor.verbose {
if verbose {
format = fmt.Sprintf("[debug] %s\n", format)
fmt.Printf(format, args...)
}
Expand All @@ -77,14 +77,15 @@ func newMonitorCmd(out io.Writer) *cobra.Command {
p.Int64Var(&monitor.expectedResultCount, "expected-result-count", 0, "number of results that are expected to be returned by the query (rollback triggered if the number of results exceeds this value)")
p.BoolVar(&monitor.force, "force", false, "force resource update through delete/recreate if needed")
p.BoolVar(&monitor.wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking a rollback as successful. It will wait for as long as --rollback-timeout")
p.BoolVarP(&monitor.verbose, "verbose", "v", false, "enable verbose output")
p.BoolVarP(&verbose, "verbose", "v", false, "enable verbose output")
p.Int64Var(&monitor.rollbackTimeout, "rollback-timeout", 300, "time in seconds to wait for any individual Kubernetes operation during the rollback (like Jobs for hooks)")
p.Int64Var(&monitor.timeout, "timeout", 300, "time in seconds to wait before assuming a monitoring action is successfull")
p.Int64VarP(&monitor.interval, "interval", "i", 10, "time in seconds between each query")

cmd.AddCommand(
newMonitorPrometheusCmd(out),
newMonitorElasticSearchCmd(out),
newMonitorSentryCmd(out),
)

return cmd
Expand Down
10 changes: 5 additions & 5 deletions cmd/monitor_elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ empty result.
The query argument can be either the path of a query DSL json file or a Lucene
query string.

Usage with Lucene query:
Example with Lucene query:

$ helm monitor elasticsearch frontend 'status:500 AND kubernetes.labels.app:app AND version:2.0.0'
$ helm monitor elasticsearch my-release 'status:500 AND kubernetes.labels.app:app AND version:2.0.0'

Usage with query DSL file:
Example with query DSL file:

$ helm monitor elasticsearch frontend ./examples/elasticsearch-query.json
$ helm monitor elasticsearch my-release ./examples/elasticsearch-query.json


Reference:

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html

`

Expand Down
6 changes: 3 additions & 3 deletions cmd/monitor_prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ This command monitor a release by querying Prometheus at a given interval and
take care of rolling back to the previous version if the query return a non-
empty result.

Usage:
Example:

$ helm monitor prometheus frontend 'rate(http_requests_total{code=~"^5.*$"}[5m]) > 0'
$ helm monitor prometheus my-release 'rate(http_requests_total{code=~"^5.*$"}[5m]) > 0'


Reference:

https://prometheus.io/docs/prometheus/latest/querying/basics/
https://prometheus.io/docs/prometheus/latest/querying/basics/

`

Expand Down
Loading