Last active
August 27, 2020 23:44
-
-
Save gswallow/21df956df698e2bc9dc57ad78e75397f to your computer and use it in GitHub Desktop.
Save money on datadog.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Client doesn't use helm yet so I have to come up with these goofy tricks.