Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

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 running on RChain Coop infrstructure is called RDoctor and the client that runs on validator machines 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 systemd service — from unit file provided by official DEB or RPM packages or your own — the data directory is in /var/lib/rnode.
  • If you run RNode from terminal the data directory is in $HOME/.rnode where $HOME should point to the home directory of the user running the terminal session.
  • 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

    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)

    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:

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:

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:

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:

setup.template.enabled: false
filebeat.inputs:
- type: log
  multiline:
    pattern: '^.*? \['
    negate: true
    match: after
  paths:
  - /var/lib/rnode/rnode.log # ...YOUR_DATA_DIR...

output.elasticsearch:
  hosts: ["https://elasticsearch.rdoctor.rchain-dev.tk"]
  headers:
    X-Rdoctor-Api-Key: "...YOUR_API_KEY..."
    X-Rdoctor-Session-Key: "...YOUR_SESSION_KEY..."


  • No labels