/ node / metrics / README.md
README.md
 1  # snarkos-node-metrics
 2  
 3  [![Crates.io](https://img.shields.io/crates/v/snarkos-node-metrics.svg?color=neon)](https://crates.io/crates/snarkos-node-metrics)
 4  [![Authors](https://img.shields.io/badge/authors-Aleo-orange.svg)](https://aleo.org)
 5  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](./LICENSE.md)
 6  
 7  The `snarkos-node-metrics` crate provides access to metrics for the `snarkos` node.
 8  
 9  ## Instructions
10  
11  #### Quick Start
12  
13  To start up Grafana and Prometheus, run the following command:
14  ```bash
15  cd node/metrics
16  docker-compose up --detach
17  ```
18  
19  To check that the metrics are running, go to http://localhost:9000.
20  
21  Lastly, go to [http://localhost:3000/](http://localhost:3000/) to see the metrics dashboard.
22  The initial login is `admin` and the password is `admin`.
23  
24  #### First-Time Setup
25  
26  1. **Start snarkOS with Metrics Enabled**
27      - Launch snarkOS using the command line with the `--metrics` flag to enable metrics tracking.
28  
29  2. **Navigate to Metrics Directory**
30      - Change your current directory to `node/metrics` using the command `cd node/metrics`.
31  
32  3. **Deploy Prometheus and Grafana with Docker**
33      - Execute `docker-compose up --detach`. This command uses the `docker-compose.yml` file to set up two containers: Prometheus and Grafana, eliminating the need for direct installation.
34  
35  4. **Verify Metrics Accessibility**
36      - Use the command `curl http://localhost:9000` to check if the metrics are accessible at the specified URL.
37  
38  5. **Access Grafana Dashboard**
39      - Open your web browser and navigate to `http://localhost:3000`. This is the Grafana user interface.
40  
41  6. **Grafana Login Process**
42      - Log in using the default credentials: username `admin` and password `admin`. On first login, you'll be prompted to change the password, but you can choose to skip this step.
43  
44  7. **Configure Prometheus Data Source**
45      - In Grafana, navigate to `Datasources`.
46      - Select `Prometheus` as the data source.
47      - Enter `http://prometheus:9090` as the server URL.
48      - Confirm the setup by clicking `Save and Test`. You should see a message confirming successful connection to the Prometheus API.
49  
50  8. **Import snarkOS Dashboard**
51      - Return to the Grafana home page by clicking `Home` in the top breadcrumb navigation.
52      - Click on the arrow next to the `+` icon in the top right corner.
53      - Select `Import dashboard`.
54      - Drag and drop the `node/metrics/snarkOS-grafana.json` file into the top panel of the import interface.
55      - From the dropdown box, choose the Prometheus data source you previously set up.
56      - Finalize the process by clicking `Import`.
57  
58  Following these steps will successfully set up and configure a monitoring environment for your snarkOS nodes using Docker, Prometheus, and Grafana.