serverless-plugin-aws-alerts icon indicating copy to clipboard operation
serverless-plugin-aws-alerts copied to clipboard

Metric Filter configuration producing unexpected results

Open JBartlett86 opened this issue 7 years ago • 11 comments

This is a Bug Report

Description

I am trying to configure a metric filter alarm with a given filter pattern for the function under my service,

custom:
  alerts:
    topics:
      alarm: 
        topic: arn:aws:sns:eu-west-1:704255512929:CloudWatch-ErrorLogs
    function:
      - name: AnAlarm
        metric: AnError
        treatMissingData: notBreaching
        threshold: 0
        statistic: Sum
        period: 60
        evaluationPeriods: 1
        comparisonOperator: GreaterThanThreshold
        pattern: '[ERROR]'

I was expecting this to create a single metric filter (ERROR) linked a single alarm that is then linked to an SNS Topic (CloudWatch-ErrorLogs), however what is actually happening is 2 metric filters are being created, one with a suffix ALERT and another with a suffix OK. Both of these are then linked to the same metric and the same alert.

From reviewing the code it appears there is code specific to create 2 metric filters, one for the Alert and one for the OK and I wondered why this was the case? Would it be possible to support a way of configuring it to exclude the OK metric filters?

Additional Data

  • Serverless Framework Version: 1.26.0:

JBartlett86 avatar Feb 01 '18 17:02 JBartlett86

Yes, I also have the same concern.

Also, how can I define the metric value parameter?

hrishabhg avatar May 02 '18 02:05 hrishabhg

I'm having the same issue. I'm trying to extract some values from a log, and the "OK" metric filter is polluting my metric data ... is there any feedback on this?

It would seem like the right thing to do to NOT create the "OK" metric filter, or at a minimum have a mechanism to allow the user to optionally not create it in the cloudformation stack...

chinatti avatar May 13 '18 18:05 chinatti

I've created a fork of this project that allows you to capture custom metrics successfully, here is a link:

https://github.com/chinatti/serverless-plugin-aws-alerts#collecting-custom-metrics

chinatti avatar May 15 '18 17:05 chinatti

@chinatti Brilliant! Any chance of fixing #54 whilst your at it?

JBartlett86 avatar Jun 01 '18 06:06 JBartlett86

@chinatti great addition, would it be worth a pull request?

ctg3 avatar Oct 01 '18 21:10 ctg3

I should do that - I've just been lazy (and I've never made a pull request before so I have to figure out how to do that :-). Let me see if I can get that together in the next week or so...

chinatti avatar Oct 01 '18 21:10 chinatti

Any news?

asyba avatar Jan 29 '19 01:01 asyba

Do we know when the following will be added into the release. Currently we are creating so many OK Metrics that we wont even use for and this code helps us saving the time and resources for OK Metric filters. https://github.com/chinatti/serverless-plugin-aws-alerts#collecting-custom-metrics

anilchinnam avatar May 14 '19 21:05 anilchinnam

It still seems to be problem. Have we done the fix?

manthan1234567 avatar Nov 06 '19 08:11 manthan1234567

Any news? Still getting the same issue

skymasseronir avatar Jan 21 '22 08:01 skymasseronir

with this forked version "useExternalStack = true" sadly does not work

Tamoskiel avatar Jul 13 '22 07:07 Tamoskiel