metrics-write-datapoint.sh 616 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env bash
  2. #
  3. # Send a metrics datapoint
  4. #
  5. point=$1
  6. if [[ -z $point ]]; then
  7. echo "Data point not specified"
  8. exit 1
  9. fi
  10. echo "[$(date -u +"%Y-%m-%dT%H:%M:%SZ")] Influx data point: $point"
  11. if [[ -z $INFLUX_DATABASE || -z $INFLUX_USERNAME || -z $INFLUX_PASSWORD ]]; then
  12. echo Influx user credentials not found
  13. exit 0
  14. fi
  15. host="https://internal-metrics.solana.com:8086"
  16. if [[ -n $INFLUX_HOST ]]; then
  17. host="$INFLUX_HOST"
  18. fi
  19. echo "${host}/write?db=${INFLUX_DATABASE}&u=${INFLUX_USERNAME}&p=${INFLUX_PASSWORD}" \
  20. | xargs curl --max-time 5 --silent --show-error -XPOST --data-binary "$point"
  21. exit 0