Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/metrics/providers: add AWS CloudWatch provider #464

Merged
merged 4 commits into from
Mar 3, 2020

Conversation

mathetake
Copy link
Collaborator

@mathetake mathetake commented Feb 28, 2020

resolves #465


this PR implements metrics provider interface for AWS CloudWatch

TODOs

  • e2e test against an actual AWS account
  • make change to crd

related issue

#241

note

  • users must give AWS IAM permission to flagger to perform cloudwatch:GetMetricData
  • AWS's region is specified by provider.region field

example

MetricTemplate

apiVersion: flagger.app/v1alpha1
kind: MetricTemplate
metadata:
  name: cwtest
spec:
  provider:
    type: cloudwatch
    region: ap-northeast-1
  query: |
    [
        {
            "Id": "e1",
            "Expression": "m1 / m2",
            "Label": "ErrorRate"
        },
        {
            "Id": "m1",
            "MetricStat": {
                "Metric": {
                    "Namespace": "MyApp",
                    "MetricName": "ErrorCount",
                    "Dimensions": [
                        {
                            "Name": "appName",
                            "Value": "{{ name }}.{{ namespace }}"
                        }
                    ]
                },
                "Period": 60,
                "Stat": "Sum",
                "Unit": "Count"
            },
            "ReturnData": false
        },
        {
            "Id": "m2",
            "MetricStat": {
                "Metric": {
                    "Namespace": "MyApp",
                    "MetricName": "RequestCount",
                    "Dimensions": [
                        {
                            "Name": "appName",
                            "Value": "{{ name }}.{{ namespace }}"
                        }
                    ]
                },
                "Period": 60,
                "Stat": "Sum",
                "Unit": "Count"
            },
            "ReturnData": false
        }
    ]

Canary

apiVersion: flagger.app/v1alpha3
kind: Canary
metadata:
  name: prd-istio-gateway
  namespace: default
spec:
  canaryAnalysis:
    interval: 5s
    maxWeight: 50
    metrics:
      - interval: 30s
        name: cloudwatch
        threshold: 99
        thresholdRange:
          min: 0.4
          max: 0.9
        templateRef:
          name: cwtest
    stepWeight: 10
    threshold: 3
...

@mathetake mathetake changed the title add Cloud watch metrics pkg/metrics/providers: add AWS CloudWatch provider Feb 28, 2020
@mathetake mathetake force-pushed the cloud-watch-metrics branch from e1ed5b1 to fedc2d0 Compare March 2, 2020 05:18
@mathetake mathetake marked this pull request as ready for review March 2, 2020 05:57
@mathetake mathetake requested a review from stefanprodan as a code owner March 2, 2020 05:57
pkg/metrics/providers/prometheus.go Outdated Show resolved Hide resolved
@mathetake mathetake force-pushed the cloud-watch-metrics branch from f01a1f5 to 337f627 Compare March 2, 2020 11:04
Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mathetake mathetake force-pushed the cloud-watch-metrics branch from 337f627 to 5faf63e Compare March 2, 2020 13:22
Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks @mathetake 🏅

@stefanprodan stefanprodan merged commit b47cfb6 into master Mar 3, 2020
@stefanprodan stefanprodan deleted the cloud-watch-metrics branch March 3, 2020 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS CloudWatch metrics provider
2 participants