Skip to content

Instantly share code, notes, and snippets.

@patrick0057
Last active June 2, 2019 14:32
Show Gist options
  • Save patrick0057/b50f577f15b4ce7289956d504fdb5161 to your computer and use it in GitHub Desktop.
Save patrick0057/b50f577f15b4ce7289956d504fdb5161 to your computer and use it in GitHub Desktop.
curl etcd metrics

Quick gist for curling etcd metrics. There are better ways to get the metrics but I'm creating this gist anyway in case I need to reference this again later.

export etcd_endpoint=$(docker exec etcd netstat -lpna | grep \:2379 | grep tcp | grep LISTEN | tr -s " " | cut -d" " -f4)

{ for var in $(docker inspect --format '{{ .Config.Env }}' etcd | sed 's/[][]//g'); do
if [[ "$var" == *"ETCDCTL_CERT"* ]] || [[ "$var" == *"ETCDCTL_KEY"* ]]; then
export ${var}
fi
done }

{ if [[ $etcd_endpoint =~ ":::" ]]; then
curl -k --cert $ETCDCTL_CERT --key $ETCDCTL_KEY https://127.0.0.1:2379/metrics
else
curl -k --cert $ETCDCTL_CERT --key $ETCDCTL_KEY https://$etcd_endpoint/metrics
fi }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment