Skip to content

Commit 40cdb9f

Browse files
authored
Merge pull request #377 from SimplyVC/release/1.3.0
Added version 1.3.0 code
2 parents e1254f4 + 46ca133 commit 40cdb9f

417 files changed

Lines changed: 41556 additions & 1951 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
./config
22
./alerter/logs
33
./certificates
4-
./web-installer/node_modules
5-
./web-installer/build
64
./ui/build
75
./ui/node_modules

.env

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,61 +13,65 @@ UI_ACCESS_IP=X.X.X.X
1313
# Development configuration
1414
DEV_MODE=false
1515

16-
# Installer configuration
17-
INSTALLER_IP=172.18.0.3
18-
INSTALLER_PORT=8000
19-
INSTALLER_USERNAME=admin
20-
INSTALLER_PASSWORD=password
21-
ACCESS_TOKEN_SECRET=7dgtas97fgsd97tgs9tg3490t6g508th0hge80rhg0s90dgs
22-
ACCESS_TOKEN_LIFE=120
23-
REFRESH_TOKEN_SECRET=9g9g90df8ghd80gh80tg0h8rth085gh458h085h0g8y54hg
24-
REFRESH_TOKEN_LIFE=86400
25-
2616
# Mongo configuration
2717
DB_NAME=panicdb
28-
DB_IP=172.18.0.2
29-
DB_IP_TEST=172.19.0.2
18+
3019
DB_PORT=27017
31-
INSTALLER_AUTH_COLLECTION=installer_authentication
32-
ACCOUNTS_COLLECTION=accounts
20+
21+
DB_IP_REPLICA_1=172.18.0.2
22+
DB_IP_REPLICA_1_TEST=172.19.0.2
23+
24+
DB_IP_REPLICA_2=172.18.0.3
25+
DB_IP_REPLICA_2_TEST=172.19.0.3
26+
27+
DB_IP_REPLICA_3=172.18.0.4
28+
DB_IP_REPLICA_3_TEST=172.19.0.4
29+
30+
DB_IP_REPLICA_STARTUP=172.18.0.5
31+
DB_IP_REPLICA_STARTUP_TEST=172.19.0.5
3332

3433
# Alerter configuration
35-
ALERTER_IP=172.18.0.4
34+
ALERTER_IP=172.18.0.7
3635
UNIQUE_ALERTER_IDENTIFIER=panic_alerter
3736

3837
# Redis configuration
39-
REDIS_IP=172.18.0.5
40-
REDIS_IP_TEST=172.19.0.5
38+
REDIS_IP=172.18.0.8
39+
REDIS_IP_TEST=172.19.0.8
4140
REDIS_PORT=6379
4241
REDIS_DB=10
43-
REDIS_TEST_DB=11
42+
REDIS_DB_TEST=11
4443

4544
# RabbitMQ configuration
46-
RABBIT_IP=172.18.0.6
47-
RABBIT_IP_TEST=172.19.0.6
45+
RABBIT_IP=172.18.0.9
46+
RABBIT_IP_TEST=172.19.0.9
4847
RABBIT_PORT=5672
4948

5049
# Health Checker configuration
51-
HEALTH_CHECKER_IP=172.18.0.7
50+
HEALTH_CHECKER_IP=172.18.0.10
5251

5352
# Tests configuration
54-
TESTS_IP=172.19.0.8
53+
TESTS_IP=172.19.0.11
5554

5655
# UI configuration
57-
UI_DASHBOARD_IP=172.18.0.9
56+
UI_DASHBOARD_IP=172.18.0.12
5857
UI_DASHBOARD_PORT=3333
5958

6059
# API configuration
61-
API_IP=172.18.0.10
60+
API_IP=172.18.0.13
61+
API_IP_TEST=172.19.0.13
6262
API_PORT=9000
63+
API_PORT_TEST=9001
6364

6465
# Substrate API configuration
65-
SUBSTRATE_API_IP=172.18.0.11
66+
SUBSTRATE_API_IP=172.18.0.14
6667
SUBSTRATE_API_PORT=8080
6768

