Skip to content

Commit

Permalink
Add default and additional schema configurations for Loki chart
Browse files Browse the repository at this point in the history
  • Loading branch information
milldr committed Jun 6, 2024
1 parent cf315db commit 141db8f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 13 deletions.
3 changes: 3 additions & 0 deletions modules/eks/loki/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ components:
| <a name="module_iam_roles"></a> [iam\_roles](#module\_iam\_roles) | ../../account-map/modules/iam-roles | n/a |
| <a name="module_loki"></a> [loki](#module\_loki) | cloudposse/helm-release/aws | 0.10.1 |
| <a name="module_loki_storage"></a> [loki\_storage](#module\_loki\_storage) | cloudposse/s3-bucket/aws | 4.2.0 |
| <a name="module_loki_tls_label"></a> [loki\_tls\_label](#module\_loki\_tls\_label) | cloudposse/label/null | 0.25.0 |
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |
## Resources
Expand All @@ -72,6 +73,7 @@ components:
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_additional_schema_config"></a> [additional\_schema\_config](#input\_additional\_schema\_config) | A list of additional `configs` for the `schemaConfig` for the Loki chart. This list will be merged with the default schemaConfig.config defined by `var.default_schema_config` | <pre>list(object({<br> from = string<br> object_store = string<br> schema = string<br> index = object({<br> prefix = string<br> period = string<br> })<br> }))</pre> | `[]` | no |
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br>This is for some rare cases where resources want additional configuration of tags<br>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
| <a name="input_alb_controller_ingress_group_component_name"></a> [alb\_controller\_ingress\_group\_component\_name](#input\_alb\_controller\_ingress\_group\_component\_name) | The name of the eks/alb-controller-ingress-group component. This should be an internal facing ALB | `string` | `"eks/alb-controller-ingress-group"` | no |
| <a name="input_atomic"></a> [atomic](#input\_atomic) | If set, installation process purges chart on fail. The wait flag will be set automatically if atomic is used. | `bool` | `true` | no |
Expand All @@ -85,6 +87,7 @@ components:
| <a name="input_cleanup_on_fail"></a> [cleanup\_on\_fail](#input\_cleanup\_on\_fail) | Allow deletion of new resources created in this upgrade when upgrade fails. | `bool` | `true` | no |
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no |
| <a name="input_create_namespace"></a> [create\_namespace](#input\_create\_namespace) | Create the Kubernetes namespace if it does not yet exist | `bool` | `true` | no |
| <a name="input_default_schema_config"></a> [default\_schema\_config](#input\_default\_schema\_config) | A list of default `configs` for the `schemaConfig` for the Loki chart. For new installations, the default schema config doesn't change. See https://grafana.com/docs/loki/latest/operations/storage/schema/#new-loki-installs | <pre>list(object({<br> from = string<br> object_store = string<br> schema = string<br> index = object({<br> prefix = string<br> period = string<br> })<br> }))</pre> | <pre>[<br> {<br> "from": "2024-04-01",<br> "index": {<br> "period": "24h",<br> "prefix": "index_"<br> },<br> "object_store": "s3",<br> "schema": "v13",<br> "store": "tsdb"<br> }<br>]</pre> | no |
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
| <a name="input_eks_component_name"></a> [eks\_component\_name](#input\_eks\_component\_name) | The name of the eks component | `string` | `"eks/cluster"` | no |
Expand Down
26 changes: 13 additions & 13 deletions modules/eks/loki/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ module "loki_storage" {
context = module.this.context
}

module "loki_tls_label" {
source = "cloudposse/label/null"
version = "0.25.0"

enabled = local.enabled

attributes = ["tls"]

context = module.this.context
}

module "loki" {
source = "cloudposse/helm-release/aws"
version = "0.10.1"
Expand Down Expand Up @@ -112,18 +123,7 @@ module "loki" {
# For new installations, schema config doesnt change. See the following:
# https://grafana.com/docs/loki/latest/operations/storage/schema/#new-loki-installs
schemaConfig = {
configs = [
{
from = "2024-04-01" # for a new install, this must be a date in the past, use a recent date. Format is YYYY-MM-DD.
object_store = "s3"
store = "tsdb"
schema = "v13"
index = {
prefix = "index_"
period = "24h"
}
}
]
configs = compact(concat(var.default_schema_config, var.additional_schema_config))
}
storage = {
bucketNames = {
Expand Down Expand Up @@ -160,7 +160,7 @@ module "loki" {
]
tls = [
{
secretName = "${module.this.id}-tls"
secretName = module.loki_tls_label.id
hosts = [local.ingress_host_name]
}
]
Expand Down
39 changes: 39 additions & 0 deletions modules/eks/loki/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,42 @@ variable "chart_values" {
description = "Additional values to yamlencode as `helm_release` values."
default = {}
}

variable "default_schema_config" {
type = list(object({
from = string
object_store = string
schema = string
index = object({
prefix = string
period = string
})
}))
description = "A list of default `configs` for the `schemaConfig` for the Loki chart. For new installations, the default schema config doesn't change. See https://grafana.com/docs/loki/latest/operations/storage/schema/#new-loki-installs"
default = [
{
from = "2024-04-01" # for a new install, this must be a date in the past, use a recent date. Format is YYYY-MM-DD.
object_store = "s3"
store = "tsdb"
schema = "v13"
index = {
prefix = "index_"
period = "24h"
}
}
]
}

variable "additional_schema_config" {
type = list(object({
from = string
object_store = string
schema = string
index = object({
prefix = string
period = string
})
}))
description = "A list of additional `configs` for the `schemaConfig` for the Loki chart. This list will be merged with the default schemaConfig.config defined by `var.default_schema_config`"
default = []
}

0 comments on commit 141db8f

Please sign in to comment.