- datadog-service
This implements the datadog-service
that integrates the Datadog observability platform with Keptn. This enables you to use Datadog as the source for the Service Level Indicators (SLIs) that are used for Keptn Quality Gates.
If you want to learn more about Keptn visit us on keptn.sh
Check the issue on the main repo for more info: https://github.com/keptn/keptn/issues/2652
If you are on Mac or Linux, you can use examples/kup.sh to set up a local Keptn installation that uses Datadog. This script creates a local minikube cluster, installs Keptn, Istio, Datadog and the Datadog integration for Keptn (check the script for pre-requisites).
To use the script,
export DD_API_KEY="<your-datadog-api-key>" DD_APP_KEY="<your-datadog-app-key>" DD_SITE="datadoghq.com"
examples/kup.sh
Check the official docs for how to create the Datadog API key and Application key
Note: Application keys get the same permissions as you. You might want to narrow down the permissions (datadog-service only reads metrics from the API. Check the official docs linked above for more information).
- Install datadog
Add datadog helm repo:
helm repo add datadog https://helm.datadoghq.com
Install datadog helm chart:
export DD_API_KEY="<your-datadog-api-key>" DD_APP_KEY="<your-datadog-app-key>" DD_SITE="datadoghq.com"
helm install datadog --set datadog.apiKey=${DD_API_KEY} datadog/datadog --set datadog.appKey=${DD_APP_KEY} --set datadog.site=${DD_SITE} --set clusterAgent.enabled=true --set clusterAgent.metricsProvider.enabled=true --set clusterAgent.createPodDisruptionBudget=true --set clusterAgent.replicas=2
- Install Keptn datadog-service to integrate Datadog with Keptn
export DD_API_KEY="<your-datadog-api-key>" DD_APP_KEY="<your-datadog-app-key>" DD_SITE="datadoghq.com"
# cd datadog-service
helm install datadog-service ./helm --set datadogservice.ddApikey=${DD_API_KEY} --set datadogservice.ddAppKey=${DD_APP_KEY} --set datadogservice.ddSite=${DD_SITE}
- Add SLI and SLO
keptn add-resource --project="<your-project>" --stage="<stage-name>" --service="<service-name>" --resource=/path-to/your/sli-file.yaml --resourceUri=datadog/sli.yaml
keptn add-resource --project="<your-project>" --stage="<stage-name>" --service="<service-name>" --resource=/path-to/your/slo-file.yaml --resourceUri=slo.yaml
Example:
keptn add-resource --project="podtatohead" --stage="hardening" --service="helloservice" --resource=./quickstart/sli.yaml --resourceUri=datadog/sli.yaml
keptn add-resource --project="podtatohead" --stage="hardening" --service="helloservice" --resource=./quickstart/slo.yaml --resourceUri=slo.yaml
Check ./quickstart/sli.yaml and ./quickstart/slo.yaml for example SLI and SLO.
- Configure Keptn to use datadog SLI provider Use keptn CLI version 0.15.0 or later.
keptn configure monitoring datadog --project <project-name> --service <service-name>
- Trigger delivery
keptn trigger delivery --project=<project-name> --service=<service-name> --image=<image> --tag=<tag>
Example:
keptn trigger delivery --project=podtatohead --service=helloservice --image=docker.io/jetzlstorfer/helloserver --tag=0.1.1
Observe the results in the Keptn Bridge
Please fill in your versions accordingly
Keptn Version | datadog-service Docker Image |
---|---|
0.11.4 | ghcr.io/keptn-sandbox/datadog-service:0.1.0 |
0.11.4 | ghcr.io/keptn-sandbox/datadog-service:0.2.0 |
0.15.0 | ghcr.io/keptn-sandbox/datadog-service:0.15.0 |
0.15.1 | ghcr.io/keptn-sandbox/datadog-service:0.15.1 |
0.16.0 | ghcr.io/keptn-sandbox/datadog-service:0.16.0 |
0.17.0 | ghcr.io/keptn-sandbox/datadog-service:0.17.0 |
0.18.1 | ghcr.io/keptn-sandbox/datadog-service:0.18.1 |
0.19.0 | ghcr.io/keptn-sandbox/datadog-service:0.19.0 |
datadog-service version will match Keptn version starting from 0.15.0 version of Keptn e.g., datadog-service 0.15.x is compatible with Keptn 0.15.x
export DD_API_KEY="<your-datadog-api-key>" DD_APP_KEY="<your-datadog-app-key>" DD_SITE="datadoghq.com"
# cd datadog-service
helm install datadog-service ./helm --set datadogservice.ddApikey=${DD_API_KEY} --set datadogservice.ddAppKey=${DD_APP_KEY} --set datadogservice.ddSite=${DD_SITE}
Tell Keptn to use datadog as SLI provider for your project/service
keptn configure monitoring datadog --project <project-name> --service <service-name>
This should install the datadog-service
together with a Keptn distributor
into the keptn
namespace, which you can verify using
kubectl -n keptn get deployment datadog-service -o wide
kubectl -n keptn get pods -l run=datadog-service
Adapt and use the following command in case you want to up- or downgrade your installed version (specified by the $VERSION
placeholder):
helm upgrade datadog-service ./helm --set datadogservice.ddApikey=${DD_API_KEY} --set datadogservice.ddAppKey=${DD_APP_KEY} --set datadogservice.ddSite=${DD_SITE}
To delete a deployed datadog-service helm chart:
helm uninstall datadog-service
port-forward Keptn API so that our tests can create/delete Keptn resources
kubectl port-forward svc/api-gateway-nginx 5000:80 -nkeptn # in a separate terminal window
from datadog-service repo
export ENABLE_E2E_TEST=true
export KEPTN_ENDPOINT=http://localhost:5000/api
export KEPTN_API_TOKEN=$(kubectl get secret keptn-api-token -n keptn -ojsonpath='{.data.keptn-api-token}' | base64 -d)
gotestsum --format standard-verbose -- -timeout=120m ./test/e2e/...
Development can be conducted using any GoLang compatible IDE/editor (e.g., Jetbrains GoLand, VSCode with Go plugins).
It is recommended to make use of branches as follows:
master
contains the latest potentially unstable versionrelease-*
contains a stable version of the service (e.g.,release-0.1.0
contains version 0.1.0)- create a new branch for any changes that you are working on, e.g.,
feature/my-cool-stuff
orbug/overflow
- once ready, create a pull request from that branch back to the
master
branch
When writing code, it is recommended to follow the coding style suggested by the Golang community.
If you don't care about the details, your first entrypoint is eventhandlers.go. Within this file you can add implementation for pre-defined Keptn Cloud events.
To better understand all variants of Keptn CloudEvents, please look at the Keptn Spec.
If you want to get more insights into processing those CloudEvents or even defining your own CloudEvents in code, please
look into main.go (specifically processKeptnCloudEvent
), helm/templates,
consult the Keptn docs as well as existing Keptn Core and
Keptn Contrib services.
- Build the binary:
go build -ldflags '-linkmode=external' -v -o datadog-service
- Run tests:
go test -race -v ./...
- Build the docker image:
docker build . -t ghcr.io/keptn-sandbox/datadog-service:latest
- Run the docker image locally:
docker run --rm -it -p 8080:8080 ghcr.io/keptn-sandbox/datadog-service:latest
- Push the docker image to DockerHub:
docker push ghcr.io/keptn-sandbox/datadog-service:latest
- Watch the deployment using
kubectl
:kubectl -n keptn get deployment datadog-service -o wide
- Get logs using
kubectl
:kubectl -n keptn logs deployment/datadog-service -f
- Watch the deployed pods using
kubectl
:kubectl -n keptn get pods -l run=datadog-service
We have dummy cloud-events in the form of RFC 2616 requests in the test-events/ directory. These can be easily executed using third party plugins such as the Huachao Mao REST Client in VS Code.
This repo uses reviewdog for automated reviews of Pull Requests.
You can find the details in .github/workflows/reviewdog.yml.
This repo has automated unit tests for pull requests.
You can find the details in .github/workflows/tests.yml.
It is assumed that the current development takes place in the master branch (either via Pull Requests or directly).
To make use of the built-in automation using GH Actions for releasing a new version of this service, you should
- branch away from master to a branch called
release-x.y.z
(wherex.y.z
is your version), - check the output of GH Actions builds for the release branch,
- verify that your image was built and pushed to GHCR with the right tags,
- update the image tags in [deploy/service.yaml], and
- test your service against a working Keptn installation.
If any problems occur, fix them in the release branch and test them again.
Once you have confirmed that everything works and your version is ready to go, you should
- create a new release on the release branch using the GitHub releases page, and
- merge any changes from the release branch back to the master branch.
- If the evaluation window of the query is too short, the api might return an empty result which datadog-service treats as 0 and fails the evaluation. Issue
- There is an on-purpose 60s delay before the datadog metrics API is called. This is because, calling the metrics API earlier leads to incorrect data. Issue
- Does not support default queries for throughput, error rate, request latency etc., i.e., you have to enter the entire query. Issue
Please find more information in the LICENSE file.