create ES index every day

This commit is contained in:
Pim Kunis 2023-08-09 01:07:24 +02:00
parent 06c3fc56ab
commit 8d1fdc443b
3 changed files with 48 additions and 3 deletions

View file

@ -7,7 +7,7 @@ datasources:
access: proxy access: proxy
url: http://maestro.dmz:{{ elasticsearch_port }} url: http://maestro.dmz:{{ elasticsearch_port }}
jsonData: jsonData:
index: 'fluentd.cpu' index: 'fluentd.cpu.*'
timeField: '@timestamp' timeField: '@timestamp'
- name: memory - name: memory
@ -15,5 +15,5 @@ datasources:
access: proxy access: proxy
url: http://maestro.dmz:{{ elasticsearch_port }} url: http://maestro.dmz:{{ elasticsearch_port }}
jsonData: jsonData:
index: 'fluentd.memory' index: 'fluentd.memory.*'
timeField: '@timestamp' timeField: '@timestamp'

View file

@ -11,7 +11,12 @@
host maestro.dmz host maestro.dmz
port {{ elasticsearch_port }} port {{ elasticsearch_port }}
include_timestamp true include_timestamp true
index_name fluentd.${tag} index_name fluentd.${tag}.%Y%m%d
<buffer tag, time>
timekey 1d
flush_mode interval
flush_interval 1s
</buffer>
</match> </match>
<system> <system>

View file

@ -0,0 +1,40 @@
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*"]
template {
settings = jsonencode({
"index.lifecycle.name" = elasticstack_elasticsearch_index_lifecycle.metrics_ilm.name
})
}
}