This project implements a Metric API Server offering additional External Metrics for Kubernetes deployments monitored with Dynatrace.
A prebuilt version of this project already is available on Docker Hub.
- Edit
deploy.yaml
and navigate to line 62. Enter the URL of your Dynatrace Environment here. - Line 59 in
deploy.yaml
refers to a secret calleddynametric
. It holds theAPI TOKEN
that grants access to the metrics offered by the Metric API Server. The minimum scope of the API Token should beDataExport (Access problem and event feed, metrics, and topology)
Unless you want to choose a different name, this is how to create that secret.kubectl -n dynatrace-metrics create secret generic dynametric --from-literal="apiToken=####"
- Finally execute
kubectl apply -f deploy.yaml
. This will automatically create a namespacedynatrace-metrics
with the required pods.
This is an example for a Horizontal Pod Scaler scaling frontend-http-server
based on the metric com.dynatrace.builtin:service.responsetime
, expecting the average response time of the monitored service to not increase 1.5 seconds.
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: frontend-http-server
namespace: dt-metrics-sample
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: frontend-http-server
minReplicas: 1
maxReplicas: 20
metrics:
- type: External
external:
metric:
name: com.dynatrace.builtin:service.responsetime
selector:
matchLabels:
hpa: frontend-http-server
target:
type: AverageValue
value: 1500000000m
Any metrics available via the Dynatrace REST API (/api/v1/timeseries
) are eligible.
Additional documentatation about this example can be found here.