-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy Bootstrap and add Metrics (#38)
* deploy bootstrap validator * wip. added bootstrap service. need lb service * deploy and wait for validator ready. need readme update * update readme. update progress. fix selector bug * add metrics * clean up
- Loading branch information
1 parent
576851d
commit da24112
Showing
7 changed files
with
475 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
here=$(dirname "$0") | ||
|
||
# https://gist.github.com/cdown/1163649 | ||
urlencode() { | ||
declare s="$1" | ||
declare l=$((${#s} - 1)) | ||
for i in $(seq 0 $l); do | ||
declare c="${s:$i:1}" | ||
case $c in | ||
[a-zA-Z0-9.~_-]) | ||
echo -n "$c" | ||
;; | ||
*) | ||
printf '%%%02X' "'$c" | ||
;; | ||
esac | ||
done | ||
} | ||
|
||
usage() { | ||
exitcode=0 | ||
if [[ -n "$1" ]]; then | ||
exitcode=1 | ||
echo "Error: $*" | ||
fi | ||
cat <<EOF | ||
usage: $0 [-e] [-d] [-c database_name] [username] | ||
Creates a testnet dev metrics database | ||
username InfluxDB user with access to create a new database | ||
-c Manually specify a database to create, rather than read from config file | ||
-d Delete the database instead of creating it | ||
-e Assume database already exists and SOLANA_METRICS_CONFIG is | ||
defined in the environment already | ||
EOF | ||
exit $exitcode | ||
} | ||
|
||
useEnv=false | ||
delete=false | ||
createWithoutConfig=false | ||
host="https://internal-metrics.solana.com:8086" | ||
while getopts ":hdec:" opt; do | ||
case $opt in | ||
h) | ||
usage | ||
exit 0 | ||
;; | ||
c) | ||
createWithoutConfig=true | ||
netBasename=$OPTARG | ||
;; | ||
d) | ||
delete=true | ||
;; | ||
e) | ||
useEnv=true | ||
;; | ||
*) | ||
usage "unhandled option: $OPTARG" | ||
;; | ||
esac | ||
done | ||
shift $((OPTIND - 1)) | ||
|
||
if $useEnv; then | ||
[[ -n $SOLANA_METRICS_CONFIG ]] || | ||
usage "SOLANA_METRICS_CONFIG is not defined in the environment" | ||
else | ||
username=$1 | ||
[[ -n "$username" ]] || usage "username not specified" | ||
|
||
read -rs -p "InfluxDB password for $username: " password | ||
[[ -n $password ]] || { echo "Password not specified"; exit 1; } | ||
echo | ||
|
||
password="$(urlencode "$password")" | ||
|
||
query() { | ||
echo "$*" | ||
set -x | ||
curl -XPOST \ | ||
"$host/query?u=${username}&p=${password}" \ | ||
--data-urlencode "q=$*" | ||
} | ||
|
||
query "DROP DATABASE \"$netBasename\"" | ||
! $delete || exit 0 | ||
query "CREATE DATABASE \"$netBasename\"" | ||
query "ALTER RETENTION POLICY autogen ON \"$netBasename\" DURATION 7d" | ||
query "GRANT READ ON \"$netBasename\" TO \"ro\"" | ||
query "GRANT WRITE ON \"$netBasename\" TO \"scratch_writer\"" | ||
|
||
SOLANA_METRICS_CONFIG="host=$host,db=$netBasename,u=scratch_writer,p=topsecret" | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.