diff --git a/.gitignore b/.gitignore index c81ead1375..0b446606b1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /book/src/img/ /book/src/tests.ok /farf/ +/metrics/scripts/lib/ /solana-release/ solana-release.tar.bz2 /target/ diff --git a/metrics/scripts/.gitignore b/metrics/scripts/.gitignore deleted file mode 100644 index 502167fa0b..0000000000 --- a/metrics/scripts/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/lib diff --git a/metrics/scripts/README.md b/metrics/scripts/README.md index 419340bcde..adf84944f6 100644 --- a/metrics/scripts/README.md +++ b/metrics/scripts/README.md @@ -7,7 +7,7 @@ Start the local metric services: `$ ./start.sh` -Metrics are enabled on a per-shell basis which means you must `source` the following scripts in each shell in which you start an application you wish to collect metrics from. For example, if running a Solana fullnode you must call `source ./enable.sh` before starting the node. +Metrics are enabled on a per-shell basis which means you must `source` the following scripts in each shell in which you start an application you wish to collect metrics from. For example, if running a Solana fullnode you must call `source ./enable.sh` before starting the node: `$ source ./enable.sh` @@ -15,6 +15,11 @@ Once metrics have been started and you have an application running you can view http://localhost:3000/d/local/local-monitor +To test that things are working correctly you can send a test airdrop data point and then check the +metrics dashboard: + +`$ ./test.sh` + Stop metric services: `$ ./stop.sh` @@ -26,11 +31,10 @@ adhoc metrics collection/viewing * Linux - `sudo apt-get install influxdb-client` * macOS - `brew install influxdb` +Simple example of pulling all airdrop measurements out of the `testnet` database: -Simple example of pulling all `thinclient` measurements out -of the `local` database: ```sh -$ influx -database local -username admin -password admin -execute 'select * from thinclient' +$ influx -database testnet -username admin -password admin -execute 'SELECT * FROM "drone-airdrop"' ``` Reference: https://docs.influxdata.com/influxdb/v1.5/query_language/ @@ -39,7 +43,7 @@ Reference: https://docs.influxdata.com/influxdb/v1.5/query_language/ To monitor activity, run one of: -``` +```sh $ docker logs -f influxdb $ docker logs -f grafana ``` diff --git a/metrics/scripts/test.sh b/metrics/scripts/test.sh new file mode 100755 index 0000000000..99f169732b --- /dev/null +++ b/metrics/scripts/test.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# +# Test local metrics by sending a airdrop datapoint +# + +set -e + +cd "$(dirname "$0")" + +# shellcheck source=metrics/scripts/enable.sh +source ./enable.sh + +if [[ -z $INFLUX_DATABASE || -z $INFLUX_USERNAME || -z $INFLUX_PASSWORD ]]; then + echo Influx user credentials not found + exit 0 +fi + +host="https://localhost:8086" +if [[ -n $INFLUX_HOST ]]; then + host="$INFLUX_HOST" +fi + +set -x + +point="drone-airdrop,localmetrics=test request_amount=1i,request_current=1i" +echo "${host}/write?db=${INFLUX_DATABASE}&u=${INFLUX_USERNAME}&p={$INFLUX_PASSWORD}" \ + | xargs curl -XPOST --data-binary "$point"