title: Getting introspection metadata from inside a container
body: <p>I'm wondering how to access <a href="http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-introspection.html" rel="nofollow noreferrer">introspection metadata</a> from inside a container running in an <strong>ECS cluster</strong>.</p>
  
  <p>The documentation recommends to call:</p>
  
  <pre><code>curl http://localhost:51678/v1/metadata
  </code></pre>
  
  <p>Which works on the <strong>EC2 instance</strong> itself, but not from the container, which is not on the same network (in <em>bridge</em> network mode).</p>
  
  <p>However, the command to access <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html" rel="nofollow noreferrer">EC2 introspection metadata</a> works well because the call has to be done to an IP address, which is reachable from the container:</p>
  
  <pre><code>curl http://169.254.169.254/latest/meta-data/  
  </code></pre>
  
  <hr>
  
  <p>I guess one way to do would be to change the network mode to share the host interface, but in the current setup that's something I'd prefer to avoid.</p>
  
  <p>In context, I'm trying to move my code that sends custom <em>Cloudwatch metrics</em> out from a local script to a utility container. I would like to avoid specifying stuff such as the <em>ECS cluster name</em>, when it could be retrieved from an API call.</p>