Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

RChain Doctor is a log collection system for RChain. It's used to collect RNode logs from developers and testnet validators so that developers will have better insight into failures that occur in the wild and fix bugs more rapidly. The back-end RDoctor consists of backend running on RChain Coop infrstructure is called RDoctor and the client that runs and clients which run on validator machines nodes and sends log lines to RDoctor is called RNurse. RNurse is mostly just Filebeat. You can run Filebeat on your own but you have to adjust the configuration as described below.

Authentication

To be able to send logs to RDoctor, RNurse needs two authentication tokens:

  • RDOCTOR_API_KEY
    This one is used to identify the validator. You can obtain it from here https://register.rdoctor.rchain-dev.tk.
  • RDOCTOR_SESSION_KEY
    This one is issued by RChain makers. You'll get one on Testing Tuesdays.

Installation and usage

First of all you need to figure out location of RNode data directory.

...

If you run RNode as Docker container you need to bind mount the data directory from host to the container. So if you want the data directory to appear in /var/tmp/rnode in host, you need to add "-v /var/tmp/rnode:/var/lib/rnode" arguments to the Docker command line. For example, if you run RNode like this

Code Block
docker run -it --network=host rchain/rnode:dev run -b "rnode://..." --validator-private-key "..."

you need to change it like this (Docker arguments must appear before image name)

Code Block
docker run -it --network=host -v /var/tmp/rnode:/var/lib/rnode rchain/rnode:dev run -b "rnode://..." --validator-private-key "..."

RNurse

The easiest way is to run the RNurse on Linux (and possibly Mac) is to use Docker via the script https://register.rdoctor.rchain-dev.tk/rnurse. This script just setup configuration and data directory for Filebeat and runs it from Docker. The script needs RDOCTOR_API_KEY, RDOCTOR_SESSION_KEY and RNODE_DATA_DIR variables to be set. RNODE_DATA_DIR must point the RNode data directory discussed above.

To run the script do the following in terminal:

Code Block
curl -O https://register.rdoctor.rchain-dev.tk/rnurse
chmod +x rnurse
# set the following environment variables as described above
export RDOCTOR_API_KEY="...YOUR_API_KEY..."
export RDOCTOR_SESSION_KEY="...YOUR_SESSION_KEY..."
export RNODE_DATA_DIR="...YOUR_DATA_DIR..."
./rnurse

Now when you start RNode in another terminal (or as a system service) the log file found in $RNODE_DATA_DIR you specified will be continuously uploaded to RDoctor. The script doesn't print anything in absence of failures.

You may want to let the RNurse run in the background as system service. To set it up to run as systemd service you can run the following as root:

Code Block
curl https://register.rdoctor.rchain-dev.tk/rnurse >/usr/local/bin/rnurse
chmod +x /usr/local/bin/rnurse

mkdir /var/lib/rnurse
touch /var/lib/rnurse/env
chown 600 /var/lib/rnurse/env
cat >/var/lib/rnurse/env <EOF
export RDOCTOR_API_KEY="...YOUR_API_KEY..."
export RDOCTOR_SESSION_KEY="...YOUR_SESSION_KEY..."
export RNODE_DATA_DIR="...YOUR_DATA_DIR..."
EOF

cat >/usr/local/bin/rnurse.wrapper <EOF
#!/bin/sh -e
source /var/lib/rnurse/env
exec /usr/local/bin/rnurse
EOF
chmod +x /usr/local/bin/rnurse.wrapper

cat >/etc/systemd/system/rnurse.service <EOF
[Unit]
After=network.target
[Service]
ExecStart=/usr/local/bin/rnurse
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable rnurse
systemctl start rnurse

RNurse is now running as system daemon and will start and monitor the log file in $RNODE_DATA_DIR you specified on every boot.

Filebeat

You can run Filebeat manually but you need to make sure the following configuration settings are set in filebeat.yml:

Code Block
setup.template.enabled: false
output.elasticsearch.hosts: ["https://elasticsearch.rdoctor.rchain-dev.tk"]
output.elasticsearch.headers.X-Rdoctor-Api-Key: "...YOUR_API_KEY..."
output.elasticsearch.headers.X-Rdoctor-Session-Key: "...YOUR_SESSION_KEY..."

The setup.template.enabled must be set to false, otherwise, Filebeat would be stuck in loop trying to upload templates in RDoctor Elasticsearch backend.

The final configuration generated and used by RNurse looks roughly like this:

...

send log output backend.

The information on this page were no longer relevant. Please visit https://github.com/woky/rdoctor-client/blob/master/README.md for client setup instructions.