-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstart-telegraf
More file actions
executable file
·41 lines (34 loc) · 1.68 KB
/
Copy pathstart-telegraf
File metadata and controls
executable file
·41 lines (34 loc) · 1.68 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
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
set -e
API_URL=${API_URL:-"https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT"}
NSQ_TOPIC_URL=${NSQ_TOPIC_URL:-"http://$DEIS_NSQD_SERVICE_HOST:$DEIS_NSQD_SERVICE_PORT/topic/create?topic=$NSQ_CONSUMER_TOPIC"}
export BEARER_TOKEN_PATH=/var/run/secrets/kubernetes.io/serviceaccount/token
export TOKEN=$(cat $BEARER_TOKEN_PATH)
export NODE_NAME=$(curl -s $API_URL/api/v1/namespaces/$POD_NAMESPACE/pods/$HOSTNAME --header "Authorization: Bearer $TOKEN" --insecure | jq -r '.spec.nodeName')
echo "Node Name set (${NODE_NAME})"
export NODE_IP=$(curl -s $API_URL/api/v1/namespaces/$POD_NAMESPACE/pods/$HOSTNAME --header "Authorization: Bearer $TOKEN" --insecure | jq -r '.status.hostIP')
echo "Node IP set (${NODE_IP})"
export AGENT_HOSTNAME=$NODE_NAME
if [ -n "$DEIS_NSQD_SERVICE_HOST" ]; then
echo "Creating topic with URL: ${NSQ_TOPIC_URL}"
curl -s -X POST ${NSQ_TOPIC_URL}
fi
if [ -n "$ENABLE_KUBERNETES" ]; then
export KUBERNETES_BEARER_TOKEN_PATH=${BEARER_TOKEN_PATH}
export KUBERNETES_URL="http://${NODE_IP}:10255"
echo "Setting KUBERNETES_URL: $KUBERNETES_URL"
fi
if [ -n "$ENABLE_PROMETHEUS" ]; then
export PROMETHEUS_BEARER_TOKEN_PATH=${BEARER_TOKEN_PATH}
export PROMETHEUS_URLS="\"$API_URL/api/v1/proxy/nodes/$NODE_NAME/metrics\", \"$API_URL/metrics\""
echo "Setting PROMETHEUS_URLS: $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