diff --git a/simplexalerts/alert.png b/simplexalerts/alert.png new file mode 100644 index 0000000..445b1e0 Binary files /dev/null and b/simplexalerts/alert.png differ diff --git a/simplexalerts/alert_rules.png b/simplexalerts/alert_rules.png new file mode 100644 index 0000000..185cd09 Binary files /dev/null and b/simplexalerts/alert_rules.png differ diff --git a/simplexalerts/contact_points.drawio b/simplexalerts/contact_points.drawio new file mode 100644 index 0000000..45c0b2c --- /dev/null +++ b/simplexalerts/contact_points.drawio @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/simplexalerts/contact_points.png b/simplexalerts/contact_points.png index f9cbe25..9139398 100644 Binary files a/simplexalerts/contact_points.png and b/simplexalerts/contact_points.png differ diff --git a/simplexalerts/index.md b/simplexalerts/index.md index e1db2b9..0f2f4c3 100644 --- a/simplexalerts/index.md +++ b/simplexalerts/index.md @@ -92,7 +92,7 @@ Download the simplex-chat ubuntu release as shown: Run your client in server mode: - [user@devnode:~]$ simplex-chat -d clientDB -p 1337 + [user@devnode:~]$ simplex-chat -d clientDB -p 1337 -x No user profiles found, it will be created now. Please choose your display name. It will be sent to your contacts when you connect. @@ -225,14 +225,159 @@ so it looks like this: ##### Start the alerter -Here using docker becomes a hassle, since we are going to have to make the simplex-chat port accessible. For security easons it runs on the loopback interface. +Run the container + + sudo docker run -v $(pwd):/config --network="host" --rm simplex-alerter -c /config/config.yml -e 127.0.0.1:1337 + +It will connect to the simplex-chat client we started earlier. You can check the metrics to make sure it's running by checking the metrics page + + curl http://localhost:7898/metrics | less + # HELP python_gc_objects_collected_total Objects collected during gc + # TYPE python_gc_objects_collected_total counter + python_gc_objects_collected_total{generation="0"} 600.0 + python_gc_objects_collected_total{generation="1"} 15.0 + python_gc_objects_collected_total{generation="2"} 0.0 + # HELP python_gc_objects_uncollectable_total Uncollectable objects found during GC + # TYPE python_gc_objects_uncollectable_total counter + python_gc_objects_uncollectable_total{generation="0"} 0.0 + python_gc_objects_uncollectable_total{generation="1"} 0.0 + python_gc_objects_uncollectable_total{generation="2"} 0.0 + # HELP python_gc_collections_total Number of times this generation was collected + ... + ... + ... -let's create a socat tunnel with: +### Configuring a grafana endpoint - apt install socat - sudo socat TCP-LISTEN:31337,bind=172.17.0.1,reuseaddr,fork TCP:127.0.0.1:1337& - -Now run our container: +Browse to the contact points page in grafana and click on "add a new contact point" +![](contact_points.png) + + +Fill out the details, don't forget the path after the URL, as it's how the alerter knows where to deliver the messages + +![new_contact_point.png] + +And click on Test! + + +Result: + + +![](alert.png) + + +### Configuring an actual alert + +Now that our webhook is ready we can configure an actual alert! + +Go to alert rules and click on "create a new alert rule" + +![](create_alert.png) + +Now you need to configure it: + +![](test_alert.png) + +- set a name +- make sure it uses the Prometheus data source +- add an alerting condition (must be True to fire) +- Use the preview button to check that the alert would indeed be firing upon creation + + +#### Keeping things Tidy + +Your alert must live in a folder: + + +Click on "New folder" +![](test_alert2.png) + +and add a folder name + +![](test_alert_2_1.png) + +#### Alert Evaluation + +![](test_alert_3.png) + +Alerts are regularly *evaluated* by grafana. Which means grafana will run the query at specific intervals and fire the alert if the conditions specified are filled. + + +Let's imagine that we want to keep a close eye on this alert, as if 0 ever not equals 0 then we will have big problems. + + +First configure an evaluation group and set its name. You can leave the one minute evaluation timing as it's the shortest. + +![](test_alert_3_1.png) + + +You can leave all other options to their default. + + +#### Alert Contact Point + +Now we are going to use the alert contact point we created earlier: + +![](test_alert_4.png) + +Choose from the drop-down menu the web hook we configured. + + +#### Alert Message + +When the conditions are fulfilled you want an information to be conveyed: that's where you configure it + +![](test_alert_5.png) + + +#### And now let's blow up some phones + +Save the rule and exit, in 1 minute it will be evaluated and you will receive a a notification + +![](test_alert_6.png) + + +And here's the alert: + +![](test_alert_7.png) + + +# Configuring those systems as systemd services + +To turn the simplex-chat and the alerter into systemd services, you only need to create two files: + +## /etc/systemd/system/simplex-chat.service + + [Unit] + Requires=tor.service + + [Service] + ExecStart=simplex-chat -d /etc/alerter_clientDB -p 1337 -x + [Install] + WantedBy=multi-user.target + +## /etc/systemd/system/alerter.service + + + [Unit] + Requires=simplex-chat.service + + [Service] + ExecStart=docker run --rm simplex-alerter -c /etc/alerter-config.yaml -e 127.0.0.1:1337 + + [Install] + WantedBy=simplex-chat.service + +## Enable the services +Now enable the services + + systemctl enable simplex-chat.service + systemctl enable alerter.service + + +# Conclusion + +We now have an easy way to set multiple alerts to different groups based on our monitoring system, furthermore those alerts will be sent over tor through a privacy-preserving messaging system. diff --git a/simplexalerts/new_alert.drawio b/simplexalerts/new_alert.drawio new file mode 100644 index 0000000..b51be63 --- /dev/null +++ b/simplexalerts/new_alert.drawio @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/simplexalerts/new_alert.png b/simplexalerts/new_alert.png new file mode 100644 index 0000000..618aed6 Binary files /dev/null and b/simplexalerts/new_alert.png differ diff --git a/simplexalerts/new_contact_point.drawio b/simplexalerts/new_contact_point.drawio new file mode 100644 index 0000000..a5c1007 --- /dev/null +++ b/simplexalerts/new_contact_point.drawio @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/simplexalerts/new_contact_point.png b/simplexalerts/new_contact_point.png new file mode 100644 index 0000000..f7c18f6 Binary files /dev/null and b/simplexalerts/new_contact_point.png differ diff --git a/simplexalerts/test_alert.drawio b/simplexalerts/test_alert.drawio new file mode 100644 index 0000000..cab7258 --- /dev/null +++ b/simplexalerts/test_alert.drawio @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/simplexalerts/test_alert.png b/simplexalerts/test_alert.png new file mode 100644 index 0000000..3b62d9e Binary files /dev/null and b/simplexalerts/test_alert.png differ diff --git a/simplexalerts/test_alert_2.png b/simplexalerts/test_alert_2.png new file mode 100644 index 0000000..f336052 Binary files /dev/null and b/simplexalerts/test_alert_2.png differ diff --git a/simplexalerts/test_alert_2_1.png b/simplexalerts/test_alert_2_1.png new file mode 100644 index 0000000..444fcb6 Binary files /dev/null and b/simplexalerts/test_alert_2_1.png differ diff --git a/simplexalerts/test_alert_3.drawio b/simplexalerts/test_alert_3.drawio new file mode 100644 index 0000000..144cad6 --- /dev/null +++ b/simplexalerts/test_alert_3.drawio @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/simplexalerts/test_alert_3.png b/simplexalerts/test_alert_3.png new file mode 100644 index 0000000..c4581d4 Binary files /dev/null and b/simplexalerts/test_alert_3.png differ diff --git a/simplexalerts/test_alert_3_1.png b/simplexalerts/test_alert_3_1.png new file mode 100644 index 0000000..bc39966 Binary files /dev/null and b/simplexalerts/test_alert_3_1.png differ diff --git a/simplexalerts/test_alert_4.drawio b/simplexalerts/test_alert_4.drawio new file mode 100644 index 0000000..2053fd8 --- /dev/null +++ b/simplexalerts/test_alert_4.drawio @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/simplexalerts/test_alert_4.png b/simplexalerts/test_alert_4.png new file mode 100644 index 0000000..ba6b645 Binary files /dev/null and b/simplexalerts/test_alert_4.png differ diff --git a/simplexalerts/test_alert_5.png b/simplexalerts/test_alert_5.png new file mode 100644 index 0000000..18b3a3d Binary files /dev/null and b/simplexalerts/test_alert_5.png differ diff --git a/simplexalerts/test_alert_6.drawio b/simplexalerts/test_alert_6.drawio new file mode 100644 index 0000000..3910adf --- /dev/null +++ b/simplexalerts/test_alert_6.drawio @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/simplexalerts/test_alert_6.png b/simplexalerts/test_alert_6.png new file mode 100644 index 0000000..1f14c85 Binary files /dev/null and b/simplexalerts/test_alert_6.png differ diff --git a/simplexalerts/test_alert_7.png b/simplexalerts/test_alert_7.png new file mode 100644 index 0000000..76a4851 Binary files /dev/null and b/simplexalerts/test_alert_7.png differ