Skip to content

Commit a1e18e3

Browse files
feat: remove dependecies
1 parent 9034719 commit a1e18e3

File tree

4 files changed

+176
-4
lines changed

4 files changed

+176
-4
lines changed

lite_llm.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ locals {
1919
module "litellm_uptime_checks" {
2020
for_each = local.litellm_uptime_checks
2121

22-
source = "github.com/sparkfabrik/terraform-sparkfabrik-gcp-http-monitoring?ref=1.0.0"
23-
gcp_project = local.litellm_project
22+
source = "./modules/http_monitoring"
23+
gcp_project_id = local.litellm_project
2424
uptime_monitoring_host = each.value.host
2525
uptime_monitoring_path = each.value.path
2626
alert_notification_channels = local.litellm_notification_channels

modules/http_monitoring/main.tf

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
locals {
2+
suffix = var.uptime_monitoring_path != "/" ? var.uptime_monitoring_path : ""
3+
uptime_monitoring_display_name = var.uptime_monitoring_display_name != "" ? "${var.uptime_monitoring_display_name} - ${var.uptime_monitoring_host}${local.suffix}" : "${var.uptime_monitoring_host}${local.suffix}"
4+
alert_display_name = var.alert_display_name != "" ? var.alert_display_name : "Failure of uptime check for: ${local.uptime_monitoring_display_name}"
5+
}
6+
7+
resource "google_monitoring_uptime_check_config" "https_uptime" {
8+
display_name = local.uptime_monitoring_display_name
9+
timeout = var.uptime_check_timeout
10+
period = var.uptime_check_period
11+
selected_regions = var.uptime_check_regions
12+
13+
http_check {
14+
path = var.uptime_monitoring_path
15+
port = "443"
16+
use_ssl = true
17+
validate_ssl = true
18+
headers = var.uptime_monitoring_headers
19+
20+
dynamic "accepted_response_status_codes" {
21+
for_each = var.accepted_response_status_values
22+
23+
content {
24+
status_value = accepted_response_status_codes.value
25+
}
26+
}
27+
28+
dynamic "accepted_response_status_codes" {
29+
for_each = var.accepted_response_status_classes
30+
31+
content {
32+
status_class = accepted_response_status_codes.value
33+
}
34+
}
35+
}
36+
37+
monitored_resource {
38+
type = "uptime_url"
39+
labels = {
40+
project_id = var.gcp_project_id
41+
host = var.uptime_monitoring_host
42+
}
43+
}
44+
45+
project = var.gcp_project_id
46+
47+
lifecycle {
48+
create_before_destroy = true
49+
}
50+
}
51+
52+
# -------------
53+
# Alerts policy
54+
# -------------
55+
resource "google_monitoring_alert_policy" "failure_alert" {
56+
display_name = local.alert_display_name
57+
combiner = "OR"
58+
59+
conditions {
60+
condition_threshold {
61+
filter = "metric.type=\"monitoring.googleapis.com/uptime_check/check_passed\" AND metric.label.check_id=\"${google_monitoring_uptime_check_config.https_uptime.uptime_check_id}\" AND resource.type=\"uptime_url\""
62+
comparison = "COMPARISON_LT"
63+
threshold_value = var.alert_threshold_value
64+
duration = var.alert_threshold_duration
65+
trigger {
66+
count = 1
67+
}
68+
aggregations {
69+
alignment_period = "1200s"
70+
per_series_aligner = "ALIGN_NEXT_OLDER"
71+
cross_series_reducer = "REDUCE_COUNT_TRUE"
72+
group_by_fields = []
73+
}
74+
}
75+
display_name = local.alert_display_name
76+
}
77+
78+
user_labels = var.uptime_alert_user_labels
79+
80+
notification_channels = var.alert_notification_channels
81+
project = var.gcp_project_id
82+
83+
depends_on = [
84+
google_monitoring_uptime_check_config.https_uptime
85+
]
86+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
variable "gcp_project_id" {
2+
type = string
3+
description = "The Google Cloud project ID."
4+
}
5+
6+
variable "uptime_monitoring_display_name" {
7+
type = string
8+
description = "A human-friendly name for the uptime check configuration. Used for monitoring display_name."
9+
default = ""
10+
}
11+
12+
variable "uptime_monitoring_path" {
13+
type = string
14+
description = "The path to the page to run the check against."
15+
default = "/"
16+
}
17+
18+
variable "uptime_check_period" {
19+
type = string
20+
description = "How often, in seconds, the uptime check is performed. Currently, the only supported values are 60s (1 minute), 300s (5 minutes), 600s (10 minutes), and 900s (15 minutes). Defaults to 300s."
21+
default = "60s"
22+
}
23+
24+
variable "uptime_check_timeout" {
25+
type = string
26+
description = "The maximum amount of time to wait for the request to complete (must be between 1 and 60 seconds)."
27+
default = "10s"
28+
}
29+
30+
variable "uptime_monitoring_host" {
31+
type = string
32+
description = "A hostname to monitor (without protocol, example: 'www.my-site.com')."
33+
}
34+
35+
variable "uptime_check_regions" {
36+
type = list(string)
37+
description = "The list of regions from which the check will be run. Some regions contain one location, and others contain more than one. If this field is specified, enough regions to include a minimum of 3 locations must be provided, or an error message is returned. Not specifying this field will result in uptime checks running from all regions."
38+
default = ["USA_VIRGINIA", "EUROPE", "ASIA_PACIFIC"]
39+
}
40+
41+
variable "uptime_alert_user_labels" {
42+
type = map(string)
43+
description = "This field is intended to be used for labelling the SSL alerts. Labels and values can contain only lowercase letters, numerals, underscores, and dashes. Keys must begin with a letter."
44+
default = {}
45+
}
46+
47+
variable "uptime_monitoring_headers" {
48+
type = map(string)
49+
description = "A set of key/value header pairs to send in the HTTP request to the URL."
50+
default = {}
51+
}
52+
53+
variable "alert_threshold_duration" {
54+
type = string
55+
description = "The amount of time that a time series must violate the threshold to be considered failing. Currently, only values that are a multiple of a minute--e.g., 0, 60, 120, or 300 seconds--are supported."
56+
default = "60s"
57+
}
58+
59+
variable "alert_threshold_value" {
60+
type = number
61+
description = "A value against which to compare the time series."
62+
default = 1
63+
}
64+
65+
variable "alert_notification_channels" {
66+
type = list(string)
67+
description = "Identifies the notification channels to which notifications should be sent when incidents are opened or closed. The syntax of the entries in this field is projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]"
68+
}
69+
70+
variable "alert_display_name" {
71+
type = string
72+
description = "A human-friendly name for the alert policy. Used for monitoring display_name."
73+
default = ""
74+
}
75+
76+
variable "accepted_response_status_values" {
77+
description = "Check will only pass if the HTTP response status code is in this set of status values (combined with the set of status classes)."
78+
type = set(number)
79+
default = []
80+
}
81+
82+
variable "accepted_response_status_classes" {
83+
description = "Check will only pass if the HTTP response status code is in this set of status classes (combined with the set of status values). Possible values: STATUS_CLASS_1XX, STATUS_CLASS_2XX, STATUS_CLASS_3XX, STATUS_CLASS_4XX, STATUS_CLASS_5XX, STATUS_CLASS_ANY"
84+
type = set(string)
85+
default = []
86+
}

typesense.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ locals {
1919
module "typesense_uptime_checks" {
2020
for_each = local.typesense_uptime_checks
2121

22-
source = "github.com/sparkfabrik/terraform-sparkfabrik-gcp-http-monitoring?ref=1.0.0"
23-
gcp_project = local.typesense_project
22+
source = "./modules/http_monitoring"
23+
gcp_project_id = local.typesense_project
2424
uptime_monitoring_host = each.value.host
2525
uptime_monitoring_path = each.value.path
2626
alert_notification_channels = local.typesense_notification_channels

0 commit comments

Comments
 (0)