I was on 8.11.n prior to the 8.12.0 upgrade that broke autodiscovery.
Filebeat is able to send non-docker container logs to Elasticsearch just fine. So the ES connection is good.
I tried debug logs and didn't spot anything helpful at the time. I'll try again.
I set the autodiscovery host host: "unix:///var/run/docker.sock"
to the default value just to see if it helped. It didn't.
I have tried the "default_config" and it didn't work.
I just tried adding the processors config, and it did not help.
Here's my config:
processors:
- add_cloud_metadata: ~
filebeat:
autodiscover:
providers:
- type: docker
hints.enabled: true
# - hints.default_config:
#paths:
#- /var/lib/docker/containers/${data.container.id}/*.json-log
#type: container
#hints.enabled: true
#host: unix:///var/run/docker.sock
#type: docker
config:
inputs:
enabled: true
path: inputs.d/*.yml
reload.enabled: true
reload.period: 30s
modules:
enabled: true
path: modules.d/*.yml
reload.enabled: true
reload.period: 30s
modules:
- audit:
enabled: false
auth:
enabled: true
var.paths:
- /host/var/log/auth*
- /host/var/log/secure*
module: system
syslog:
enabled: true
var.paths:
- /host/var/log/messages*
- /host/var/log/syslog*
output:
elasticsearch:
enabled: true
hosts:
- https://< user/pass/host >:9200
index: projectname-logs-%{[agent.version]}
ssl:
certificate_authorities:
- /usr/local/share/ca-certificates/projectname-ca.crt
enabled: true
verification_mode: certificate
setup:
dashboards:
enabled: false
ilm:
enabled: false
json:
data_stream: true
enabled: false
kibana:
enabled: false
template:
enabled: false
name: projectname-logs-%{[agent.version]}
pattern: projectname-logs-%{[agent.version]}-*
And journald spit out these logs for filebeat:
Feb 20 09:59:26 swarmnode02 filebeat[3827847]: {"log.level":"warn","@timestamp":"2024-02-20T09:59:26.998-0800","log.origin":{"function":"github.com/elastic/beats/v7/libbeat/autodiscover/template.ApplyConfigTemplate","file.name":"template/config.go","file.line":157},"message":"autodiscover: Configuration template cannot be resolved: field 'data.kubernetes.container.id' not available in event or environment accessing 'log'","service.name":"filebeat","ecs.version":"1.6.0"}
Feb 20 09:59:27 swarmnode02 filebeat[3827847]: {"log.level":"warn","@timestamp":"2024-02-20T09:59:27.012-0800","log.origin":{"function":"github.com/elastic/beats/v7/libbeat/autodiscover/template.ApplyConfigTemplate","file.name":"template/config.go","file.line":157},"message":"autodiscover: Configuration template cannot be resolved: field 'data.kubernetes.container.id' not available in event or environment accessing 'log'","service.name":"filebeat","ecs.version":"1.6.0"}
Feb 20 09:59:27 swarmnode02 filebeat[3827847]: {"log.level":"warn","@timestamp":"2024-02-20T09:59:27.012-0800","log.origin":{"function":"github.com/elastic/beats/v7/libbeat/autodiscover/template.ApplyConfigTemplate","file.name":"template/config.go","file.line":157},"message":"autodiscover: Configuration template cannot be resolved: field 'data.kubernetes.container.id' not available in event or environment accessing 'id'","service.name":"filebeat","ecs.version":"1.6.0"}
Feb 20 09:59:27 swarmnode02 filebeat[3827847]: {"log.level":"warn","@timestamp":"2024-02-20T09:59:27.013-0800","log.origin":{"function":"github.com/elastic/beats/v7/libbeat/autodiscover/template.ApplyConfigTemplate","file.name":"template/config.go","file.line":157},"message":"autodiscover: Configuration template cannot be resolved: field 'data.kubernetes.container.id' not available in event or environment accessing 'id'","service.name":"filebeat","ecs.version":"1.6.0"}
Feb 20 09:59:27 swarmnode02 filebeat[3827847]: {"log.level":"warn","@timestamp":"2024-02-20T09:59:27.013-0800","log.origin":{"function":"github.com/elastic/beats/v7/libbeat/autodiscover/template.ApplyConfigTemplate","file.name":"template/config.go","file.line":157},"message":"autodiscover: Configuration template cannot be resolved: field 'data.kubernetes.container.id' not available in event or environment accessing 'error'","service.name":"filebeat","ecs.version":"1.6.0"}
Feb 20 09:59:27 swarmnode02 filebeat[3827847]: {"log.level":"warn","@timestamp":"2024-02-20T09:59:27.014-0800","log.origin":{"function":"github.com/elastic/beats/v7/libbeat/autodiscover/template.ApplyConfigTemplate","file.name":"template/config.go","file.line":157},"message":"autodiscover: Configuration template cannot be resolved: field 'data.kubernetes.container.id' not available in event or environment accessing 'error'","service.name":"filebeat","ecs.version":"1.6.0"}
Feb 20 09:59:27 swarmnode02 filebeat[3827847]: {"log.level":"warn","@timestamp":"2024-02-20T09:59:27.015-0800","log.origin":{"function":"github.com/elastic/beats/v7/libbeat/autodiscover/template.ApplyConfigTemplate","file.name":"template/config.go","file.line":157},"message":"autodiscover: Configuration template cannot be resolved: field 'data.kubernetes.container.id' not available in event or environment accessing 'access'","service.name":"filebeat","ecs.version":"1.6.0"}
I also tried adding:
- add_docker_metadata:
host: "unix:///var/run/docker.sock"
to the processors and it did not help. Still get the missing kube field message.
I eventually tried a bunch of things and stripped the config down to:
log.level: debug
processors:
- add_docker_metadata: ~
filebeat:
autodiscover:
providers:
- type: docker
hints.enabled: true
hints.default_config:
type: container
paths:
- /var/lib/docker/containers/${data.container.id}/*json.log
output:
elasticsearch:
enabled: true
hosts:
- https://< user/pass/host >:9200
index: projectname-logs-%{[agent.version]}
ssl:
certificate_authorities:
- /usr/local/share/ca-certificates/projectname-ca.crt
enabled: true
verification_mode: certificate
setup:
dashboards:
enabled: false
ilm:
enabled: false
json:
data_stream: true
enabled: false
kibana:
enabled: false
template:
enabled: false
name: projectname-logs-%{[agent.version]}
pattern: projectname-logs-%{[agent.version]}-*
And I see logs like:
Feb 20 11:11:36 swarmnode02 filebeat[4053811]: {"log.level":"error","@timestamp":"2024-02-20T11:11:36.713-0800","log.logger":"reader_json","log.origin":{"function":"github.com/elastic/beats/v7/libbeat/reader/readjson.(*JSONReader).decode","file.name":"readjson/json.go","file.line":75},"message":"Error decoding JSON: invalid character '-' after array element","service.name":"filebeat","ecs.version":"1.6.0"}
None of the search results I found about json decoding issues helped, and I'm pretty sure it's a red herring.
So, yeah, I'm running in circles at this point.
According to the docs: Hints based autodiscover | Filebeat Reference [8.12] | Elastic I should be able to just do:
filebeat.autodiscover:
providers:
- type: docker
hints.enabled: true
hints.default_config.enabled: false
I just tried that (again, I think...) and did not get anything new.
That, plus the logs about the missing kube field make it clear that Filebeat is trying to configure the access/error logs for some of the containers I have the hint labels on. But instead of looking for docker fields, it's looking for kube fields.
It really feels like a bug to me. Especially since my original config was working prior to the upgrade.
My old config:
filebeat:
autodiscover:
providers:
- type: docker
hints.enabled: true
host: "unix:///var/run/docker.sock"
Any other ideas?