for #21440 # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Manual QA for all new/changed functionality |
||
|---|---|---|
| .. | ||
| lambda | ||
| .header.md | ||
| .terraform-docs.yml | ||
| main.tf | ||
| README.md | ||
| variables.tf | ||
Monitoring addon
This addon enables Cloudwatch monitoring for Fleet.
This includes:
- 5XX Errors on ALB
- ECS Service Monitoring
- RDS Monitoring
- Redis Monitoring
- ACM Certificate Monitoring
- A custom Lambda to check the Fleet DB for Cron runs
Preparation
Some of the for_each and counts in this module cannot pre-determine the numbers until the main fleet module is applied.
You will need to terraform apply -target module.main prior applying monitoring assuming the use of a configuration matching the example at https://github.com/fleetdm/fleet/blob/main/terraform/example/main.tf.
Multiple alb support was added in order to allow monitoring saml-auth-proxy. See https://github.com/fleetdm/fleet/tree/main/terraform/addons/saml-auth-proxy
Example configuration
This assumes your fleet module is main and is configured with it's default documentation.
https://github.com/fleetdm/fleet/blob/main/terraform/example/main.tf for details.
Note if you haven't specified defined local.customer or customized service names, the default is "fleet" for anywhere that local.customer is specified below.
module "monitoring" {
source = "github.com/fleetdm/fleet//terraform/addons/monitoring?ref=tf-mod-addon-monitoring-v1.4.0"
customer_prefix = local.customer
fleet_ecs_service_name = module.main.byo-vpc.byo-db.byo-ecs.service.name
albs = [
{
name = module.main.byo-vpc.byo-db.alb.lb_dns_name,
target_group_name = module.main.byo-vpc.byo-db.alb.target_group_names[0]
target_group_arn_suffix = module.main.byo-vpc.byo-db.alb.target_group_arn_suffixes[0]
arn_suffix = module.main.byo-vpc.byo-db.alb.lb_arn_suffix
ecs_service_name = module.main.byo-vpc.byo-db.byo-ecs.service.name
min_containers = module.main.byo-vpc.byo-db.byo-ecs.appautoscaling_target.min_capacity
alert_thresholds = {
HTTPCode_ELB_5XX_Count = {
period = 3600
threshold = 2
},
HTTPCode_Target_5XX_Count = {
period = 120
threshold = 0
}
}
},
]
sns_topic_arns_map = {
alb_httpcode_5xx = [var.slack_topic_arn]
cron_monitoring = [var.slack_topic_arn]
}
mysql_cluster_members = module.main.byo-vpc.rds.cluster_members
# The cloudposse module seems to have a nested list here.
redis_cluster_members = module.main.byo-vpc.redis.member_clusters[0]
acm_certificate_arn = module.acm.acm_certificate_arn
cron_monitoring = {
mysql_host = module.main.byo-vpc.rds.cluster_reader_endpoint
mysql_database = module.main.byo-vpc.rds.cluster_database_name
mysql_user = module.main.byo-vpc.rds.cluster_master_username
mysql_password_secret_name = module.main.byo-vpc.secrets.secret_ids["${local.customer}-database-password"]
rds_security_group_id = module.main.byo-vpc.rds.security_group_id
subnet_ids = module.main.vpc.private_subnets
vpc_id = module.main.vpc.vpc_id
# Format of https://pkg.go.dev/time#ParseDuration
delay_tolerance = "4h"
# Interval format for: https://docs.aws.amazon.com/scheduler/latest/UserGuide/schedule-types.html#rate-based
run_interval = "1 hour"
log_retention_in_days = 365
}
}
SNS topic ARNs map
Valid targets for sns_topic_arns_map:
- acm_certificate_expired
- alb_helthyhosts
- alb_httpcode_5xx
- backend_response_time
- cron_monitoring
- rds_cpu_untilizaton_too_high
- rds_db_event_subscription
- redis_cpu_engine_utilization
- redis_cpu_utilization
- redis_current_connections
- redis_database_memory_percentage
- redis_replication_lag
If you want to publish to all, use default_sns_topic_arns instead and include your notification ARNs there.
Requirements
No requirements.
Providers
| Name | Version |
|---|---|
| archive | 2.4.0 |
| aws | 5.22.0 |
| null | 3.2.1 |
Modules
No modules.
Resources
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| acm_certificate_arn | n/a | string |
null |
no |
| albs | n/a | list(object({ |
[] |
no |
| cron_monitoring | n/a | object({ |
null |
no |
| customer_prefix | n/a | string |
"fleet" |
no |
| default_sns_topic_arns | n/a | list(string) |
[] |
no |
| fleet_ecs_service_name | n/a | string |
null |
no |
| mysql_cluster_members | n/a | list(string) |
[] |
no |
| redis_cluster_members | n/a | list(string) |
[] |
no |
| sns_topic_arns_map | n/a | map(list(string)) |
{} |
no |
Outputs
No outputs.