-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstart-telegraf
More file actions
executable file
·19 lines (18 loc) · 1.07 KB
/
Copy pathstart-telegraf
File metadata and controls
executable file
·19 lines (18 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
export PROMETHEUS_BEARER_TOKEN=/var/run/secrets/kubernetes.io/serviceaccount/token
export TOKEN=$(cat $PROMETHEUS_BEARER_TOKEN)
export POD_API_URL=https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT/api/v1/namespaces/$POD_NAMESPACE/pods/$HOSTNAME
export NODE_NAME=$(curl -s $POD_API_URL --header "Authorization: Bearer $TOKEN" --insecure | grep nodeName | cut -c 18- | tr -d '"')
export AGENT_HOSTNAME=$NODE_NAME
echo "Setting Agent Hostname to: $AGENT_HOSTNAME"
export PROMETHEUS_URLS="\"https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT/api/v1/proxy/nodes/$NODE_NAME/metrics\", \"https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT/metrics\""
echo "Setting PROMETHEUS_URLS to: $PROMETHEUS_URLS"
echo "Building config.toml!"
./envtpl -in config.toml.tpl >> config.toml
echo "Finished building toml..."
echo "###########################################"
echo "###########################################"
cat config.toml
echo "###########################################"
echo "###########################################"
exec /telegraf -quiet -config config.toml