Skip to content

Commit

Permalink
feat(thanos): configure query splitting and cache
Browse files Browse the repository at this point in the history
  • Loading branch information
modridi committed Dec 6, 2023
1 parent a6e5dca commit e13a7ff
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 12 deletions.
6 changes: 4 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ The following resources are used by this module:
- https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource[null_resource.dependencies] (resource)
- https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource[null_resource.this] (resource)
- https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password[random_password.oauth2_cookie_secret] (resource)
- https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password[random_password.redis_password] (resource)
- https://registry.terraform.io/providers/cloudposse/utils/latest/docs/data-sources/deep_merge_yaml[utils_deep_merge_yaml.values] (data source)

=== Required Inputs
Expand Down Expand Up @@ -113,7 +114,7 @@ Description: Override of target revision of the application chart.

Type: `string`

Default: `"v2.6.0"`
Default: `"v2.7.0"`

==== [[input_cluster_issuer]] <<input_cluster_issuer,cluster_issuer>>

Expand Down Expand Up @@ -234,6 +235,7 @@ Description: ID to pass other modules in order to refer to this module as a depe
|https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource[null_resource.dependencies] |resource
|https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource[null_resource.this] |resource
|https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password[random_password.oauth2_cookie_secret] |resource
|https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password[random_password.redis_password] |resource
|https://registry.terraform.io/providers/cloudposse/utils/latest/docs/data-sources/deep_merge_yaml[utils_deep_merge_yaml.values] |data source
|===
Expand Down Expand Up @@ -281,7 +283,7 @@ Description: ID to pass other modules in order to refer to this module as a depe
|[[input_target_revision]] <<input_target_revision,target_revision>>
|Override of target revision of the application chart.
|`string`
|`"v2.6.0"`
|`"v2.7.0"`
|no
|[[input_cluster_issuer]] <<input_cluster_issuer,cluster_issuer>>
Expand Down
4 changes: 2 additions & 2 deletions aks/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ Description: Override of target revision of the application chart.

Type: `string`

Default: `"v2.6.0"`
Default: `"v2.7.0"`

==== [[input_cluster_issuer]] <<input_cluster_issuer,cluster_issuer>>

