Hi,
I need to create a new index from a previous index that exists but only with aggregations and some metrics. For example: I have a field called "status_contrato" which is a string, and need to bring the percentile of "status_contrato: APROVADO" and the percentile of "status_contrato: PENDENTE".
I know I can make this kind of metric on Kibana, but I need an index only with these parameters, without input all the data from the previous index.
My script until now:
input{
elasticsearch{
hosts => "localhost"
index => "teste"
}
}
filter {
mutate{
remove_field => ["@timestamp","@version","host","path", "column14", "column15", "column16","id_contrato","id_tarefa","message","status_tarefa","data_confirmacao","diretoria","nome_gestor","nome_parte_passiva","prazo_tarefa","tarefa_pendente","area_ou_user_resp"]
}
date{
match => [ "data_registro", "dd/MM/yyyy" ]
target => "data_registro"
timezone => "America/Sao_Paulo"
}
if [status_contrato] != ""{
//Make here the calculations
}
mutate{
remove_field =>["status_contrato", "data_registro"]
}
}
output{
elasticsearch{
hosts => "localhost:9200"
index => "calculos"
manage_template => false
}
stdout{}
}
I've tried using the aggregation filter, metric filter, ruby filter, but nothing seems to work.
Can someone help me out?
The mapping of the index I'm using to import is this one:
{
"mapping": {
"properties": {
"@timestamp": {
"type": "date"
},
"@version": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"area_ou_user_resp": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"column14": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"column15": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"column16": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"data_confirmacao": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"data_registro": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"diretoria": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"host": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"id_contrato": {
"type": "long"
},
"id_tarefa": {
"type": "long"
},
"message": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"nome_gestor": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"nome_parte_passiva": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"path": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"prazo_tarefa": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"status_contrato": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"tarefa_pendente": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}