A tool to monitor and notify robot log errors.
Project description
robotmonitor
Maintain datalake to monitor robot real time situation
Project Setup Instructions
Project Overview
This project aims to connect robot logs to the internet, ensuring comprehensive log management and instant error notification. The objectives include:
- Saving all logs in a NoSQL data store.
- Generating instant messages upon detecting errors.
We achieve this through four main steps:
- Configure Slack for notifications.
- Configure folder sharing from the robot to a Linux system.
- Install and configure the Elastic Stack (ELK).
- Run the Python service to handle logs and notifications.
Step-by-Step Instructions
##########################
1. Configure Slack
##########################
Slack Configuration for Notifications
This section guides you through setting up Slack to receive instant messages when errors are detected in robot logs. Follow the steps below to create and configure a Slack app, which will allow you to send notifications directly to your chosen Slack channel.
Step 1.1: Create and Configure a Slack App
-
Create a Slack App:
- Navigate to Slack API and click on "Create New App." (you need to sign in first).
- Select "From scratch," name your app, and choose the Slack workspace where notifications will be sent.
- Click "Create App."
-
Set Permissions:
- Go to "OAuth & Permissions" (left side, under Features)
- Scroll down to "Scopes" and click "Add an OAuth Scope."
- Add the following scopes to enable message sending and channel reading:
chat:writechannels:readgroups:readim:readmpim:readchannels:historyconversations.connect:readincoming-webhook
- Scroll back up to "Install to Workspace" (green) to generate and obtain the OAuth Access Token, which will be used to authenticate API requests.
- Create a configuration file named .env with the following line: SECONDS_TO_STAY_SILENCE=3 SLACK_TOKEN=xoxb-******
-
Incoming Webhook Setup (Optional) You can skip this step. It allows another method to post to slack, called webhook. Webhook is simpler, but with a limited functionality.
- In the app settings, select "Incoming Webhooks" from the sidebar.
- Toggle the activation switch to "On."
- Click "Add New Webhook to Workspace" and select the channel where you want to receive notifications.
- Copy the generated Webhook URL, which will be used in your Python script to send messages.
Step 1.2: Find Your Slack Channel ID
- Locate Channel ID:
- Open your Slack workspace in a browser.
- Navigate to the channel where notifications should appear.
- The URL will include the Channel ID at the end, e.g.,
https://app.slack.com/client/T00000000/C00000000—C00000000is your Channel ID. - Add to .env the following line: SLACK_CHANNEL_ID=C***
-
Invite the bot to the channel. Go to your Slack Channel and type the following as a message. /invite @bot-name
-
Test pip install -r requirements.txt python tests/test_slack_bot.py
##########################
2. Folder Sharing
##########################
On the Computer connected to the robot:
-
Navigate to the Logs Folder:
- Go to c:\Program Files (x86)\Hamilton\
-
Configure Sharing:
- Right-click the
Logsfolder and selectProperties. - Switch to the
Sharingtab and click onAdvanced Sharing. - Check
Share this folder. Set the share name, for instance,RobotLogs. - Click on
Permissionsand ensure that you grant 'Read' or 'Full Control' permissions, depending on the required level of access. - Confirm all settings by clicking
OK.
- Right-click the
-
Note the Network Path:
- The shared folder's network path will typically look
like
\\YOUR-PC-NAME\RobotLogs. Ensure to note this path as it will be used for mounting the folder on Ubuntu.
- The shared folder's network path will typically look
like
On Ubuntu:
-
install cifs sudo apt-get install cifs-utils
-
Create the folder for sharing sudo mkdir /var/log/shared_logs
-
Mount temporarily: Use the following command to mount the Windows shared folder to the mount point you created:
sudo mount -t cifs -o username=YOUR_WINDOWS_USERNAME,password=YOUR_WINDOWS_PASSWORD,iocharset=utf8,noperm //YOUR-PC-NAME/RobotLogs /var/log/shared_logs
-
Configure Persistent Mounting Add the following line to /etc/fstab (you can use emacs/nano/vi) //YOUR-PC-NAME/RobotLogs /var/log/shared_logs cifs username=YOUR_WINDOWS_USERNAME,password=YOUR_WINDOWS_PASSWORD,iocharset=utf8,noperm 0 0
-
remount: sudo mount -a
#######################
3. Install ELK
####################### Installtion of the ElasticSearch,Kibana,Logstash is out of the scope of this repo. You can use paid services such as https://logz.io/, https://www.elastic.co/, https://aws.amazon.com/opensearch-service/ or dare to install it yourself ! See e.g. here for the last option: https://www.digitalocean.com/community/tutorials/how-to-install-elasticsearch-logstash-and-kibana-elastic-stack-on-ubuntu-22-04
I have provided in this repo a logstash configution file scripts/logstash.conf
To load all log files into Elasticsearch. Make sure to update the user and password in the relevant section.
##############################
4. run the notifier script
############################## nohup python3 scripts/elasticsearch_error_notifier.py >> elasticsearch_error_notifier.log 2>&1 &
References
- For a comprehensive guide on Slack APIs and further configuration details, visit the Slack API Documentation.
- For specifics on message sending methods, see Sending Messages on Slack.
Note
With the above setup, your project can send real-time notifications to a Slack channel, enhancing the monitoring system's responsiveness to issues. Depending on your preference and requirement, choose between using the API for complex interactions or Webhooks for straightforward message sending.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file robotmonitor-0.1.0.tar.gz.
File metadata
- Download URL: robotmonitor-0.1.0.tar.gz
- Upload date:
- Size: 18.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56267e977295df0912b1cc3cbe98f6c8b384e9d44d514930e29bbe6471eebe59
|
|
| MD5 |
c79b54daaff7a8e2ef3147a11372e7de
|
|
| BLAKE2b-256 |
761430111002b7f5f91f5eca68790669fdfeb48b3d34e1ec7bbfaf08b0949b08
|
File details
Details for the file robotmonitor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: robotmonitor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70373068f99be921d0cfb2176d2312ed82182e302a551ff0f0250dfa1d32757d
|
|
| MD5 |
c4714c8f0990c1711749697828334e60
|
|
| BLAKE2b-256 |
5735852c7da52eb9c0c35e5634ba10a000eebc32444e1d88113dcf38b3b6a752
|