Hello guys.
I have some apps .net running in my environment. My apps are using serilog to send logs to Elasticsearch. We aren't use any plugin or middle to do this, like logstash, filebeat, etc.
When I leave the app to create the template by yourself and then I just add the policy to the index, I have this error:
illegal_argument_exception: index name [contoso-2024.10.09] does not match pattern '^.*-\d+$'
In another scenario is, I create the template and instead of apply manually the policy to the index, I put the parameters to assign policy automatically on template:
{
"index": {
"lifecycle": {
"name": "contoso_policy",
"rollover_alias": "contoso"
},
"number_of_replicas": "1",
"refresh_interval": "5s"
}
}
Then I have the same error above.
#####################################################
This is my config in app:
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.Console()
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri("https://elastic:mypass@elastic-desenv.contoso.com.br"))
{
AutoRegisterTemplate = true,
IndexFormat = "contoso-{0:yyyy.MM.dd}",
NumberOfReplicas = 1,
IndexAliases = new string[] { "contoso" },
AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv8,
TemplateName = "contoso_template",
OverwriteTemplate = false,
})
.CreateLogger();
#####################################################
The template is generated automatically by app:
{
"template": {
"settings": {
"index": {
"number_of_replicas": "1",
"routing": {
"allocation": {
"include": {
"_tier_preference": "data_content"
}
}
},
"refresh_interval": "5s"
}
},
"mappings": {
"dynamic_templates": [
{
"numerics_in_fields": {
"path_match": "fields\\.[\\d+]$",
"match_pattern": "regex",
"mapping": {
"index": true,
"norms": false,
"type": "text"
}
}
},
{
"string_fields": {
"match": "*",
"match_mapping_type": "string",
"mapping": {
"fields": {
"raw": {
"ignore_above": 256,
"index": true,
"type": "keyword"
}
},
"index": true,
"norms": false,
"type": "text"
}
}
}
],
"properties": {
"exceptions": {
"type": "nested",
"properties": {
"Depth": {
"type": "integer"
},
"ExceptionMessage": {
"properties": {
"MemberType": {
"type": "integer"
}
}
},
"HResult": {
"type": "integer"
},
"RemoteStackIndex": {
"type": "integer"
},
"RemoteStackTraceString": {
"type": "text"
},
"StackTraceString": {
"type": "text"
}
}
},
"message": {
"type": "text"
}
}
},
"aliases": {
"contoso": {}
}
}
}
#####################################################
This is my policy:
{
"contoso_policy": {
"version": 1,
"modified_date": "2024-10-07T19:38:53.758Z",
"policy": {
"phases": {
"warm": {
"min_age": "7m",
"actions": {
"set_priority": {
"priority": 50
}
}
},
"hot": {
"min_age": "0ms",
"actions": {
"set_priority": {
"priority": 100
},
"rollover": {
"max_age": "5m"
}
}
},
"delete": {
"min_age": "10m",
"actions": {
"delete": {
"delete_searchable_snapshot": true
}
}
}
}
},
"in_use_by": {
"indices": [
"contoso-2024.10.09"
],
"data_streams": [],
"composable_templates": []
}
}
}
I guess, I'm doing something wrong.
Someone can help me?