69+
# Migration configuration
70+
MIGRATION_IP=172.18.0.15
71+
6872
# Logs configuration - Log files with {} are Python template strings, where {}
6973
# is replaced with text that makes the log file name specific to the process
70-
# that logs to it. For example, system_monitor_{}.log may become
74+
# that logs to it. For example, system_monitor_{}.log may become
7175
# system_monitor_validator.log.
7276
LOGGING_LEVEL=INFO
7377
DATA_STORE_LOG_FILE_TEMPLATE=logs/stores/{}.log
@@ -86,8 +90,8 @@ ALERTS_LOG_FILE=logs/alerts/alerts.log
8690
# becomes: https://api.github.com/repos/w3f/substrate/releases
8791
GITHUB_RELEASES_TEMPLATE=https://api.github.com/repos/{}releases
8892

89-
# DockerHub monitoring configuration - This is a Python template string, where
90-
# the two {} are replaced with the namespace and repository name, so that in the
93+
# DockerHub monitoring configuration - This is a Python template string, where
94+
# the two {} are replaced with the namespace and repository name, so that in the
9195
# case of nginx which belongs to the namespace library, the complete link becomes
9296
# https://hub.docker.com/v2/repositories/library/nginx/tags
9397
DOCKERHUB_TAGS_TEMPLATE=https://hub.docker.com/v2/repositories/{}/{}/tags
@@ -101,8 +105,8 @@ NODE_MONITOR_PERIOD_SECONDS=10
101105
CHAINLINK_CONTRACTS_MONITOR_PERIOD_SECONDS=10
102106
NETWORK_MONITOR_PERIOD_SECONDS=60
103107

104-
# Publishers limits - These define how much messages should be stored in a
105-
# publisher queue before starting to prune old messages. This happens when for
108+
# Publishers limits - These define how much messages should be stored in a
109+
# publisher queue before starting to prune old messages. This happens when for
106110
# some reason messages are not being sent by the publisher.
107111
DATA_TRANSFORMER_PUBLISHING_QUEUE_SIZE=1000
108112
ALERTER_PUBLISHING_QUEUE_SIZE=1000
@@ -118,4 +122,4 @@ ENABLE_LOG_ALERTS=True
118122

119123
# Twilio Preferences
120124
TWIML=<Response><Reject/></Response>
121-
TWIML_IS_URL=false
125+
TWIML_IS_URL=false

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
/cache
99

1010
# dependencies
11-
web-installer/node_modules
1211
ui/node_modules
1312
ui/www
1413
api/node_modules
14+
api/dist
1515
api/**/*.js
1616
# IDE
1717
.idea

.gitkeep

Whitespace-only changes.

README.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# PANIC Monitoring and Alerting for Blockchains
22

3-
**DISCLAIMERS**:
4-
- Don't allow public access to PANIC UI as it might contain sensitive information about your infrastructure. UI authentication is still to be developed.
3+
**DISCLAIMER**: Don't allow public access to PANIC UI as it might contain sensitive information about your infrastructure. UI authentication is still to be developed.
54

65
![PANIC Banner](./docs/images/PANIC_BANNER.png)
76

