This is a simple Kubernetes Controller to allow Datadog Monitors to be created, updated or deleted from custom resources in Kubernetes.
Here's an example DatadogMonitor
resource:
apiVersion: datadoghq.com/v1beta1
kind: DatadogMonitor
metadata:
name: apm-error-rate-example
spec:
name: my-service error rate
query: 'avg(last_5m):sum:trace.servlet.request.errors{env:staging,service:my-service} / sum:trace.servlet.request.hits{env:staging,service:my-service} > 0.05'
type: query alert
message: 'Service my-service has a high error rate on env:stg'
tags:
- service:my-service
- env:staging
You will need a Datadog APP and API key which can be found or created at app.datadoghq.eu/account/settings or app.datadoghq.com/account/settings.
Use the included Helm chart in chart or install the chart from the Delivery Hero Helm charts repo:
helm repo add deliveryhero https://charts.deliveryhero.io/
helm search repo deliveryhero
helm install datadog-controller deliveryhero/datadog-controller --set datadog.client_api_key="YOUR_API_KEY" --set datadog.client_app_key="YOUR_APP_KEY"
Or a docker image is available at maxrocketinternet/datadog-controller.
There are more examples in the examples directory.
Set your kubectl
context as required and export required environment variables:
export DD_CLIENT_API_KEY="YOUR_API_KEY"
export DD_CLIENT_APP_KEY="YOUR_APP_KEY"
Then run main.go
:
go run main.go
To run tests you need to install kubebuilder which includes the required kube-apiserver
and etcd
to test the controller:
go test ./...
The contents of this repository are licensed under the Apache License version 2.0.
This project was created using kubebuilder.
This repository and its authors are in no way associated with the company Datadog.