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

feat: add DataDog notification provider #592

Merged
merged 1 commit into from
Aug 15, 2023

Conversation

mrparkers
Copy link
Contributor

This PR adds support for DataDog as a notification provider.

This provider publishes events that look like this:
image

...given a provider config that looks like this:

apiVersion: notification.toolkit.fluxcd.io/v1beta2
kind: Provider
metadata:
  name: datadog
  namespace: flux-system
spec:
  secretRef:
    name: datadog-secret
  type: datadog
  address: https://api.datadoghq.com
  channel: my-k8s-cluster-name

...and a secret that looks like this:

apiVersion: v1
kind: Secret
metadata:
  name: datadog-secret
  namespace: flux-system
stringData:
  token: "datadog-api-key"
  headers: |
    my-custom-tag: tag-value

...and an alert that looks like this:

apiVersion: notification.toolkit.fluxcd.io/v1beta1
kind: Alert
metadata:
  name: datadog-info
  namespace: flux-system
spec:
  eventSeverity: info
  eventSources:
    - kind: Kustomization
      name: "*"
    - kind: HelmRelease
      name: "*"
    - kind: GitRepository
      name: "*"
  providerRef:
    name: datadog

I made a few assumptions along the way based on the way other events / tags look within the DataDog ecosystem. I tried to leave comments in the code that explains the rationale behind each of these.

@mrparkers mrparkers force-pushed the datadog-notification-provider branch from b982abb to 21efe48 Compare August 2, 2023 22:21
@stefanprodan
Copy link
Member

Please use eventMetadata to set the custom tags instead of things in the secret along with the standard ones like revision and summary. The cluster name, as specified in docs should come from eventMetadata, the env can be set from the channel.

@mrparkers mrparkers force-pushed the datadog-notification-provider branch from c7a70ae to 0cef615 Compare August 3, 2023 16:06
@mrparkers
Copy link
Contributor Author

Thanks for the review @stefanprodan. I made the changes that you requested. I'm setting kube_cluster_name via the event summary if it exists, falling back to channel if it doesn't exist.

@mrparkers
Copy link
Contributor Author

Okay, I think that make sense. I've removed the code that derives kube_cluster_name from the summary field of the event metadata.

@mrparkers mrparkers force-pushed the datadog-notification-provider branch from 55f9bd8 to b2e0e9c Compare August 7, 2023 18:54
@cep21
Copy link

cep21 commented Aug 8, 2023

Thanks for this change! We use datadog and this will be very helpful.

@mrparkers mrparkers force-pushed the datadog-notification-provider branch from 2d46239 to fddf96b Compare August 8, 2023 18:31
@stefanprodan stefanprodan added enhancement New feature or request area/alerting Alerting related issues and PRs labels Aug 9, 2023
@stefanprodan
Copy link
Member

@mrparkers can you please squash the commits and rebase with upstream main.

@mrparkers mrparkers force-pushed the datadog-notification-provider branch from fddf96b to f1d8d74 Compare August 9, 2023 18:27
@mrparkers
Copy link
Contributor Author

Done! Thanks again for the review!

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 @mrparkers 🏅

PS. We'll need another rebase with upstream main to merge it.

@mrparkers mrparkers force-pushed the datadog-notification-provider branch 2 times, most recently from 2f69169 to af15854 Compare August 14, 2023 14:45
@mrparkers
Copy link
Contributor Author

Hi @stefanprodan, I just rebased with main again. Let me know if there's anything else you need from me 😄

@stefanprodan
Copy link
Member

@mrparkers can you please run make tidy and force push the changes?

@mrparkers mrparkers force-pushed the datadog-notification-provider branch from af15854 to b075a5f Compare August 14, 2023 15:29
@mrparkers
Copy link
Contributor Author

@stefanprodan Done!

@mrparkers mrparkers force-pushed the datadog-notification-provider branch from b075a5f to 5116ae5 Compare August 14, 2023 19:31
@stefanprodan stefanprodan force-pushed the datadog-notification-provider branch from 5116ae5 to 2b4a99e Compare August 15, 2023 08:28
Signed-off-by: Michael Parker <michael@parker.gg>
@stefanprodan stefanprodan force-pushed the datadog-notification-provider branch from 2b4a99e to 71ed90e Compare August 15, 2023 08:37
@stefanprodan stefanprodan merged commit e760ef2 into fluxcd:main Aug 15, 2023
@mrparkers mrparkers deleted the datadog-notification-provider branch April 18, 2024 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/alerting Alerting related issues and PRs enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants