2

I have a number of EC2 instances, each running a separate instance of my application. All log files are being streamed into CloudWatch, using the hostname of each EC2 instance as the log stream name, so I have multiple log streams for each log group.

I want to create a custom metric for each of my EC2 instances using data from the CloudWatch logs. I've set up a metric filter, but this aggregates the data across all the log streams in my log group. I want to be able to see this metric for each individual EC2 instance (i.e. separate by log stream). Is this possible? Or if not, how would I achieve this? (The only method I can think of would be to use a different log group for each instance, which isn't ideal).

1

I'm having the same problem. If you are using CloudFormation to deploy your instances and/or log streams, the best way I have found to do this is by appending a reference to your instance ID at the end of your metric name.

"MetricTransformations": [
{
    "MetricValue": "1",
    "MetricNamespace": "myNamespace",
    "MetricName": { "Fn::Join": [ "", [ "myMetric - ", { "Ref" : "InstanceID" }] ] }
}

What would be nice is if you could somehow associate your logstreams as a dimension in a single metric, rather than creating one for each instance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.