Skip to content

Commit ecc7e07

Browse files
authored
[DEV-13927] Add loki for logging (#466)
1 parent 301862c commit ecc7e07

File tree

5 files changed

+82
-9
lines changed

5 files changed

+82
-9
lines changed

application.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,7 @@ keda:
746746
enabled: true
747747
kube-prometheus-stack:
748748
${local.kube_prometheus_stack_values}
749+
${local.loki_config}
749750
metrics-server:
750751
global:
751752
imageRegistry: ${var.image_registry}/docker.io

environment.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ locals {
2424
environment_data_s3_bucket_name = var.load_environment == "" ? coalesce(module.s3-storage[0].data_s3_bucket_name, "null") : data.terraform_remote_state.environment[0].outputs.data_s3_bucket_name
2525
environment_pgbackup_s3_bucket_name = var.load_environment == "" ? coalesce(module.s3-storage[0].pgbackup_s3_bucket_name, "null") : data.terraform_remote_state.environment[0].outputs.pgbackup_s3_bucket_name
2626
environment_miniobkp_s3_bucket_name = var.load_environment == "" ? coalesce(module.s3-storage[0].miniobkp_s3_bucket_name, "null") : data.terraform_remote_state.environment[0].outputs.miniobkp_s3_bucket_name
27+
environment_loki_s3_bucket_name = var.load_environment == "" ? coalesce(module.s3-storage[0].loki_s3_bucket_name, "null") : data.terraform_remote_state.environment[0].outputs.loki_s3_bucket_name
2728
environment_efs_filesystem_id = var.load_environment == "" ? var.include_efs == true ? module.efs-storage[0].efs_filesystem_id : "null" : data.terraform_remote_state.environment[0].outputs.efs_filesystem_id
2829
environment_fsx_rwx_id = var.load_environment == "" ? var.include_fsx == true ? module.fsx-storage[0].fsx_rwx_id : "null" : data.terraform_remote_state.environment[0].outputs.fsx_rwx_id
2930
environment_fsx_rwx_arn = var.load_environment == "" ? var.include_fsx == true ? module.fsx-storage[0].fsx_rwx_arn : "null" : data.terraform_remote_state.environment[0].outputs.fsx_rwx_arn

main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ module "security-group" {
207207
module "s3-storage" {
208208
count = var.load_environment == "" ? 1 : 0
209209
source = "app.terraform.io/indico/indico-aws-buckets/mod"
210-
version = "4.4.0"
210+
version = "4.5.0"
211211
force_destroy = true # allows terraform to destroy non-empty buckets.
212212
label = var.label
213213
kms_key_arn = local.environment_kms_key_arn
@@ -224,6 +224,8 @@ module "s3-storage" {
224224
miniobkp_s3_bucket_name_override = var.miniobkp_s3_bucket_name_override
225225
include_miniobkp = var.include_miniobkp && var.insights_enabled ? true : false
226226
allowed_origins = ["https://${local.dns_name}"]
227+
loki_s3_bucket_name_override = var.loki_s3_bucket_name_override
228+
enable_loki_logging = var.enable_loki_logging
227229
}
228230

229231

@@ -315,7 +317,7 @@ module "iam" {
315317
aws_primary_dns_role_arn = var.aws_primary_dns_role_arn
316318
efs_filesystem_id = [var.include_efs == true ? local.environment_efs_filesystem_id : ""]
317319
fsx_arns = [var.include_rox ? local.environment_fsx_rox_arn : "", var.include_fsx == true ? local.environment_fsx_rwx_arn : ""]
318-
s3_buckets = compact([local.environment_data_s3_bucket_name, var.include_pgbackup ? local.environment_pgbackup_s3_bucket_name : "", var.include_rox ? local.environment_api_models_s3_bucket_name : "", lower("${var.aws_account}-aws-cod-snapshots"), var.performance_bucket ? "indico-locust-benchmark-test-results" : "", var.include_miniobkp && var.insights_enabled ? local.environment_miniobkp_s3_bucket_name : ""])
320+
s3_buckets = compact([local.environment_data_s3_bucket_name, var.include_pgbackup ? local.environment_pgbackup_s3_bucket_name : "", var.include_rox ? local.environment_api_models_s3_bucket_name : "", lower("${var.aws_account}-aws-cod-snapshots"), var.performance_bucket ? "indico-locust-benchmark-test-results" : "", var.include_miniobkp && var.insights_enabled ? local.environment_miniobkp_s3_bucket_name : "", var.enable_loki_logging ? local.environment_loki_s3_bucket_name : ""])
319321
kms_key_arn = local.environment_kms_key_arn
320322
# EKS cluster role
321323
create_cluster_iam_role = var.create_eks_cluster_role

monitoring.tf

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,30 @@ locals {
2020
EOT
2121
)
2222

23+
loki_config = var.enable_loki_logging == true ? (<<EOT
24+
fluent-bit:
25+
enabled: true
26+
loki:
27+
enabled: true
28+
loki:
29+
storage_config:
30+
aws:
31+
region: ${var.region}
32+
bucketnames: ${module.s3-storage[0].loki_s3_bucket_name}
33+
s3forcepathstyle: false
34+
storage:
35+
type: s3
36+
bucketNames:
37+
chunks: ${module.s3-storage[0].loki_s3_bucket_name}
38+
s3:
39+
region: ${var.region}
40+
41+
EOT
42+
) : (<<EOT
43+
fluent-bit:
44+
enabled: false
45+
EOT
46+
)
2347

2448
alertmanager_tls = var.acm_arn == "" ? (<<EOT
2549
tls:
@@ -135,6 +159,22 @@ ${local.prometheus_tls}
135159
- grafana-${local.monitoring_domain_name}
136160
path: /
137161
${local.grafana_tls}
162+
${var.enable_loki_logging == true ? (<<EOT
163+
additionalDataSources:
164+
- name: loki
165+
type: loki
166+
access: proxy
167+
basicAuth: true
168+
url: http://monitoring-loki-gateway.monitoring.svc.cluster.local
169+
secureJsonData:
170+
httpHeaderValue1: logs
171+
jsonData:
172+
httpHeaderName1: "X-Scope-OrgID"
173+
EOT
174+
) : (<<EOT
175+
additionalDataSources: []
176+
EOT
177+
)}
138178
sql-exporter:
139179
enabled: ${var.ipa_enabled}
140180
image:
@@ -143,7 +183,7 @@ tempo:
143183
tempo:
144184
repository: ${var.image_registry}/docker.io/grafana/tempo
145185
EOT
146-
) : (<<EOT
186+
) : (<<EOT
147187
prometheus-node-exporter:
148188
image:
149189
registry: ${var.image_registry}/quay.io
@@ -219,6 +259,23 @@ ${local.thanos_config}
219259
cert-manager.io/cluster-issuer: zerossl
220260
labels:
221261
acme.cert-manager.io/dns01-solver: "true"
262+
${var.enable_loki_logging == true ? (<<EOT
263+
additionalDataSources:
264+
- name: loki
265+
type: loki
266+
access: proxy
267+
basicAuth: true
268+
url: http://monitoring-loki-gateway.monitoring.svc.cluster.local
269+
secureJsonData:
270+
httpHeaderValue1: logs
271+
jsonData:
272+
httpHeaderName1: "X-Scope-OrgID"
273+
EOT
274+
) : (<<EOT
275+
additionalDataSources: []
276+
EOT
277+
)}
278+
222279
sql-exporter:
223280
enabled: ${var.ipa_enabled}
224281
image:
@@ -227,7 +284,7 @@ tempo:
227284
tempo:
228285
repository: ${var.image_registry}/docker.io/grafana/tempo
229286
EOT
230-
)
287+
)
231288
}
232289

233290

variables.tf

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,8 +1596,8 @@ variable "harbor_customer_robot_username" {
15961596
}
15971597

15981598
variable "harbor_customer_robot_password" {
1599-
type = string
1600-
default = ""
1599+
type = string
1600+
default = ""
16011601
}
16021602

16031603
variable "dev_computer_vision_api_key" {
@@ -1634,7 +1634,7 @@ variable "prod_computer_vision_api_url" {
16341634
type = string
16351635
default = ""
16361636
description = "readapi computer vision api url"
1637-
}
1637+
}
16381638

16391639
variable "prod_form_recognizer_api_key" {
16401640
type = string
@@ -1646,7 +1646,7 @@ variable "prod_form_recognizer_api_url" {
16461646
type = string
16471647
default = ""
16481648
description = "readapi form recognizer api url"
1649-
}
1649+
}
16501650

16511651
variable "dev_apikey" {
16521652
type = string
@@ -1672,6 +1672,18 @@ variable "prod_billing" {
16721672
description = "This is the billing url for readapi and has the same value as prod_computer_vision_api_url "
16731673
}
16741674

1675+
variable "enable_loki_logging" {
1676+
type = bool
1677+
default = false
1678+
description = "Toggle for enabling loki logging"
1679+
}
1680+
1681+
variable "loki_s3_bucket_name_override" {
1682+
type = string
1683+
default = null
1684+
description = "The name of the existing S3 bucket to be loaded and used as the loki bucket"
1685+
}
1686+
16751687
variable "use_local_helm_charts" {
16761688
type = bool
16771689
default = false
@@ -1688,4 +1700,4 @@ variable "install_local_insights_chart" {
16881700
type = bool
16891701
default = false
16901702
description = "Toggle for installing the local insights chart"
1691-
}
1703+
}

0 commit comments

Comments
 (0)