Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump the npm_and_yarn group across 1 directory with 2 updates #14

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Binary file added .DS_Store
Binary file not shown.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Shardeum

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Shardeum Network Monitoring Project

This repository is designed to monitor the status of the Shardeum Network services.
It provides users with information about the health of the Shardeum network, uptime, and latency.

![Shardeum network status](https://res.cloudinary.com/kennyy/image/upload/v1716044789/CleanShot_2024-05-18_at_19.05.34_2x_kliwxi.png)


### Prerequisites.
* To get started, ensure you have `Node.js` installed preferably v18+
* Adhere to the requirements of each submodule (frontend & backend)

### Installation

#### Clone the Network Status Repository.

First, clone the Shardeum network status repository to your local machine.


```
git clone https://github.com/shardeum/network-status.git
```

#### Install the required dependencies for the frontend and backend:
For the backend,

```bash
cd backend
npm i
```

This will install all the dependencies required for the backend project (i.e Node.js server)

To start the local development server for the backend project, run the following command:

```bash
npm start
```

This will start the local Node server on port `3002` (or your locally specified port).

> Your Prometheus server should be running on port 9090 [how to set up Prometheus](https://github.com/shardeum/network-status/tree/main/backend#run-prometheus)
>
For the frontend project, change directory into the frontend directory and install the dependencies.

```bash
cd ..
cd frontend
npm i
```
Start the frontend server by running the following command:

```bash
npm run dev
```

This will start the local development server for the frontend project on port `3000` (or your locally specified port).
2 changes: 2 additions & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# PORT = 3002
# Port to run the server on
29 changes: 29 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Use an official Node.js runtime as the base image
FROM node:20

# Set the working directory in the container
WORKDIR /usr/src/app

# Copy package.json and package-lock.json
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

# Install Prometheus
RUN apt-get update && apt-get install -y prometheus

# Copy the Prometheus configuration file
COPY prometheus.yml /etc/prometheus/prometheus.yml

# Make the entry script executable
RUN chmod +x /usr/src/app/entry.sh

# Expose the ports the app runs on
EXPOSE 3002 9090

# Start both the Node.js application and Prometheus
CMD ["./entry.sh"]
23 changes: 22 additions & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# Shardeum Status Server

Instructions to run locally coming soon...
This is a Node server that monitors the Shardeum network on a set interval and feeds the data to Prometheus (A time series database we are using to store metrics).
The services and their expected responses are contained in the `endpoints.jsoon` file within the backend folder.

## Running it locally

To run this server locally, follow these steps:

* Clone the repository with `git clone https://github.com/shardeum/network-status.git`
* Change into the backend directory with `cd backend`
* Install the dependencies with `npm install`
* Run the local dev server with: `npm start`
* This should start the server on port 3002 from where it will feed data to Prometheus.


## Run Prometheus
Prometheus is also required to scrape metrics from the server. To run Prometheus locally:
* Download the prometheus binary for your local machine from https://prometheus.io/
* Extract the contents of the zip file to access the prometheus executable
* Open the `prometheus.yml` file in the root directory and update with the contents of the `prometheus.yml` in this project
* Lastly, run the prometheus executable with: `./prometheus`

Prometheus should now ping your local server on the specified port based on the configuration in the yml file.
7 changes: 3 additions & 4 deletions backend/app.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { Request, Response } from 'express';
const express = require('express');
const cors = require('cors')
const prometheus = require('prom-client');
const HealthChecker = require('./services/servicecheck');
const app = express();
require('dotenv').config();

app.use(cors());
const healthChecker = new HealthChecker();

const PORT = process.env.PORT || 3002;
const PORT = process.env.PORT || 3003;

app.get('/metrics', async (req: Request, res: Response) => {
healthChecker.startPeriodicChecks();

// healthChecker.startPeriodicChecks();
const metrics = await prometheus.register.metrics();
res.set('Content-Type', prometheus.register.contentType);
res.send(metrics);
Expand Down
47 changes: 32 additions & 15 deletions backend/endpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,70 @@
"group": "Archivers Servers",
"servers": [
{
"url": "http://172.105.153.160:4000/nodelist",
"url": "http://198.58.110.213:4000/nodelist",
"name": "Archiver 1",
"help": "This is the first Archiver server"
},
{
"url": "http://172.105.153.160:4000/nodelistfaddada",
"name": "Archiver 2",
"help": "This is the second Archiver server"
"help": "This is the first Archiver server",
"expectedResponse":{
"nodeList": [{}, {}],
"sign":{
"owner":"d34b80a5a6f9638b7c75d6eb6e59d35d9a3e103f1877827eebbe973b8281f794"
}
}
}
]
},
{
"group": "Monitors Servers",
"servers": [
{
"url": "http://50.116.18.184:3000/summarasdsfy",
"url": "http://198.58.113.59:3000/summary",
"name": "Monitor 1",
"help": "This is the first Monitor server"
"help": "This is the first Monitor server",
"expectedResponse": "Ascending"
}
]
},
{
"url": "http://72.14.184.233:8080",
"url": "http://139.162.162.217:8080",
"name": "JSON-RPC Server",
"help": "This is the first JSON-RPC server",
"body": {
"jsonrpc": "2.0",
"method": "eth_gasPrice",
"params": [],
"id": 73
},
"expectedResponse": {
"jsonrpc": "2.0",
"id": 73
}
},
{
"url": "https://explorer-sphinx.shardeum.org/",
"url": "https://explorer-atomium.shardeum.org",
"name": "Explorer",
"help": "This is the Shardeum Explorer"
"help": "This is the Shardeum Explorer",
"expectedResponse": "The Shardeum Betanet Explorer"

},
{
"url": "https://shardeum.org/",
"url": "https://shardeum.org",
"name": "Website",
"help": "This is the Shardeum Website"
"help": "This is the Shardeum Website",
"expectedResponse": "Shardeum | EVM based Sharded Layer 1 Blockchain"
},
{
"url": "https://docs.shardeum.org/",
"name": "Documentation",
"help": "This is the Shardeum Documentation"
"help": "This is the Shardeum Documentation",
"expectedResponse": "Shardeum is a scalable, secure, and efficient blockchain platform that enables developers to build and deploy decentralized applications. Dive into our documentation to learn more about Shardeum and how to get started with the network"
},
{
"url": "https://faucet-atomium.shardeum.org/is-healthy",
"name": "Faucet",
"help": "This is the Shardeum Faucet",
"expectedResponse": {
"health": true
}
}
]
}
2 changes: 2 additions & 0 deletions backend/entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
npm start & prometheus --config.file=/etc/prometheus/prometheus.yml --web.listen-address=:9090
2 changes: 2 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "shardeum-status-server",

"version": "1.0.0",
"description": "Shardeum Status Server to monitor the health of Shardeum systems",
"main": "app.ts",
Expand All @@ -16,6 +17,7 @@
"dotenv": "^16.4.5",
"express": "^4.18.3",
"https": "^1.0.0",
"node-fetch": "^3.3.2",
"nodemon": "^3.1.0",
"prom-client": "^15.1.0",
"response-time": "^2.3.2"
Expand Down
Loading