Skip to content

Instantly share code, notes, and snippets.

@gswallow
Last active August 27, 2020 23:44
Show Gist options
  • Save gswallow/21df956df698e2bc9dc57ad78e75397f to your computer and use it in GitHub Desktop.
Save gswallow/21df956df698e2bc9dc57ad78e75397f to your computer and use it in GitHub Desktop.
Save money on datadog.
#!/bin/bash
set -e
cat > patch.yaml <<-EOF
spec:
template:
metadata:
annotations:
ad.datadoghq.com/$1.logs: |-
[{
"source": "$1",
"service": "$1",
"log_processing_rules": [{
"type": "exclude_at_match",
"name": "discard_pings",
"pattern": "GET\\\\s/(ping|healthz)"
},
{
"type": "multi_line",
"name": "log_start_with_date",
"pattern" : "\\\\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])"
}]
}]
spec:
containers:
- name: $1
env:
- name: DD_AGENT_HOST
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: DD_ENV
value: ci
- name: DD_TAGS
value: "app:$1,account_id:799999999999,account_name:non-prod"
- name: DD_TRACE_ANALYTICS_ENABLED
value: "true"
- name: DD_PROFILING_ENABLED
value: "true"
EOF
kubectl get deployment $1 && kubectl patch deployment $1 --patch "$(cat patch.yaml)"
kubectl get deployment $1-deployment && kubectl patch deployment $1-deployment --patch "$(cat patch.yaml)"
@gswallow
Copy link
Author

Client doesn't use helm yet so I have to come up with these goofy tricks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment