terraform {
backend "pg" {
schema_name = "shoarma-elasticsearch"
}
required_providers {
elasticstack = {
source = "elastic/elasticstack"
version = "0.6.2"
provider "elasticstack" {
elasticsearch {
endpoints = ["http://maestro.dmz:14653"]
resource "elasticstack_elasticsearch_index_lifecycle" "metrics_ilm" {
name = "metrics_ilm"
delete {
min_age = "7d"
delete {}
resource "elasticstack_elasticsearch_index_template" "metrics_template" {
name = "metrics_template"
priority = 42
index_patterns = ["fluentd.cpu-*", "fluentd.memory-*", "fluentd.diskfree-*"]
template {
settings = jsonencode({
"index.lifecycle.name" = elasticstack_elasticsearch_index_lifecycle.metrics_ilm.name
})
resource "elasticstack_elasticsearch_index_lifecycle" "logs_ilm" {
name = "logs_ilm"
min_age = "2d"
resource "elasticstack_elasticsearch_index_template" "logs_template" {
name = "logs_template"
index_patterns = ["fluentd.access.**"]
"index.lifecycle.name" = elasticstack_elasticsearch_index_lifecycle.logs_ilm.name