-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstart-telegraf
More file actions
executable file
·29 lines (25 loc) · 1.44 KB
/
Copy pathstart-telegraf
File metadata and controls
executable file
·29 lines (25 loc) · 1.44 KB
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
#!/bin/sh
set -e
if [ -n "$DEIS_NSQD_SERVICE_HOST" ]; then
echo "Creating topic with URL: http://$DEIS_NSQD_SERVICE_HOST:$DEIS_NSQD_SERVICE_PORT/topic/create?topic=$NSQ_CONSUMER_TOPIC"
curl -s -X POST http://$DEIS_NSQD_SERVICE_HOST:$DEIS_NSQD_SERVICE_PORT/topic/create?topic=$NSQ_CONSUMER_TOPIC
fi
export PROMETHEUS_BEARER_TOKEN=/var/run/secrets/kubernetes.io/serviceaccount/token
if [ -f $PROMETHEUS_BEARER_TOKEN ]; then
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"
fi
echo "Building config.toml!"
envtpl -in config.toml.tpl | sed '/^$/d' > config.toml
echo "Finished building toml..."
echo "###########################################"
echo "###########################################"
cat config.toml
echo "###########################################"
echo "###########################################"
telegraf -config config.toml -quiet