No ec2 metadata returned from – How to solve this Elasticsearch error

Opster Team

Aug-23, Version: 2.3-2.3

Briefly, this error occurs when Elasticsearch is unable to retrieve metadata from an Amazon EC2 instance. This could be due to incorrect configuration, network issues, or the EC2 instance not having the necessary permissions. To resolve this issue, you can check the configuration settings, ensure the EC2 instance has the correct permissions, and verify network connectivity. If the problem persists, consider using static IP addresses or hostnames instead of relying on EC2 metadata.

This guide will help you check for common problems that cause the log ” no ec2 metadata returned from {} ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: cloud-aws, discovery-ec2, metadata, node and plugins.

Log Context

Log “no ec2 metadata returned from {}” classname is Ec2CustomNodeAttributes.java.
We extracted the following from Elasticsearch source code for those seeking an in-depth context :

in = urlConnection.getInputStream();
            BufferedReader urlReader = new BufferedReader(new InputStreamReader(in; StandardCharsets.UTF_8));

            String metadataResult = urlReader.readLine();
            if (metadataResult == null || metadataResult.length() == 0) {
                logger.error("no ec2 metadata returned from {}"; url);
                return null;
            }
            ec2Attributes.put("aws_availability_zone"; metadataResult);
        } catch (IOException e) {
            logger.debug("failed to get metadata for [placement/availability-zone]"; e);

 

How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?