@@ -385,7 +385,12 @@ module "ooni_clickhouse_proxy" {
385385 to_port = 9200 ,
386386 protocol = " tcp"
387387 cidr_blocks = [for ip in flatten (data. dns_a_record_set . monitoring_host . * . addrs ) : " ${ tostring (ip)} /32" ]
388- }]
388+ }, {
389+ from_port = 9100 ,
390+ to_port = 9100 ,
391+ protocol = " tcp"
392+ cidr_blocks = [" ${ module . ooni_monitoring_proxy . aws_instance_private_ip } /32" ]
393+ }]
389394
390395 egress_rules = [{
391396 from_port = 0 ,
@@ -419,6 +424,70 @@ resource "aws_route53_record" "clickhouse_proxy_alias" {
419424 ]
420425}
421426
427+ # ### Monitoring Proxy
428+ module "ooni_monitoring_proxy" {
429+ source = " ../../modules/ec2"
430+
431+ stage = local. environment
432+
433+ vpc_id = module. network . vpc_id
434+ subnet_id = module. network . vpc_subnet_public [0 ]. id
435+ private_subnet_cidr = module. network . vpc_subnet_private [* ]. cidr_block
436+ dns_zone_ooni_io = local. dns_zone_ooni_io
437+
438+ key_name = module. adm_iam_roles . oonidevops_key_name
439+ instance_type = " t3a.nano"
440+
441+ name = " oonimnprx"
442+ ingress_rules = [{
443+ from_port = 22 ,
444+ to_port = 22 ,
445+ protocol = " tcp" ,
446+ cidr_blocks = [" 0.0.0.0/0" ],
447+ }, {
448+ from_port = 80 ,
449+ to_port = 80 ,
450+ protocol = " tcp" ,
451+ cidr_blocks = [" 0.0.0.0/0" ],
452+ }, {
453+ // For the prometheus proxy:
454+ from_port = 9200 ,
455+ to_port = 9200 ,
456+ protocol = " tcp"
457+ cidr_blocks = [for ip in flatten (data. dns_a_record_set . monitoring_host . * . addrs ) : " ${ tostring (ip)} /32" ]
458+ }]
459+
460+ egress_rules = [{
461+ from_port = 0 ,
462+ to_port = 0 ,
463+ protocol = " -1" ,
464+ cidr_blocks = [" 0.0.0.0/0" ],
465+ }, {
466+ from_port = 0 ,
467+ to_port = 0 ,
468+ protocol = " -1" ,
469+ ipv6_cidr_blocks = [" ::/0" ]
470+ }]
471+
472+ sg_prefix = " oomnprx"
473+ tg_prefix = " mnpr"
474+
475+ tags = merge (
476+ local. tags ,
477+ { Name = " ooni-tier1-monitoringproxy" }
478+ )
479+ }
480+
481+ resource "aws_route53_record" "monitoring_proxy_alias" {
482+ zone_id = local. dns_zone_ooni_io
483+ name = " monitoringproxy.${ local . environment } .ooni.io"
484+ type = " CNAME"
485+ ttl = 300
486+
487+ records = [
488+ module . ooni_monitoring_proxy . aws_instance_public_dns
489+ ]
490+ }
422491
423492# ## OONI Services Clusters
424493
@@ -441,7 +510,8 @@ module "ooniapi_cluster" {
441510 # The clickhouse proxy has an nginx configuration
442511 # to proxy requests from the monitoring server
443512 # to the cluster instances
444- module . ooni_clickhouse_proxy . ec2_sg_id
513+ module . ooni_clickhouse_proxy . ec2_sg_id ,
514+ module . ooni_monitoring_proxy . ec2_sg_id
445515 ]
446516
447517 tags = merge (
@@ -823,7 +893,10 @@ module "ansible_controller" {
823893
824894 dns_zone_ooni_io = local. dns_zone_ooni_io
825895
826- monitoring_sg_ids = [module . ooni_clickhouse_proxy . ec2_sg_id ]
896+ monitoring_sg_ids = [
897+ module . ooni_clickhouse_proxy . ec2_sg_id ,
898+ module . ooni_monitoring_proxy . ec2_sg_id
899+ ]
827900
828901 tags = {
829902 Environment = local.environment
0 commit comments