title: Add instanceid dimension to cloudwatch metric-filter
body: <p>I set up a very basic metric filter for a log-stream to count the number of lines matching a certain condition. My usecase is very similiar to the one described at <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Counting404Responses.html" rel="nofollow noreferrer">the tutorial for counting apache HTTP status codes</a>.</p>
  
  <p>E.g. the log-events look like </p>
  
  <pre><code>127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 404 2326
  </code></pre>
  
  <p>and the filter is very similiar to </p>
  
  <pre><code>[IP, UserInfo, User, Timestamp, RequestInfo, StatusCode=404, Bytes]
  </code></pre>
  
  <p>I set up the metric-filter via the Cloudwatch console. The filter works perfectly except that it accumulates the values for all instanceids. However the metric is only valuable to me if it it takes the instanceid into account. </p>
  
  <p><strong>Is there a way to get the metric per instanceid, e.g. to write the instanceid as <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Dimension" rel="nofollow noreferrer">dimension</a> to the metric?</strong></p>
  
  <p>I searched for a while but could not find anything appropriate. It is very important to me, that i don't have to hardcode the instanceid since instances might get terminated at any point and new instances will be created. Further on I want to avoid <a href="https://aws.amazon.com/de/premiumsupport/knowledge-center/cloudwatch-custom-metrics/" rel="nofollow noreferrer">evaluating the metric on the EC2-machine</a>.</p>
  
  <p>Is there any way to achieve my goal? I would really appreciate any suggestions!</p>