Skip to content

Commit

Permalink
terraform: support TBS in standalone_apm_server (#15337)
Browse files Browse the repository at this point in the history
Support TBS in testing/infra/terraform/modules/standalone_apm_server
  • Loading branch information
carsonip authored Jan 23, 2025
1 parent 9d457a5 commit f6af1e9
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 11 deletions.
5 changes: 5 additions & 0 deletions testing/benchmark/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,14 @@ module "standalone_apm_server" {
vpc_id = module.vpc.vpc_id
aws_os = "amzn2-ami-hvm-*-x86_64-ebs"
apm_instance_type = var.standalone_apm_server_instance_size
apm_volume_type = var.standalone_apm_server_volume_type
apm_volume_size = var.standalone_apm_server_volume_size
apm_server_bin_path = var.apm_server_bin_path
ea_managed = false

apm_server_tail_sampling = var.apm_server_tail_sampling
apm_server_tail_sampling_storage_limit = var.apm_server_tail_sampling_storage_limit

aws_provisioner_key_name = var.private_key

elasticsearch_url = module.moxy[0].moxy_url
Expand Down
10 changes: 9 additions & 1 deletion testing/benchmark/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ user_name = "USER"
# The number of AZs the APM Server should span.
# apm_server_zone_count = 2

# Tail-based sampling settings of the APM Server.
# apm_server_tail_sampling = false
# apm_server_tail_sampling_storage_limit = "10GB"

# The Elasticsearch cluster node size.
# elasticsearch_size = "1g"

Expand Down Expand Up @@ -71,5 +75,9 @@ user_name = "USER"
# Override the default APM Server VM size in standalone bench mode.
# standalone_apm_server_instance_size = "c6i.2xlarge"

# Override the default APM Server VM volume settings in standalone bench mode
# standalone_apm_server_volume_type = "gp2"
# standalone_apm_server_volume_size = 8

# Override the default Moxy VM size in standalone bench mode.
# standalone_moxy_instance_size = "c6i.4xlarge"
# standalone_moxy_instance_size = "c6i.4xlarge"
12 changes: 12 additions & 0 deletions testing/benchmark/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ variable "standalone_moxy_instance_size" {
description = "Optional instance type to use for moxy VM"
}

variable "standalone_apm_server_volume_type" {
default = null
type = string
description = "Optional volume type to use for APM Server VM"
}

variable "standalone_apm_server_volume_size" {
default = null
type = number
description = "Optional volume size in GB to use for APM Server VM"
}

## VPC Network settings

variable "vpc_cidr" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ This module can be used to create a standalone APM Server deployment against a s

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_apm_instance_type"></a> [apm\_instance\_type](#input\_apm\_instance\_type) | Optional apm server instance type overide | `string` | `""` | no |
| <a name="input_apm_instance_type"></a> [apm\_instance\_type](#input\_apm\_instance\_type) | Optional apm server instance type override | `string` | `""` | no |
| <a name="input_apm_server_bin_path"></a> [apm\_server\_bin\_path](#input\_apm\_server\_bin\_path) | Optionally use the apm-server binary from the specified path instead | `string` | `""` | no |
| <a name="input_apm_server_tail_sampling"></a> [apm\_server\_tail\_sampling](#input\_apm\_server\_tail\_sampling) | Whether or not to enable APM Server tail-based sampling. Defaults to false | `bool` | `false` | no |
| <a name="input_apm_server_tail_sampling_storage_limit"></a> [apm\_server\_tail\_sampling\_storage\_limit](#input\_apm\_server\_tail\_sampling\_storage\_limit) | Storage size limit of APM Server tail-based sampling. Defaults to 10GB | `string` | `"10GB"` | no |
| <a name="input_apm_volume_size"></a> [apm\_volume\_size](#input\_apm\_volume\_size) | Optional apm server volume size in GB override | `number` | `null` | no |
| <a name="input_apm_volume_type"></a> [apm\_volume\_type](#input\_apm\_volume\_type) | Optional apm server volume type override | `string` | `null` | no |
| <a name="input_aws_os"></a> [aws\_os](#input\_aws\_os) | Optional aws EC2 instance OS | `string` | `""` | no |
| <a name="input_aws_provisioner_key_name"></a> [aws\_provisioner\_key\_name](#input\_aws\_provisioner\_key\_name) | ssh key name to create the aws key pair and remote provision the EC2 instance | `string` | n/a | yes |
| <a name="input_ea_managed"></a> [ea\_managed](#input\_ea\_managed) | Whether or not install Elastic Agent managed APM Server | `bool` | `false` | no |
| <a name="input_elasticsearch_password"></a> [elasticsearch\_password](#input\_elasticsearch\_password) | The Elasticsearch password | `string` | n/a | yes |
| <a name="input_elasticsearch_url"></a> [elasticsearch\_url](#input\_elasticsearch\_url) | The secure Elasticsearch URL | `string` | n/a | yes |
| <a name="input_elasticsearch_username"></a> [elasticsearch\_username](#input\_elasticsearch\_username) | The Elasticsearch username | `string` | n/a | yes |
| <a name="input_stack_version"></a> [stack\_version](#input\_stack\_version) | Optional stack version | `string` | `"latest"` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Optional set of tags to use for all deployments | `map(string)` | `{}` | no |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | VPC ID to provision the EC2 instance | `string` | n/a | yes |

## Outputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ apm-server:
enabled: true
pprof:
enabled: true

sampling:
tail:
enabled: ${apm_server_tail_sampling}
storage_limit: ${apm_server_tail_sampling_storage_limit}
policies:
- sampling_rate: 0.1
output:
elasticsearch:
hosts: [ ${elasticsearch_url} ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ inputs:
rum:
enabled: true
host: '0.0.0.0:${apm_port}'
sampling:
tail:
enabled: ${apm_server_tail_sampling}
storage_limit: ${apm_server_tail_sampling_storage_limit}
policies:
- sampling_rate: 0.1
logging.level: debug
logging.to_files: true
logging.files:
Expand Down
19 changes: 13 additions & 6 deletions testing/infra/terraform/modules/standalone_apm_server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ resource "aws_instance" "apm" {
key_name = aws_key_pair.provisioner_key.key_name
monitoring = false

root_block_device {
volume_type = var.apm_volume_type
volume_size = var.apm_volume_size
}

connection {
type = "ssh"
user = local.image_ssh_users[var.aws_os]
Expand All @@ -185,12 +190,14 @@ resource "aws_instance" "apm" {
provisioner "file" {
destination = local.conf_path
content = templatefile(var.ea_managed ? "${path.module}/elastic-agent.yml.tftpl" : "${path.module}/apm-server.yml.tftpl", {
elasticsearch_url = "${var.elasticsearch_url}",
elasticsearch_username = "${var.elasticsearch_username}",
elasticsearch_password = "${var.elasticsearch_password}",
apm_version = "${var.stack_version}"
apm_secret_token = "${random_password.apm_secret_token.result}"
apm_port = "${local.apm_port}"
elasticsearch_url = "${var.elasticsearch_url}",
elasticsearch_username = "${var.elasticsearch_username}",
elasticsearch_password = "${var.elasticsearch_password}",
apm_version = "${var.stack_version}"
apm_secret_token = "${random_password.apm_secret_token.result}"
apm_port = "${local.apm_port}"
apm_server_tail_sampling = "${var.apm_server_tail_sampling}"
apm_server_tail_sampling_storage_limit = "${var.apm_server_tail_sampling_storage_limit}"
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@ variable "aws_os" {
variable "apm_instance_type" {
default = ""
type = string
description = "Optional apm server instance type overide"
description = "Optional apm server instance type override"
}

variable "apm_volume_type" {
default = null
type = string
description = "Optional apm server volume type override"
}

variable "apm_volume_size" {
default = null
type = number
description = "Optional apm server volume size in GB override"
}

variable "vpc_id" {
Expand Down Expand Up @@ -54,3 +66,15 @@ variable "apm_server_bin_path" {
type = string
description = "Optionally use the apm-server binary from the specified path instead"
}

variable "apm_server_tail_sampling" {
default = false
description = "Whether or not to enable APM Server tail-based sampling. Defaults to false"
type = bool
}

variable "apm_server_tail_sampling_storage_limit" {
default = "10GB"
description = "Storage size limit of APM Server tail-based sampling. Defaults to 10GB"
type = string
}

0 comments on commit f6af1e9

Please sign in to comment.