github.com/muhammedhassanm/blockchain@v0.0.0-20200120143007-697261defd4d/sawtooth-core-master/docs/source/sysadmin_guide/grafana_configuration.rst (about) 1 ******************************** 2 Configuring Grafana and InfluxDB 3 ******************************** 4 5 This procedure is for a Linux (Ubuntu) environment. For a Sawtooth network in 6 Docker containers, additional steps are needed to change the configuration of 7 the validator containers. These steps are not described in this procedure. 8 9 .. note:: 10 11 This procedure is for a Linux (Ubuntu) environment. For a Sawtooth network 12 in Docker containers, additional steps are needed to change the 13 configuration of the validator containers. These steps are not described in 14 this procedure. 15 16 Requirements 17 ============ 18 19 This guide assumes Docker Engine is installed and one or more Sawtooth 20 validator nodes have been configured. 21 22 Download `sawtooth-core <https://github.com/hyperledger/sawtooth-core>`_ 23 from the Hyperledger GitHub repository. 24 25 .. code-block:: console 26 27 $ git clone https://github.com/hyperledger/sawtooth-core.git 28 29 InfluxDB 30 ======== 31 32 #. First, pull the InfluxDB Docker image from Docker Hub. 33 34 .. code-block:: console 35 36 $ docker pull influxdb 37 38 #. Create an InfluxDB data directory to provide persistent storage on the local 39 file system. 40 41 .. note:: 42 43 Depending on the host operating system /var/lib/influx-data may not be 44 appropriate, modify this path accordingly. 45 46 .. code-block:: console 47 48 $ sudo mkdir /var/lib/influx-data 49 50 #. Next, start an InfluxDB Docker container. This command uses the persistent 51 storage on the local file system and exposes port 8086 to the network. It 52 also configures the database name and the ``admin`` and ``lrdata`` users for 53 InfluxDB. 54 55 .. code-block:: console 56 57 $ docker run -d -p 8086:8086 -v /var/lib/influx-data:/var/lib/influxdb \ 58 -e INFLUXDB_DB=metrics -e INFLUXDB_HTTP_AUTH_ENABLED=true \ 59 -e INFLUXDB_ADMIN_USER=admin -e INFLUXDB_ADMIN_PASSWORD='{admin-pw}' \ 60 -e INFLUXDB_USER=lrdata -e INFLUXDB_USER_PASSWORD='{lrdata-pw}' \ 61 --name sawtooth-stats-influxdb influxdb 62 63 .. note:: 64 65 Also, remember to properly escape any special characters, such as 66 ``,@!$``. 67 68 Grafana 69 ======= 70 71 #. First, build the Grafana Docker image from the Dockerfile included in the 72 sawtooth-core repository. 73 74 .. code-block:: console 75 76 $ cd sawtooth-core/docker 77 $ docker build . -f grafana/sawtooth-stats-grafana \ 78 -t sawtooth-stats-grafana 79 80 #. Run the Grafana container. 81 82 .. code-block:: console 83 84 $ docker run -d -p 3000:3000 --name sawtooth-stats-grafana \ 85 sawtooth-stats-grafana 86 87 #. Next, open the Grafana web page at ``http://{host}:3000``. 88 89 .. note:: 90 Be sure to replace {host} with the IP or Fully Qualified Domain Name 91 (FQDN) of the system running the Grafana Docker container. 92 93 #. Log in as user ``admin`` with the password ``admin``. 94 95 #. Change the admin password. First, click on the Grafana spiral icon at the 96 top left of the web page and go to "Admin / Profile". Next, click on 97 "Change Password". 98 99 #. Configure Grafana to use InfluxDB as a data source. 100 101 a. Click on the Grafana spiral icon at the top left of the web page and go to 102 "Data Sources". 103 104 #. Click on "Metrics". 105 106 #. Change the URL to the host server (IP or FQDN) running the InfluxDB 107 Docker container. 108 109 #. Under "InfluxDB Details", set INFLUXDB_USER to ``lrdata``. For 110 INFLUXDB_USER_PASSWORD, enter the ``lrdata`` password that was defined in 111 "Configure InfluxDB", above. 112 113 #. Click "Save & Test". 114 115 #. For Sawtooth 1.0.* only, import the 1.0 dashboard. (Sawtooth 1.1.* can use 116 the dashboard included in the Grafana Docker container from git master.) 117 118 a. Get the 1.0 dashboard from either 119 sawtooth-core/docker/grafana/dashboards/sawtooth_performance.json in the 120 1-0 branch or download from GitHub directly at `sawtooth_performance.json 121 <https://raw.githubusercontent.com/hyperledger/sawtooth-core/1-0/docker/grafana/dashboards/sawtooth_performance.json>`_. 122 123 #. Click Grafana spiral logo and mouse over "Dashboards", then click 124 "Import". 125 126 #. Click "Upload .json file". 127 128 #. Navigate to the location of `` sawtooth_performance.json``. 129 130 #. Select "metrics" in the drop-down menu and click "Import". 131 132 Sawtooth Configuration 133 ====================== 134 135 Sawtooth metrics are reported by the validator process, and are configured in 136 the file /etc/sawtooth/validator.toml. 137 138 #. If the validator configuration file doesn't exist yet, copy the template 139 from ``/etc/sawtooth/validator.toml.example`` to 140 ``/etc/sawtooth/validator.toml``. 141 142 #. Fill in the following values with the configurations used above. 143 ``opentsdb_url`` is the IP / FQDN:port to the InfluxDB instance, 144 ``opentsdb_db`` is the value of INFLUXDB_DB, then fill in the INFLUXDB_USER 145 for ``opentsdb_username`` and INFLUXDB_USER_PASSWORD for 146 ``opentsdb_password`` created above. 147 148 .. code-block:: console 149 150 # The host and port for Open TSDB database used for metrics 151 opentsdb_url = "http://{host}:3000" 152 153 # The name of the ld the Grafana Docker image from the Dockerfile included in thedatabase used for storing metrics 154 opentsdb_db = "met rics" 155 156 opentsdb_username = "lrdata" 157 158 opentsdb_password = "test" 159 160 .. note:: 161 Be sure to replace {host} with the IP or Fully Qualified Domain Name 162 (FQDN) of the system running the InfluxDB Docker container. 163 164 #. Restart sawtooth-validator for these changes to take effect. 165 166 If started via systemd: 167 168 .. code-block:: console 169 170 $ sudo systemctl restart sawtooth-validator 171 172 Telegraf Configuration 173 ======================= 174 175 Telegraf is used on the Sawtooth validator nodes for sending OS and hardware 176 metrics to InfluxDB. 177 178 #. Install Telegraf from the InfluxData repository. 179 180 .. code-block:: console 181 182 $ curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add - 183 $ sudo apt-add-repository "deb https://repos.influxdata.com/ubuntu xenial stable" 184 $ sudo apt-get update 185 $ sudo apt-get install telegraf 186 187 #. To configure Telegraf, edit ``/etc/telegraf/telegraf.conf``. 188 189 .. code-block:: console 190 191 $ sudo vi /etc/telegraf/telegraf.conf 192 193 #. Under ``[[outputs.influxdb]]``, change the following settings to match the 194 values used above. 195 196 .. code-block:: console 197 198 urls = ["http://{host}:8086"] 199 database = "metrics" 200 username = "lrdata" 201 password = "{lrdata-pw}" 202 203 .. note:: 204 Be sure to replace {host} with the IP or Fully Qualified Domain Name 205 (FQDN) of the system running the InfluxDB Docker container. 206 207 #. Restart Telegraf. 208 209 .. code-block:: console 210 211 $ sudo systemctl restart telegraf 212 213 .. Licensed under Creative Commons Attribution 4.0 International License 214 .. https://creativecommons.org/licenses/by/4.0/