Skip to content

philips-labs/terraform-cloudfoundry-thanos

Repository files navigation

Terraform Cloudfoundry Thanos module

Setup for Prometheus + Thanos on Cloudfoundry. This provides a path towards unlimited metrics storage. This module deploys a number of apps and services to provide Thanos

Disclaimer

Important

This repository is managed as Philips Inner-source / Open-source. This repository is NOT endorsed or supported by HSSA&P or I&S Cloud Operations. You are expected to self-support or raise tickets on the Github project and NOT raise tickets in HSP ServiceNow.

Features

  • Deploys a Thanos instance with S3 Bucket as storage
  • Deploys a Compactor instance
  • Variant sidecar for scrape target and rule discovery
  • Remote write support
  • HSP Metrics exporter (optional)
  • CF Metric exporter (optional)

Example of Thanos Terraform

module "thanos" {
    source = "philips-labs/thanos/cloudfoundry"
    version = "6.1.0"

    cf_org_name        = var.cf_org_name
    cf_space_id        = var.cf_space_id

    cf_functional_account = {
      api_endpoint = var.cf_api_url
      username     = var.cf_username
      password     = var.cf_password
    }
}

Requirements

Name Version
terraform >= 1.3.0
cloudfoundry >= 0.15.5
hsdp >= 0.38.2
random >= 2.2.1

Providers

Name Version
cloudfoundry >= 0.15.5
hsdp >= 0.38.2
random >= 2.2.1

Modules

Name Source Version
proxy ./modules/proxy n/a

Resources

Name Type
cloudfoundry_app.cfpaasexporter resource
cloudfoundry_app.hsdp_metrics_exporter resource
cloudfoundry_app.thanos resource
cloudfoundry_app.thanos_compactor resource
cloudfoundry_app.thanos_query resource
cloudfoundry_app.thanos_store resource
cloudfoundry_network_policy.thanos_query resource
cloudfoundry_network_policy.thanos_store resource
cloudfoundry_route.cfpaasexporter_internal resource
cloudfoundry_route.hsdp_metrics_exporter_internal resource
cloudfoundry_route.thanos resource
cloudfoundry_route.thanos_internal resource
cloudfoundry_route.thanos_query resource
cloudfoundry_route.thanos_query_internal resource
cloudfoundry_route.thanos_store_internal resource
cloudfoundry_service_instance.s3 resource
cloudfoundry_service_key.s3 resource
random_id.id resource
random_password.password resource
cloudfoundry_domain.app_domain data source
cloudfoundry_domain.apps_internal_domain data source
cloudfoundry_service.s3 data source
hsdp_config.cf data source

Inputs

Name Description Type Default Required
alertmanagers_endpoints List of endpoints of the alert managers list(string) [] no
cf_functional_account Configuration for the CloudFoundry function account. Required for variant and if enable_cf_exporter is set to true
object({
api_endpoint = string
username = string
password = string
})
{
"api_endpoint": "",
"password": "",
"username": ""
}
no
cf_paas_exporter_disk_quota CF PaaS Exporter disk quota number 100 no
cf_paas_exporter_image Image to use for cf paas exporter. Use a v* tagged version to prevent automatic updates string "loafoe/paas-prometheus-exporter:v0.0.5" no
cf_paas_exporter_memory CF PaaS Exporter memory number 256 no
cf_paas_exporter_timeout CF PaaS Exporter timeout number 120 no
cf_space_id Cloudfoundry SPACE id to use for deploying all Thanos components. string n/a yes
docker_password Docker registry password string "" no
docker_username Docker registry username string "" no
enable_cf_exporter Enable the CloudFoundry metrics exporter and scrape it from Thanos bool false no
enable_hsdp_metrics_exporter Enable scraping of HSDP Metrics instances bool false no
enable_prometheus_proxy Enable the Prometheus proxy, protected by Basic Auth bool false no
environment Pass environment variable to the app map(any) {} no
hsdp_metrics_exporter HSDP Metrics exporter configuration
object({
image = string
docker_username = string
docker_password = string
memory = number
disk_quota = number
timeout = number
region = string
})
{
"disk_quota": 100,
"docker_password": "",
"docker_username": "",
"image": "loafoe/prometheus-hsdp-metrics-exporter:v0.0.14",
"memory": 256,
"region": "us-east",
"timeout": 120
}
no
name_postfix The postfix string to append to the space, hostname, etc. Prevents namespace clashes string "" no
spaces The list of CF space GUIDs to scrape. When provided variant will only consider apps in these spaces list(string) [] no
tenants The list of tenants to scrape. When an app does not specify tenant then 'default' is used list(string)
[
"default"
]
no
thanos_compactor_disk_quota Thanos disk quota number 5000 no
thanos_compactor_enabled Enable or disable the Thanos compactor component bool true no
thanos_compactor_image Image to use for Thanos compactor. Use a v* tagged version to prevent automatic updates string "ghcr.io/philips-labs/terraform-cloudfoundry-thanos:v6.5.0" no
thanos_compactor_memory Thanos store memory number 1024 no
thanos_disk_quota Thanos disk quota number 5000 no
thanos_extra_config Any extra yaml config that will be merged into the prometheus config at runtime. Extra targets can be added here. string "" no
thanos_file_sd_url A URL that exposes a prometheus file_sd yaml file will be periodically downloaded and used for service discovery string "" no
thanos_image Image to use for Thanos app. Use a v* tagged version to prevent automatic updates string "ghcr.io/philips-labs/terraform-cloudfoundry-thanos:v6.5.0" no
thanos_memory Thanos memory number 1024 no
thanos_public_endpoints Make Thanos public endpoint bool false no
thanos_query_image Image to use for Thanos query. Use a v* tagged version to prevent automatic updates string "ghcr.io/philips-labs/terraform-cloudfoundry-thanos:v6.5.0" no
thanos_query_memory Thanos memory number 1024 no
thanos_query_service_bindings A list of service instances that should be bound to the thanos app list(object({ service_instance = string })) [] no
thanos_service_bindings A list of service instances that should be bound to the thanos app list(object({ service_instance = string })) [] no
thanos_storage_tsdb_retention_time Thanos storage tsdb retention time string "2h" no
thanos_store_disk_quota Thanos store disk quota number 5000 no
thanos_store_image Image to use for Thanos store. Use a v* tagged version to prevent automatic updates string "ghcr.io/philips-labs/terraform-cloudfoundry-thanos:v6.5.0" no
thanos_store_memory Thanos store memory number 1536 no
thanos_store_service_bindings A list of service instances that should be bound to the thanos_store app list(object({ service_instance = string })) [] no

Outputs

Name Description
postfix Cluster ID / Postfix of Thanos deployment
prometheus_proxy_endpoint The Promethues proxy endpoint
prometheus_proxy_password The Promethues proxy password
prometheus_proxy_username The Promethues proxy username
thanos_app_id App id for Thanos
thanos_endpoint URL of Thanos deployment
thanos_query_app_id App id for Thanos Query
thanos_query_endpoint URL of Thanos query deployment
thanos_space_id Cloud foundry space ID of Thanos
thanos_store_app_id App id for Thanos Store
thanos_store_endpoint Internal only URL of Thanos store deployment

Contact / Getting help

Please post your questions on the HSDP Slack #terraform channel, or start a discussion

License

License is MIT