Expand Down Expand Up @@ -501,7 +501,7 @@ object({
|[[input_target_revision]] <<input_target_revision,target_revision>>
|Override of target revision of the application chart.
|`string`
|`"v2.6.0"`
|`"v2.7.0"`
|no
|[[input_cluster_issuer]] <<input_cluster_issuer,cluster_issuer>>
Expand Down
7 changes: 5 additions & 2 deletions charts/thanos/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ dependencies:
- name: thanos
repository: https://charts.bitnami.com/bitnami
version: 12.13.13
digest: sha256:95f4c32ad1ca0636ba87643dd1e2157aa8c44c7189f090aa7ec1b70aea661405
generated: "2023-11-03T07:03:17.594517861Z"
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 18.4.0
digest: sha256:17f83e8fa5ed4acc963cfb471b3f6a73e5f347903ccf1a533fb6400628222d89
generated: "2023-11-30T17:09:11.837623668+01:00"
3 changes: 3 additions & 0 deletions charts/thanos/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ dependencies:
- name: thanos
repository: https://charts.bitnami.com/bitnami
version: 12.13.13
- name: "redis"
version: "18.4.0"
repository: "https://charts.bitnami.com/bitnami"
name: thanos
version: "0"
Binary file added charts/thanos/charts/redis-18.4.0.tgz
Binary file not shown.
4 changes: 2 additions & 2 deletions eks/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ Description: Override of target revision of the application chart.

Type: `string`

Default: `"v2.6.0"`
Default: `"v2.7.0"`

==== [[input_cluster_issuer]] <<input_cluster_issuer,cluster_issuer>>

Expand Down Expand Up @@ -479,7 +479,7 @@ object({
|[[input_target_revision]] <<input_target_revision,target_revision>>
|Override of target revision of the application chart.
|`string`
|`"v2.6.0"`
|`"v2.7.0"`
|no
|[[input_cluster_issuer]] <<input_cluster_issuer,cluster_issuer>>
Expand Down
4 changes: 2 additions & 2 deletions kind/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Description: Override of target revision of the application chart.

Type: `string`

Default: `"v2.6.0"`
Default: `"v2.7.0"`

==== [[input_cluster_issuer]] <<input_cluster_issuer,cluster_issuer>>

Expand Down Expand Up @@ -415,7 +415,7 @@ object({
|[[input_target_revision]] <<input_target_revision,target_revision>>
|Override of target revision of the application chart.
|`string`
|`"v2.6.0"`
|`"v2.7.0"`
|no
|[[input_cluster_issuer]] <<input_cluster_issuer,cluster_issuer>>
Expand Down
94 changes: 94 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
# TODO rename & use static Redis svc name.

locals {
oauth2_proxy_image = "quay.io/oauth2-proxy/oauth2-proxy:v7.5.0"

# values.yaml translated into HCL structures.
# Possible values available here -> https://github.com/bitnami/charts/tree/master/bitnami/thanos/
helm_values = [{
redis = {
architecture = "standalone"
auth = {
enabled = true
password = random_password.redis_password.result
}
master = {
persistence = {
enabled = false
}
}
}
thanos = {

storegateway = {
Expand All @@ -12,9 +26,37 @@ locals {
enabled = false
}
resources = local.thanos.storegateway_resources
extraFlags = [
# Store Gateway index cache config -> https://thanos.io/tip/components/store.md/#index-cache
<<-EOT
--index-cache.config="config":
addr: "thanos-redis-master:6379"
password: ${random_password.redis_password.result}
db: 0
dial_timeout: 5s
read_timeout: 3s
write_timeout: 3s
max_get_multi_concurrency: 1000
get_multi_batch_size: 100
max_set_multi_concurrency: 1000
set_multi_batch_size: 100
tls_enabled: false
cache_size: 0
max_async_buffer_size: 1000000
max_async_concurrency: 200
expiration: 2h
"type": "REDIS"
EOT
]
}

query = {
replicaCount = 4
extraFlags = [
"--query.max-concurrent=1",
"--query.max-concurrent-select=1",
"--query.timeout=15m"
]
dnsDiscovery = {
enabled = true
sidecarsService = "kube-prometheus-stack-thanos-discovery" # Name of the service that exposes thanos-sidecar
Expand Down Expand Up @@ -137,6 +179,58 @@ locals {
}

queryFrontend = {
extraFlags = [
"--query-range.request-downsampled",
"--query-range.split-interval=6h",
"--query-range.max-query-parallelism=4",
"--labels.split-interval=6h",
"--labels.max-query-parallelism=4",
# Query Frontend response cache config -> https://thanos.io/tip/components/query-frontend.md/#caching
<<-EOT
--query-range.response-cache-config="config":
addr: "thanos-redis-master:6379"
password: ${random_password.redis_password.result}
db: 1
dial_timeout: 5s
read_timeout: 3s
write_timeout: 3s
max_get_multi_concurrency: 1000
get_multi_batch_size: 100
max_set_multi_concurrency: 1000
set_multi_batch_size: 100
tls_enabled: false
cache_size: 0
max_async_buffer_size: 1000000
max_async_concurrency: 200
expiration: 2h
"type": "REDIS"
EOT
,
<<-EOT
--labels.response-cache-config="config":
addr: "thanos-redis-master:6379"
password: ${random_password.redis_password.result}
db: 2
dial_timeout: 5s
read_timeout: 3s
write_timeout: 3s
max_get_multi_concurrency: 1000
get_multi_batch_size: 100
max_set_multi_concurrency: 1000
set_multi_batch_size: 100
tls_enabled: false
cache_size: 0
max_async_buffer_size: 1000000
max_async_concurrency: 200
expiration: 2h
"type": "REDIS"
EOT
,
<<-EOT
--query-frontend.downstream-tripper-config=
"response_header_timeout": "15m"
EOT
]
sidecars = [{
args = concat([
"--http-address=0.0.0.0:9075",
Expand Down
5 changes: 5 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ resource "null_resource" "dependencies" {
triggers = var.dependency_ids
}

resource "random_password" "redis_password" {
length = 16
special = false
}

resource "argocd_project" "this" {
count = var.argocd_project == null ? 1 : 0

Expand Down
4 changes: 2 additions & 2 deletions sks/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Description: Override of target revision of the application chart.

Type: `string`

Default: `"v2.6.0"`
Default: `"v2.7.0"`

==== [[input_cluster_issuer]] <<input_cluster_issuer,cluster_issuer>>

Expand Down Expand Up @@ -369,7 +369,7 @@ object({
|[[input_target_revision]] <<input_target_revision,target_revision>>
|Override of target revision of the application chart.
|`string`
|`"v2.6.0"`
|`"v2.7.0"`
|no
|[[input_cluster_issuer]] <<input_cluster_issuer,cluster_issuer>>
Expand Down

0 comments on commit e13a7ff

Please sign in to comment.