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
Resource: Alerts #297
Resource: Alerts #297
Conversation
Codecov ReportBase: 88.59% // Head: 88.49% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #297 +/- ##
==========================================
- Coverage 88.59% 88.49% -0.10%
==========================================
Files 46 48 +2
Lines 3709 3939 +230
==========================================
+ Hits 3286 3486 +200
- Misses 423 453 +30
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
<b>New Alert Resource</b> (closes goblet#278) You can deploy alerts related to your application by using the alert method. Each alert takes a name and a list of conditions. Notification channels can be added to the `alerts.notification_channel` key in `config.json` or explicity in the alert. The base `AlertCondition` class allows you to fully customize your alert based on the fields privided by the [GCP Alert Resource](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.alertPolicies#conditionhttps://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.alertPolicies#condition>) If you do not need a fully customized alert you can use the built in classes for `MetricCondition`, `LogMatchCondition`, and `CustomMetricCondition`. These come with defaults in terms of duration and aggregations, but can be overriden as needed. The `CustomMetricCondition` creates a custom metric based on the filter provided and then creates an alert using that metric. from goblet.resources.alerts import MetricCondition,LogMatchCondition,CustomMetricCondition app = Goblet() # Example Metric Alert for the cloudfunctin metric execution_count with a threshold of 10 app.alert("metric",conditions=[MetricCondition("test", metric="cloudfunctions.googleapis.com/function/execution_count", value=10)]) # Example Log Match metric that will trigger an incendent off of any Error logs app.alert("error",conditions=[LogMatchCondition("error", "severity>=ERROR")]) # Example Metric Alert that creates a custom metric for severe errors with http code in the 500's and creates an alert with a threshold of 10 app.alert("custom",conditions=[CustomMetricCondition("custom", metric_filter='severity=(ERROR OR CRITICAL OR ALERT OR EMERGENCY) httpRequest.status=(500 OR 501 OR 502 OR 503 OR 504)', value=10)])
New Alert Resource (closes #278)
You can deploy alerts related to your application by using the alert method. Each alert takes a name and a list of conditions. Notification channels
can be added to the
alerts.notification_channel
key inconfig.json
or explicity in the alert. The baseAlertCondition
class allows you tofully customize your alert based on the fields privided by the GCP Alert Resource
If you do not need a fully customized alert you can use the built in classes for
MetricCondition
,LogMatchCondition
, andCustomMetricCondition
. These come withdefaults in terms of duration and aggregations, but can be overriden as needed. The
CustomMetricCondition
creates a custom metric based on the filter provided and thencreates an alert using that metric.