-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdd_install.sh
126 lines (107 loc) · 3.42 KB
/
dd_install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
# Prompt for the Datadog API key
read -p "Enter your Datadog API key: " DD_API_KEY
# Validate the API key is not empty
if [[ -z "$DD_API_KEY" ]]; then
echo "Error: Please enter a valid Datadog API key."
exit 1
fi
export DD_API_KEY=$DD_API_KEY
# Prompt for the Datadog Site
# Define available options and their corresponding DD_SITE values
echo "What cloud provider do you use?"
options=(
"AWS"
"Azure"
"GCP"
"EU"
"Asia Pacific"
)
PS3="Select your Datadog site (enter the corresponding number): "
select opt in "${options[@]}"; do
case $opt in
"AWS")
DD_SITE="datadoghq.com"
echo "You chose the Datadog AWS site: $DD_SITE"
break
;;
"Azure")
DD_SITE="us3.datadoghq.com"
echo "You chose the Datadog Azure site: $DD_SITE"
break
;;
"GCP")
DD_SITE="us5.datadoghq.com"
echo "You chose the Datadog GCP site: $DD_SITE"
break
;;
"EU")
DD_SITE="datadoghq.eu"
echo "You chose EU site: $DD_SITE"
break
;;
"Asia Pacific")
DD_SITE="ap1.datadoghq.com"
echo "You chose AP1 site: $DD_SITE"
break
;;
*)
echo "Invalid option. Please choose a number between 1 and ${#options[@]}."
;;
esac
done
# Validate if a site was chosen
if [[ -z "$DD_SITE" ]]; then
echo "No site selected. Exiting..."
exit 1
fi
export DD_SITE="$DD_SITE"
# Enable APM Auto Instrumentation - https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/
export DD_APM_INSTRUMENTATION_ENABLED=host
# Start the script
echo "Datadog agent installation script execution initiated."
# Execute the installation command
bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script_agent7.sh)"
# Enable Remote Configuration - https://docs.datadoghq.com/agent/remote_config/?tab=configurationyamlfile#enabling-remote-configuration
sudo tee -a /etc/datadog-agent/datadog.yaml <<EOF
remote_configuration:
enabled: true
EOF
# Enable Live Processes - https://docs.datadoghq.com/infrastructure/process/?tab=linuxwindows#installation
sudo tee -a /etc/datadog-agent/datadog.yaml <<EOF
process_config:
process_collection:
enabled: true
EOF
# Enable Logs - https://docs.datadoghq.com/agent/logs/?tab=tailfiles
sudo tee -a /etc/datadog-agent/datadog.yaml <<EOF
logs_enabled: true
EOF
# Enable I/O Stats - https://docs.datadoghq.com/infrastructure/process/?tab=linuxwindows#io-stats
sudo -u dd-agent install -m 0640 /etc/datadog-agent/system-probe.yaml.example /etc/datadog-agent/system-probe.yaml
sudo tee -a /etc/datadog-agent/system-probe.yaml <<EOF
system_probe_config:
process_config:
enabled: true
EOF
# Enable NPM - https://docs.datadoghq.com/network_monitoring/performance/setup/
sudo tee -a /etc/datadog-agent/system-probe.yaml <<EOF
network_config:
enabled: true
EOF
# Enable USM - https://docs.datadoghq.com/universal_service_monitoring/setup/?tab=configurationfileslinux#non-containerized-services-on-linux
sudo tee -a /etc/datadog-agent/system-probe.yaml <<EOF
service_monitoring_config:
enabled: true
process_service_inference:
enabled: true
EOF
# Restart the agent to apply changes
echo "Reticulating Splines..."
sudo systemctl stop datadog-agent
sleep 2
sudo systemctl start datadog-agent
# Show the Status of the Agent
echo "We are pausing for a minute to allow system probes to start. We will give you the status of the Datdog Agent as soon as possible."
sleep 60
sudo datadog-agent status