Skip to content

Commit

Permalink
feat: add mimir as long-term storage for prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
jhandguy committed Sep 25, 2023
1 parent 5c2a3e5 commit 80812eb
Show file tree
Hide file tree
Showing 52 changed files with 404 additions and 108 deletions.
8 changes: 4 additions & 4 deletions dynamo/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ replicas: 1
resources:
limits:
cpu: 100m
memory: 150Mi
memory: 300Mi
requests:
cpu: 75m
memory: 150Mi
cpu: 50m
memory: 200Mi
horizontalPodAutoscaler:
minReplicas: 1
maxReplicas: 1
Expand All @@ -15,7 +15,7 @@ horizontalPodAutoscaler:
averageUtilization: 70
memory:
type: Utilization
averageUtilization: 50
averageUtilization: 90
image:
registry: ghcr.io
repository: jhandguy/cloud-playground/dynamo
Expand Down
8 changes: 4 additions & 4 deletions gateway/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ replicas: 1
resources:
limits:
cpu: 100m
memory: 100Mi
memory: 300Mi
requests:
cpu: 75m
memory: 100Mi
cpu: 50m
memory: 200Mi
horizontalPodAutoscaler:
minReplicas: 1
maxReplicas: 1
Expand All @@ -15,7 +15,7 @@ horizontalPodAutoscaler:
averageUtilization: 70
memory:
type: Utilization
averageUtilization: 50
averageUtilization: 90
image:
registry: ghcr.io
repository: jhandguy/cloud-playground/gateway
Expand Down
8 changes: 4 additions & 4 deletions s3/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ replicas: 1
resources:
limits:
cpu: 100m
memory: 150Mi
memory: 300Mi
requests:
cpu: 75m
memory: 150Mi
cpu: 50m
memory: 200Mi
horizontalPodAutoscaler:
minReplicas: 1
maxReplicas: 1
Expand All @@ -15,7 +15,7 @@ horizontalPodAutoscaler:
averageUtilization: 70
memory:
type: Utilization
averageUtilization: 50
averageUtilization: 90
image:
registry: ghcr.io
repository: jhandguy/cloud-playground/s3
Expand Down
1 change: 1 addition & 0 deletions terraform/environments/consul/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
| <a name="module_localstack"></a> [localstack](#module\_localstack) | ../../modules/localstack | n/a |
| <a name="module_loki"></a> [loki](#module\_loki) | ../../modules/loki | n/a |
| <a name="module_metrics"></a> [metrics](#module\_metrics) | ../../modules/metrics | n/a |
| <a name="module_mimir"></a> [mimir](#module\_mimir) | ../../modules/mimir | n/a |
| <a name="module_prometheus"></a> [prometheus](#module\_prometheus) | ../../modules/prometheus | n/a |
| <a name="module_pushgateway"></a> [pushgateway](#module\_pushgateway) | ../../modules/pushgateway | n/a |
| <a name="module_s3"></a> [s3](#module\_s3) | ../../modules/s3 | n/a |
Expand Down
66 changes: 41 additions & 25 deletions terraform/environments/consul/modules.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module "kind" {
"pushgateway",
"consul",
"vault",
"mimir",
]
}

Expand All @@ -27,7 +28,7 @@ module "localstack" {
source = "../../modules/localstack"

aws_dynamo_tables = ["dynamo"]
aws_s3_buckets = ["s3"]
aws_s3_buckets = ["mimir", "s3"]
consul_enabled = true
node_ip = module.kind.node_ip
node_port = module.kind.node_ports["localstack"]
Expand All @@ -37,30 +38,31 @@ module "dynamo" {
depends_on = [module.metrics, module.vault, module.localstack]
source = "../../modules/dynamo"

consul_enabled = true
csi_enabled = true
node_ip = module.kind.node_ip
node_ports = [module.kind.node_ports["dynamo_grpc"], module.kind.node_ports["dynamo_metrics"]]
prometheus_enabled = true
vault_url = module.vault.cluster_url
max_replicas = 2
consul_enabled = true
csi_enabled = true
node_ip = module.kind.node_ip
node_ports = [module.kind.node_ports["dynamo_grpc"], module.kind.node_ports["dynamo_metrics"]]
vault_url = module.vault.cluster_url
}

module "s3" {
depends_on = [module.metrics, module.vault, module.localstack]
source = "../../modules/s3"

consul_enabled = true
csi_enabled = true
node_ip = module.kind.node_ip
node_ports = [module.kind.node_ports["s3_grpc"], module.kind.node_ports["s3_metrics"]]
prometheus_enabled = true
vault_url = module.vault.cluster_url
max_replicas = 2
consul_enabled = true
csi_enabled = true
node_ip = module.kind.node_ip
node_ports = [module.kind.node_ports["s3_grpc"], module.kind.node_ports["s3_metrics"]]
vault_url = module.vault.cluster_url
}

module "gateway" {
depends_on = [module.metrics, module.vault, module.dynamo, module.s3]
depends_on = [module.dynamo, module.s3]
source = "../../modules/gateway"

max_replicas = 2
consul_enabled = true
csi_enabled = true
ingress_gateway_port = module.consul.ingress_gateway_port
Expand All @@ -70,8 +72,7 @@ module "gateway" {
"canary" : [module.kind.node_ports["gateway_canary_http"], module.kind.node_ports["gateway_canary_metrics"]],
"stable" : [module.kind.node_ports["gateway_stable_http"], module.kind.node_ports["gateway_stable_metrics"]]
}
prometheus_enabled = true
vault_url = module.vault.cluster_url
vault_url = module.vault.cluster_url
}

module "cli" {
Expand All @@ -82,36 +83,51 @@ module "cli" {
vault_url = module.vault.cluster_url
}

module "mimir" {
depends_on = [module.localstack]
source = "../../modules/mimir"

aws_access_key_id = var.aws_access_key_id
aws_region = var.aws_region
aws_secret_access_key = var.aws_secret_access_key
aws_s3_bucket = module.localstack.aws_s3_buckets["mimir"]
aws_s3_cluster_endpoint = module.localstack.aws_s3_cluster_endpoint
node_ip = module.kind.node_ip
node_port = module.kind.node_ports["mimir"]
}

module "prometheus" {
depends_on = [module.kind]
depends_on = [module.mimir]
source = "../../modules/prometheus"

alertmanager_node_port = module.kind.node_ports["alertmanager"]
grafana_dashboards = ["dynamo", "s3", "gateway", "cli"]
grafana_datasources = ["loki", "tempo"]
grafana_datasources = ["loki", "mimir", "tempo"]
grafana_node_port = module.kind.node_ports["grafana"]
mimir_url = module.mimir.cluster_url
node_ip = module.kind.node_ip
prometheus_node_port = module.kind.node_ports["prometheus"]
}

module "pushgateway" {
depends_on = [module.consul]
depends_on = [module.consul, module.prometheus]
source = "../../modules/pushgateway"

node_ip = module.kind.node_ip
node_port = module.kind.node_ports["pushgateway"]
consul_enabled = true
node_ip = module.kind.node_ip
node_port = module.kind.node_ports["pushgateway"]
}

module "loki" {
depends_on = [module.consul]
depends_on = [module.consul, module.prometheus]
source = "../../modules/loki"

alerting_rules = ["dynamo", "s3", "gateway", "cli"]
alertmanager_url = module.prometheus.alertmanager_cluster_url
}

module "tempo" {
depends_on = [module.consul]
depends_on = [module.consul, module.prometheus]
source = "../../modules/tempo"

consul_enabled = true
Expand All @@ -128,7 +144,7 @@ module "csi" {
}

module "consul" {
depends_on = [module.prometheus]
depends_on = [module.kind]
source = "../../modules/consul"

node_ip = module.kind.node_ip
Expand All @@ -139,7 +155,7 @@ module "consul" {
}

module "vault" {
depends_on = [module.consul, module.csi]
depends_on = [module.csi]
source = "../../modules/vault"

node_ip = module.kind.node_ip
Expand Down
2 changes: 1 addition & 1 deletion terraform/environments/consul/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output "aws_s3_endpoint" {
value = module.localstack.aws_dynamo_endpoint
value = module.localstack.aws_s3_endpoint
description = "S3 endpoint"
}

Expand Down
1 change: 1 addition & 0 deletions terraform/environments/haproxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
| <a name="module_kind"></a> [kind](#module\_kind) | ../../modules/kind | n/a |
| <a name="module_loki"></a> [loki](#module\_loki) | ../../modules/loki | n/a |
| <a name="module_metrics"></a> [metrics](#module\_metrics) | ../../modules/metrics | n/a |
| <a name="module_mimir"></a> [mimir](#module\_mimir) | ../../modules/mimir | n/a |
| <a name="module_mysql"></a> [mysql](#module\_mysql) | ../../modules/mysql | n/a |
| <a name="module_postgresql"></a> [postgresql](#module\_postgresql) | ../../modules/postgresql | n/a |
| <a name="module_prometheus"></a> [prometheus](#module\_prometheus) | ../../modules/prometheus | n/a |
Expand Down
40 changes: 24 additions & 16 deletions terraform/environments/haproxy/modules.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module "kind" {
"sql_postgres_metrics",
"sql_mysql_http",
"sql_mysql_metrics",
"mimir",
"prometheus",
"alertmanager",
"grafana",
Expand Down Expand Up @@ -51,12 +52,11 @@ module "sql_postgres" {
depends_on = [module.metrics, module.loki, module.postgresql, module.redis]
source = "../../modules/sql"

feature = "postgres"
ingress_host = random_pet.sql_postgres_host.id
node_ip = module.kind.node_ip
node_ports = [module.kind.node_ports["sql_postgres_http"], module.kind.node_ports["sql_postgres_metrics"]]
prometheus_enabled = true
replicas = 2
feature = "postgres"
ingress_host = random_pet.sql_postgres_host.id
node_ip = module.kind.node_ip
node_ports = [module.kind.node_ports["sql_postgres_http"], module.kind.node_ports["sql_postgres_metrics"]]
replicas = 2
secrets = {
"database_url" = module.postgresql.cluster_url
"database_user" = module.postgresql.user_name
Expand All @@ -73,12 +73,11 @@ module "sql_mysql" {
depends_on = [module.metrics, module.loki, module.mysql, module.redis]
source = "../../modules/sql"

feature = "mysql"
ingress_host = random_pet.sql_mysql_host.id
node_ip = module.kind.node_ip
node_ports = [module.kind.node_ports["sql_mysql_http"], module.kind.node_ports["sql_mysql_metrics"]]
prometheus_enabled = true
replicas = 2
feature = "mysql"
ingress_host = random_pet.sql_mysql_host.id
node_ip = module.kind.node_ip
node_ports = [module.kind.node_ports["sql_mysql_http"], module.kind.node_ports["sql_mysql_metrics"]]
replicas = 2
secrets = {
"database_url" = module.mysql.cluster_url
"database_user" = module.mysql.user_name
Expand All @@ -92,14 +91,24 @@ module "sql_mysql" {
}
}

module "prometheus" {
module "mimir" {
depends_on = [module.kind]
source = "../../modules/mimir"

node_ip = module.kind.node_ip
node_port = module.kind.node_ports["mimir"]
localstack_enabled = false
}

module "prometheus" {
depends_on = [module.mimir]
source = "../../modules/prometheus"

alertmanager_node_port = module.kind.node_ports["alertmanager"]
grafana_dashboards = ["mysql", "postgres"]
grafana_datasources = ["loki", "tempo"]
grafana_node_port = module.kind.node_ports["grafana"]
mimir_url = module.mimir.cluster_url
node_ip = module.kind.node_ip
prometheus_node_port = module.kind.node_ports["prometheus"]
}
Expand Down Expand Up @@ -127,9 +136,8 @@ module "haproxy" {
depends_on = [module.prometheus]
source = "../../modules/haproxy"

node_ip = module.kind.node_ip
node_ports = [module.kind.node_ports["haproxy_http"], module.kind.node_ports["haproxy_https"], module.kind.node_ports["haproxy_stat"]]
prometheus_enabled = true
node_ip = module.kind.node_ip
node_ports = [module.kind.node_ports["haproxy_http"], module.kind.node_ports["haproxy_https"], module.kind.node_ports["haproxy_stat"]]
}

module "certmanager" {
Expand Down
1 change: 1 addition & 0 deletions terraform/environments/nginx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
| <a name="module_localstack"></a> [localstack](#module\_localstack) | ../../modules/localstack | n/a |
| <a name="module_loki"></a> [loki](#module\_loki) | ../../modules/loki | n/a |
| <a name="module_metrics"></a> [metrics](#module\_metrics) | ../../modules/metrics | n/a |
| <a name="module_mimir"></a> [mimir](#module\_mimir) | ../../modules/mimir | n/a |
| <a name="module_nginx"></a> [nginx](#module\_nginx) | ../../modules/nginx | n/a |
| <a name="module_prometheus"></a> [prometheus](#module\_prometheus) | ../../modules/prometheus | n/a |
| <a name="module_pushgateway"></a> [pushgateway](#module\_pushgateway) | ../../modules/pushgateway | n/a |
Expand Down
Loading

0 comments on commit 80812eb

Please sign in to comment.