Hey guys!
We've been building up our Kubernetes platform using ECK and its custom Beat resources. We recently ran into an issue where we needed to apply different ILM policies to different types of data and we found data streams. We figured out a way to ship filebeat and metricbeat data into the default logs-* and metrics-* with custom namespaces that allow us to apply different lifecycle and security policies like we needed.
But after seeing some info from @ruflin here Logstash Integration with Elasticsearch Data Streams · Issue #12178 · elastic/logstash · GitHub we wanted to ask about the tradeoffs about this approach, as far as we understand some of the documentation and blog posts this should be fine as long as the data has the right format which we've done as follows:
filebeat config:
setup.template.enabled: false
setup.ilm.enabled: false
output.elasticsearch:
index: "logs-%{[data_stream.dataset]}-%{[data_stream.namespace]}"
processors:
- add_fields:
target: data_stream
fields:
type: logs
dataset: generic
namespace: default
- script:
lang: javascript
id: dataset_override
source: >
function process(event) {
var ns = event.Get("kubernetes.namespace");
if (ns != null) event.Put("data_stream.namespace", "k8s." + ns);
var ds = event.Get("event.dataset");
if (ds != null) event.Put("data_stream.dataset", ds);
else event.Put("event.dataset", "generic");
}
metricbeat config:
setup.template.enabled: false
setup.ilm.enabled: false
output.elasticsearch:
index: "metrics-%{[data_stream.dataset]}-%{[data_stream.namespace]}"
processors:
- add_fields:
target: data_stream
fields:
type: metrics
dataset: generic
namespace: default
- script:
lang: javascript
id: dataset_override
source: >
function process(event) {
var ns = event.Get("kubernetes.namespace");
if (ns != null) event.Put("data_stream.namespace", "k8s." + ns);
var mod = event.Get("event.module");
var ms = event.Get("metricset.name");
if (mod != null && ms != null) event.Put("data_stream.dataset", mod + "." + ms);
}
After this setup we can use the Kubernetes and System integration assets, like the dashboards, without any noticeable issues.