For determining the instance id the cwlogs library is using the EC2 Meta http://169.254.169.254/latest/meta-data/instance-id. If it fails to determine the instance id it automatically falls back to the hostname
code snippet from cwlogs/push.py:
556 if not instance_id:
557 instance_id = (socket.gethostname() or
558 socket.gethostbyname(socket.gethostname()))
559 logger.warning('Unable to get instance id, use %s instead.',
560 instance_id)
We should update our code to also check if the logstrem exists for the hostname if the logstream can't be found with the instance id.
The awslogs service is using the python library cwlogs(https://pypi.org/project/awscli-cwlogs) in order to push the awslogs to AWS.
For determining the instance id the
cwlogs
library is using the EC2 Metahttp://169.254.169.254/latest/meta-data/instance-id
. If it fails to determine the instance id it automatically falls back to the hostnamecode snippet from
cwlogs/push.py
:We should update our code to also check if the logstrem exists for the hostname if the logstream can't be found with the instance id.
https://github.com/shinesolutions/ruby_aem_aws/blob/master/lib/ruby_aem_aws/mixins/metric_verifier.rb#L79-L81