I'm doing a few tests and so far I did:
Created a component template with the metricbeat default mappings and settings (those ones from metricbeat setup command - version 8.13.4).
Adjusted the metricbeat component template changing the 'agent.hostname' from 'alias' to 'keyword'.
Created an index template with the 'metrics@settings', 'metrics-metricbeat@package' and 'ecs@mappings' included and the index pattern defined to 'metric-metricbeat.*-*'.
Created the Logstash pipeline.
Pipeline:
input {
beats {
port => 5045
ssl_enabled => "false"
}
}
filter {
// beat 5.0.0 compatibility
if [beat] {
mutate {
rename => { "beat" => "agent"}
rename => { "source" => "log.file.path"}
rename => { "[metricset][module]" => "[event][module]"}
}
}
if ![host][name] {
mutate {
add_field => { "[host][name]" => "%{[agent][name]}"}
}
}
if ![@metadata][pipeline] {
mutate {
add_field => { "[@metadata][pipeline]" => "%{[@metadata][beat]}-pipeline"}
}
}
}
output {
#stdout { codec => json }
if "metricbeat" in [@metadata][beat] {
elasticsearch {
hosts => ["https://localhost:9200"]
data_stream => "true"
data_stream_type => "metrics"
data_stream_dataset => "metricbeat.generic"
data_stream_namespace => "default"
pipeline => "%{[@metadata][pipeline]}"
user => ""
password => ""
}
}
}
Created the Elasticsearch Ingest Pipeline (metricbeat-pipeline)
PUT _ingest/pipeline/metricbeat-pipeline
{
"processors": [
{
"script": {
"source": "\r\nctx['event']['dataset'] = \"metricbeat.\"+ctx?.event?.dataset;\r\n \r\n",
"if": "ctx?.event?.dataset != null"
}
},
{
"script": {
"source": "\r\nctx['event']['dataset'] = \"metricbeat.\"+ctx?.event?.module+\".\"+ctx?.metricset?.name;",
"if": "ctx?.event?.dataset == null"
}
},
{
"reroute": {
"dataset": [
"{{event.dataset}}"
]
}
}
]
}
Tested with metricbeat 8.13.4, 7.17.21, 6.8.23, 5.6.16 and 5.0.0 versions.
I had to add some compatibility with the 5.0.0 on Logstash and Elasticsearch Ingest pipelines because it not uses the ECS schema (of course!).
I see a few differences when some versions does not have all the system metrics needed for some standard dashboards (like Infrastructure).
Versions 7.x.x and 8.x.x seems to be working fine.
I will do another test setting up an elastic agent with the System integration to see if some field conflict will appear and possibly change/fix it on the metricbeat side (logstash or elasticsearch pipeline).
Thanks,
Matheus