-
Notifications
You must be signed in to change notification settings - Fork 203
Description
As discussed at #613 (comment), kubernetes provider can be enhanced in order to support hint's based autodiscovery.
This can be achieved using the already supported dynamic variable resolution mechanism by constructing and emitting hint's specific mappings similar to elastic-agent/internal/pkg/composable/providers/kubernetes/pod.go.
Find below a full example of how we can reach from k8s annotations to an Agent input.
Hint's as annotations
annotations:
co.elastic.hints/package: redis
co.elastic.hints/data_streams: info, key
co.elastic.hints/host: '${kubernetes.pod.ip}:6379'
co.elastic.hints/info.period: 1m
co.elastic.hints/key.period: 10mEmitted mapping by k8s provider
{
"kubernetes": {
"hints": {
"redis": {
"info": {
"enabled": true,
"period": "1m",
"host": "152.10.67.976:6379"
},
"key": {
"enabled": true,
"period": "10m",
"host": "152.10.67.976:6379"
}
}
}
}
}Defined template constructed by Fleet UI
providers:
kubernetes:
kube_config: /Users/chrismark/.kube/config
node: "kind-control-plane"
hints.enabled: true
inputs:
- name: templates.d/redis/0.3.6
type: redis/metrics
data_stream.namespace: default
use_output: default
streams:
- data_stream:
dataset: redis.info
type: metrics
metricsets:
- info
hosts:
- "${kubernetes.hints.redis.info.host|kubernetes.hints.redis.host|'127.0.0.1:6379'}"
idle_timeout: 20s
maxconn: 10
network: tcp
period: "${kubernetes.hints.redis.info.period|kubernetes.hints.redis.period|'10s'}"
condition: ${kubernetes.hints.redis.info.enabled} == true or ${kubernetes.hints.redis.enabled} == true //enabled even if only the integration is enabled, AKA enabled by default
- data_stream:
dataset: redis.key
type: metrics
metricsets:
- key
hosts:
- "${kubernetes.hints.redis.key.host|kubernetes.hints.redis.host|'127.0.0.1'}:${kubernetes.hints.redis.info.port|'6379'}"
idle_timeout: 20s
key.patterns:
- limit: 20
pattern: '*'
maxconn: 10
network: tcp
period: "${kubernetes.hints.redis.key.period|kubernetes.hints.redis.period|'10s'}"
condition: ${kubernetes.hints.redis.key.enabled} == true and ${kubernetes.hints.redis.enabled} == true //enabled only if explicitely enabled, AKA disabled by defaultThe above will be provided as a ConfigMap mounted into the Agent Pod:
apiVersion: v1
kind: ConfigMap
metadata:
name: elastic-agent-standalone-inputs
data:
redis.yml: |-
inputs:
- name: templates.d/redis/0.3.6
type: redis/metrics
data_stream.namespace: default
use_output: default
streams:
- data_stream:
dataset: redis.info
type: metrics
metricsets:
...The scope of this issue is summarised into 2 parts and can be implemented already regardless of Fleet's UI implementation part:
-
Update the kubernetes provider accordingly to extract hints' from annotations and produce hints-specific mappings: Add support for hints' based autodiscovery in kubernetes provider #698
-
Update the manifests for standalone Agent at https://github.com/elastic/elastic-agent/tree/main/deploy/kubernetes/elastic-agent-standalone to include an inputs.d ConfigMap similar to modules.d of Metricbeat. Provide a dummy
inputs.das an example/placeholder: Update k8s manifests to leverage hints #1202 -
Add documentation: Add hints based autodiscover part observability-docs#2182
Known issues/dependencies:
- Inputs.d usage in container environments is fuzzy #663
:character in dynamic variables breaks the rendering #624
Closes #274