It seems like if you boot up your new instance, filebeat is already running and not started. Is this intended? The shipper ip is loaded once during starting filebeat and reading the config and from then on cached as it assumes it will not change during running.
The new instance is built from an ami which had filebeat installed. When the instance first boots, it should start filebeat (and it does).
So where is the cache location of this config? I think if i delete that cache file pre the ami 'sealing', then i should be OK.
My speculation is that somehow filebeat is reading the cache instead of the new hostname.
As an added note, i do not have a 'shipper' section in my filebeat.yml file.
Which OS and Version are you using? I have to make some tests myself here. Filebeat itself does not have a cache location, but I have to check in detail where Golang reads the value from.
logging:
level: info
# enable file rotation with default configuration
to_files: true
# do not log to syslog
to_syslog: false
files:
path: /var/log/filebeat
name: filebeat.log
keepfiles: 3
filebeat:
# General filebeat configuration options
#spool_size: 1024
#idle_timeout: 5s
registry_file: /var/lib/filebeat/registry
config_dir: /etc/filebeat/conf.d
prospectors:
# Each - is a prospector. Below are the prospector specific configurations
-
paths:
- /var/log/filebeat/*.log
#encoding: plain
type: log
#ignore_older: 24h
#scan_frequency: 10s
#harvester_buffer_size: 16384
#tail_on_rotate: false
output:
logstash:
enabled: true
hosts: ["logstash:1001"]
# index configures '@metadata.beat' field to be used by Logstash for
# indexing. By Default the beat name is used (e.g. filebeat, topbeat, packetbeat)
index: mybeat
@sijis I did some tests on my side with fedora and the hostname change seems to be depend on timing and where / how do you change it. Which command do you use the change the hostname? At what stage is the hostname of the new machine set related to the start of filebeat?
For golang the file that seems to matter seems to be: /proc/sys/kernel/hostname
As you write after restarting filebeat it works as expected, I assume it has more to do with timing of setting the hostname. But be aware that I'm not a fedora expert
I would agree that those service should start much later in bootup sequence.
Is a service file available for filebeat/logstash?
There is no filebeat.service or logstash.service file. I installed these from official elastic repositories.
Can you add network.service as requirement for filebeat/logstash?
Since there's no service file, i can't do it through systemd. There is probably a way to do is via the initd method. i'd have to research it a bit as i don't know it offhand.
My first guess, is that i'd have to modify these lines:
I'm not really sure about the order of list-dependencies. Can you also try
$ systemd list-dependencies filebeat.service
I see some more services: cloud-config, cloud-final, cloud-init-local, cloud-init . I don't know amazon ami well, but what's the purpose of these services? Maybe any of these changes the hostname?
I do believe cloud-init stuff does change it. We don't set or change instances to any specific name or anything and just let ec2 dhcp basically handle it.
I'll provide the output of list-dependencies shortly.
If this helps to reproduce, i'm doing the following.
i'm using the following ami (ami-81698dea) [us-east-1] + and installing filebeat sudo dnf install filebeat from elastic repos
Reading amzon linux ami basics cloud-init will set the hostname. with systemd potentially parallelizing service startup, cloud-init must be a dependency for filebeat I would say.
Yeah, that would seem like what would need to be done.
The packaging for filebeat doesn't use a systemd script to launch though. i'll see if i can hack something with either the provided script in /init.d or a custom service file.
Cool, looking forward to hear about your experience. Unfortunately I don't know systemd or amazon ami this well. Maybe we can integrate your solution into beats-packer.
I did try to incorporate the changes to the beats-packer repo but I wasn't able to fully understand the process thus I did not create a PR. However, I do think, long term, there will have to be a feature implemented in fpm that allows systemd scripts from being used for rpm based systems. In fpm's master branch, that feature appears to be available for debian based systems.
in platforms directory building for different platforms is scripted. Every 'platform' has a build.sh which is responsible to apply the local script templates to current build parameters and run final script (run-<id>.sh).
Maybe for AMI support we will need an extra package or some checks if cloud-init is installed to build service file from template. Don't know much about fpm/rpm myself.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.