87
PANIC is an open source monitoring and alerting solution for Cosmos-SDK,
98
Substrate and Chainlink based nodes by [Simply VC](https://simply-vc.com.mt/).
10-
The tool was built with user friendliness in mind, and comes with numerous
11-
features such as phone calls for critical alerts, a UI Dashboard, a Web-UI
9+
The tool was built with user friendliness in mind and comes with numerous
10+
features, such as phone calls for critical alerts, a UI Dashboard, a Web based
1211
installation process and Telegram/Slack commands for increased control over your
1312
alerter.
1413

@@ -82,19 +81,17 @@ git clone https://github.com/SimplyVC/panic
8281
cd panic
8382
```
8483

85-
Now that you're inside the PANIC directory, open up the .env file and change the `INSTALLER_USERNAME` and `INSTALLER_PASSWORD` fields to your preferred but secure choice. This is to ensure that when configuring PANIC through the web-installer no one else can access it. Moreover, the `UI_ACCESS_IP` field must also be changed to the IP of where PANIC UI is going to be hosted (can be set to `localhost` if running locally). This is to ensure that the API is only accessible from the UI. Helper scripts which can be used to get the IP address (`scripts/get_ip_linux.sh` and `scripts/get_ip_mac.sh`) are available but please note that these are not guaranteed to work on all servers/machines.
84+
Now that you're inside the PANIC directory, open up the .env file and change the `UI_ACCESS_IP` field to the IP of where PANIC UI is going to be hosted (can be set to `localhost` if running locally). This is to ensure that the API (PANIC UI Backend) is only accessible from the UI. Helper scripts which can be used to get the IP address (`scripts/get_ip_linux.sh` and `scripts/get_ip_mac.sh`) are available but please note that these are not guaranteed to work on all servers/machines.
8685

8786
```bash
8887
# This will access the .env file on your terminal
8988
nano .env
9089
```
9190

92-
Once inside change `UI_ACCESS_IP`, `INSTALLER_USERNAME` and `INSTALLER_PASSWORD` accordingly. Here is an example:
91+
Once inside change `UI_ACCESS_IP` accordingly. Here is an example:
9392

9493
```ini
9594
UI_ACCESS_IP=1.1.1.1
96-
INSTALLER_USERNAME=panic_operator
97-
INSTALLER_PASSWORD=wowthisisasecurepassword
9895
```
9996

10097
Then to exit hit the following keys:
@@ -118,13 +115,13 @@ docker system prune -a --volumes
118115
docker-compose up -d --build
119116
```
120117

121-
Now you will have to configure PANIC to monitor your nodes and systems as well as give it the channels to alert you through. To do this you will have to navigate to the running web-installer. This can be found at `https://{UI_ACCESS_IP}:8000`, or at `https://localhost:8000` if you're running it locally. The installer will first ask you to enter the username and password. These are `INSTALLER_USERNAME` and `INSTALLER_PASSWORD` which you have changed previously. Make sure you type **HTTPS** if you're getting an error when accessing the installer on your browser.
118+
The next step is to configure PANIC to monitor your nodes and systems as well as give it the channels to alert you through. You can do this by navigating to the PANIC UI at `https://{UI_ACCESS_IP}:3333`, or at `https://localhost:3333` if you're running it locally. The PANIC UI will start the installation procedure if it does not detect any configurations. Make sure you type **HTTPS** if you're getting an error when accessing PANIC UI on your browser.
122119

123-
After you set-up PANIC to your liking, the Web-Installer will save these details in the form of configuration files inside the `config` folder. For correct behavior, these configuration files should never be modified. If you would like to edit them at some point, we suggest to re-run the web-installer again. The web-installer will ask you if you want to start a fresh install or load your old configuration.
120+
After you set-up PANIC to your liking the installation procedure will save these details in the Mongo database. For correct behavior the database should never be modified manually. If you would like to edit the configurations at some point you can do so by accessing the settings option on the PANIC UI header.
124121

125-
PANIC will automatically read these configuration files and begin monitoring the data sources. To check that this is the case we suggest running the command `docker-compose logs -f alerter` and `docker-compose logs -f health-checker`. By this you can see the different components starting up. If you have set-up telegram/slack commands we suggest that you enter the command `/status` to check that all PANIC components are running. If you really want to check that PANIC is up and running, we suggest that you check that all the logs inside `panic/alerter/logs` have no errors.
122+
PANIC will automatically read these configuration files and begin monitoring the data sources. To confirm that PANIC is running as expected we suggest running the command `docker-compose logs -f alerter` and `docker-compose logs -f health-checker`. By this you can see the different components starting up. If you have set-up telegram/slack commands we suggest that you enter the command `/status` (telegram) or `/panicstatus` (slack) to check that all PANIC components are running. If you want to check that every PANIC component is up and running without any issue we suggest that you check that all the logs inside `panic/alerter/logs` have no errors.
126123

127-
You can visualise node metrics and alerts using PANIC UI, which can be accessed at `https://{UI_ACCESS_IP}:3333`, or at `https://localhost:3333` if you're running it locally.
124+
After PANIC is up and running you can visualise node metrics and alerts using PANIC UI at `https://{UI_ACCESS_IP}:3333`, or at `https://localhost:3333` if you're running it locally.
128125
For more information regarding PANIC UI, [click here](./ui/README.md).
129126

130127
Congratulations you should have PANIC up and running!
@@ -277,17 +274,11 @@ If you wish to explore more advanced features, PANIC also supports configurable
277274
3. The rest can be configured to your preferences.
278275
4. Click `Add Service`
279276
2. You will be taken to a new page, where you need to navigate to the `Integrations` tab and take note of the (i)`Integration Key`.
280-
- Secondly the API Token
281-
1. Navigate to `https:/{YOUR_SUBDOMAIN}.pagerduty.com/api_keys`.
282-
2. Click `Create New API Key`
283-
3. Give it a description (This can be anything you want)
284-
4. Click `Create Key` and take note of (ii)`API Key` value.
285277

286278
**At the end, you should have:**
287279
1. The Integration Key
288-
2. The API token
289280

290-
These will be used later in the Web-Installer to be saved in the configuration files.
281+
This will be used later on in the installation procedure.
291282

292283
**Note** You can also install an app for Android / iPhone as well as setup your phone number to receive alerts.
293284

@@ -306,15 +297,15 @@ These will be used later in the Web-Installer to be saved in the configuration f
306297
**At the end, you should have:**
307298
1. The API token
308299

309-
These will be used later in the Web-Installer to be saved in the configuration files.
300+
This will be used later on in the installation procedure.
310301

311302
**Note** You can also install the Opsgenie app for Android / iPhone as well as setup your phone number to receive calls.
312303

313304
[Back to Requirements](#requirements)
314305

315306
### Replacing SSL certificates (recommended)
316307

317-
Apply your own SSL certificate signed by a certificate authority. The SSL certificate (cert.pem) and the key (key.pem) should be placed in the `panic/certificates` folder, and they should replace the existing dummy files. Note that these dummy files were given just for convenience as the Installer server won't start without them, however, for maximum security these must be replaced.
308+
Apply your own SSL certificate signed by a certificate authority. The SSL certificate (cert.pem) and the key (key.pem) should be placed in the `panic/certificates` folder, and they should replace the existing dummy files. Note that these dummy files were given just for convenience as the API (PANIC UI Backend) server won't start without them, however, for maximum security these must be replaced.
318309

319310
We suggest reading [this](https://nodejs.org/en/knowledge/HTTP/servers/how-to-create-a-HTTPS-server/) for more details on SSL certificates, and how to generate a self signed certificate in case you do not want to obtain a certificate signed by a certificate authority. However, for maximum security, the self signed certificate option is not recommended.
320311

@@ -334,6 +325,13 @@ npm install # Install API project dependencies
334325
npm test # Run API unit tests
335326
```
336327

328+
To run the tests for the **Substrate API** component within PANIC, navigate to the
329+
`/substrate-api` directory and do the following:
330+
```bash
331+
npm install # Install API project dependencies
332+
npm test # Run API unit tests
333+
```
334+
337335
To run the tests for the **UI** component within PANIC, navigate to the
338336
`/ui` directory and do the following:
339337
```bash

alerter/run_alerter.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from src.alerter.managers.substrate import SubstrateAlertersManager
1919
from src.alerter.managers.system import SystemAlertersManager
2020
from src.channels_manager.manager import ChannelsManager
21-
from src.config_manager import ConfigsManager
21+
from src.config_manager.change_stream.config_manager import ConfigsManager
2222
from src.data_store.stores.manager import StoreManager
2323
from src.data_transformers.manager import DataTransformersManager
2424
from src.message_broker.rabbitmq import RabbitMQApi
@@ -30,7 +30,6 @@
3030
from src.monitors.managers.node import NodeMonitorsManager
3131
from src.monitors.managers.system import SystemMonitorsManager
3232
from src.utils import env
33-
from src.utils.constants.configs import IGNORE_FILE_PATTERNS
3433
from src.utils.constants.names import (
3534
SYSTEM_ALERTERS_MANAGER_NAME, GITHUB_ALERTER_MANAGER_NAME,
3635
DOCKERHUB_ALERTER_MANAGER_NAME, SYSTEM_MONITORS_MANAGER_NAME,
@@ -589,13 +588,12 @@ def _initialise_config_manager() -> Tuple[ConfigsManager, logging.Logger]:
589588
config_manager_logger = _initialise_logger(
590589
display_name, ConfigsManager.__name__, env.CONFIG_MANAGER_LOG_FILE
591590
)
592-
591+
593592
rabbit_ip = env.RABBIT_IP
594593
while True:
595594
try:
596595
config_manager = ConfigsManager(
597-
display_name, config_manager_logger, '../config', rabbit_ip,
598-
ignore_file_patterns=IGNORE_FILE_PATTERNS
596+
display_name, config_manager_logger, rabbit_ip
599597
)
600598
return config_manager, config_manager_logger
601599
except Exception as e:

alerter/src/channels_manager/handlers/starters.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from src.data_store.redis import RedisApi
4040
from src.message_broker.rabbitmq import RabbitMQApi
4141
from src.utils import env
42+
from src.utils.constants.mongo import REPLICA_SET_HOSTS, REPLICA_SET_NAME
4243
from src.utils.constants.names import (TELEGRAM_ALERTS_HANDLER_NAME_TEMPLATE,
4344
TELEGRAM_COMMANDS_HANDLER_NAME_TEMPLATE,
4445
TELEGRAM_COMMAND_HANDLERS_NAME,
@@ -174,7 +175,8 @@ def _initialise_telegram_commands_handler(
174175
namespace=env.UNIQUE_ALERTER_IDENTIFIER)
175176
cmd_handlers_mongo = MongoApi(
176177
logger=cmd_handlers_logger.getChild(MongoApi.__name__),
177-
host=env.DB_IP, db_name=env.DB_NAME, port=env.DB_PORT)
178+
host=REPLICA_SET_HOSTS, db_name=env.DB_NAME,
179+
replicaSet=REPLICA_SET_NAME)
178180

179181
cmd_handlers = TelegramCommandHandlers(
180182
TELEGRAM_COMMAND_HANDLERS_NAME, cmd_handlers_logger,
@@ -282,7 +284,8 @@ def _initialise_slack_commands_handler(
282284
namespace=env.UNIQUE_ALERTER_IDENTIFIER)
283285
cmd_handlers_mongo = MongoApi(
284286
logger=cmd_handlers_logger.getChild(MongoApi.__name__),
285-
host=env.DB_IP, db_name=env.DB_NAME, port=env.DB_PORT)
287+
host=REPLICA_SET_HOSTS, db_name=env.DB_NAME,
288+
replicaSet=REPLICA_SET_NAME)
286289

287290
cmd_handlers = SlackCommandHandlers(
288291
SLACK_COMMAND_HANDLERS_NAME, cmd_handlers_logger,
@@ -597,4 +600,4 @@ def start_handler(handler: ChannelHandler) -> None:
597600
log_and_print(get_stopped_message(handler), handler.logger)
598601
log_and_print("Restarting {} in {} seconds.".format(
599602
handler, RESTART_SLEEPING_PERIOD), handler.logger)
600-
time.sleep(RESTART_SLEEPING_PERIOD)
603+
time.sleep(RESTART_SLEEPING_PERIOD)

0 commit comments

Comments
 (0)