-
Notifications
You must be signed in to change notification settings - Fork 0
refs platform/board#4052: add Typesense monitoring alerts and configuration for uptime checks and container checks #10
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ff59097
refs platform/board#4052: add Typesense monitoring alerts and configu…
FabrizioCafolla 64a67d1
Update variables.tf
FabrizioCafolla 44e172e
Update typesense.tf
FabrizioCafolla 1a19a5a
Update typesense.tf
FabrizioCafolla b783cb8
Update CHANGELOG.md
FabrizioCafolla 88fcbbe
update
FabrizioCafolla 2574306
Apply suggestion from @Copilot
FabrizioCafolla 6d8d576
update
FabrizioCafolla 357500b
update
FabrizioCafolla 940ee5d
update
FabrizioCafolla ccec26c
update
FabrizioCafolla 7c3fced
update
FabrizioCafolla 91ddaed
update
FabrizioCafolla 1f3f91d
update
FabrizioCafolla 40038b8
remove oom killed
FabrizioCafolla 124bdca
update
FabrizioCafolla 08afac7
Update variables.tf
FabrizioCafolla 09b5386
Update typesense.tf
FabrizioCafolla 10cc3e5
update
FabrizioCafolla 1c8c470
update
FabrizioCafolla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
|
|
||
| locals { | ||
| typesense_project = var.typesense.project_id != null ? var.typesense.project_id : var.project_id | ||
|
|
||
| typesense_notification_channels = var.typesense.notification_enabled ? (length(var.typesense.notification_channels) > 0 ? var.typesense.notification_channels : var.notification_channels) : [] | ||
|
|
||
| typesense_uptime_checks = var.typesense.enabled ? { | ||
| for app_name, config in var.typesense.apps : | ||
| app_name => config.uptime_check | ||
| if config.uptime_check != null && try(config.uptime_check.enabled, false) | ||
| } : {} | ||
|
|
||
| typesense_container_checks = var.typesense.enabled ? { | ||
| for app_name, config in var.typesense.apps : | ||
| app_name => config.container_check | ||
| if config.container_check != null && try(config.container_check.enabled, false) | ||
|
FabrizioCafolla marked this conversation as resolved.
FabrizioCafolla marked this conversation as resolved.
|
||
| } : {} | ||
| } | ||
|
|
||
| module "typesense_uptime_checks" { | ||
| for_each = local.typesense_uptime_checks | ||
|
|
||
| source = "github.com/sparkfabrik/terraform-sparkfabrik-gcp-http-monitoring?ref=1.0.0" | ||
| gcp_project = local.typesense_project | ||
| uptime_monitoring_host = each.value.host | ||
| uptime_monitoring_path = each.value.path | ||
| alert_notification_channels = local.typesense_notification_channels | ||
| alert_threshold_value = 1 | ||
| uptime_check_period = "900s" | ||
| } | ||
|
|
||
| # Alert: GKE Pod Restarts | ||
| # This alert monitors the restart count of Typesense containers in GKE. | ||
| # It triggers when the delta of restarts is greater than the threshold | ||
| # within the specified alignment period. | ||
| resource "google_monitoring_alert_policy" "typesense_pod_restart" { | ||
| for_each = local.typesense_container_checks | ||
|
|
||
| project = local.typesense_project | ||
| display_name = "Typesense Pod Restarts (cluster=${var.typesense.cluster_name}, namespace=${each.value.namespace}, app=${each.key})" | ||
| combiner = "OR" | ||
| enabled = true | ||
|
|
||
| conditions { | ||
| display_name = "Typesense container restart count > ${each.value.pod_restart.threshold}" | ||
|
|
||
| condition_threshold { | ||
| filter = <<-EOT | ||
| resource.type="k8s_container" | ||
| AND resource.labels.project_id="${local.typesense_project}" | ||
| AND resource.labels.cluster_name="${var.typesense.cluster_name}" | ||
| AND resource.labels.namespace_name="${each.value.namespace}" | ||
| AND metric.type="kubernetes.io/container/restart_count" | ||
|
FabrizioCafolla marked this conversation as resolved.
|
||
| EOT | ||
|
|
||
| comparison = "COMPARISON_GT" | ||
| threshold_value = each.value.pod_restart.threshold | ||
| duration = "${each.value.pod_restart.duration}s" | ||
|
|
||
| aggregations { | ||
| alignment_period = "${each.value.pod_restart.alignment_period}s" | ||
| per_series_aligner = "ALIGN_DELTA" | ||
| cross_series_reducer = "REDUCE_SUM" | ||
| group_by_fields = [ | ||
| "metadata.user_labels.app", | ||
| ] | ||
| } | ||
|
|
||
| trigger { | ||
| count = 1 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| notification_channels = local.typesense_notification_channels | ||
|
|
||
| alert_strategy { | ||
| auto_close = "${each.value.pod_restart.auto_close_seconds}s" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.