-
Notifications
You must be signed in to change notification settings - Fork 50
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
feat(microservices): add LiDAR, Weight, Peripheral Analytics, and Grafana integration #655
Conversation
…Kafka/HTTP publishing - Implement Python microservice to ingest real or mock Lidar data - Publish sensor data to MQTT, Kafka, or HTTP (controlled by environment vars) - Add logging, retry logic, and graceful shutdown handling - Integrate with existing Makefile and Docker Compose Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
…DAR and weight data - Subscribes to LiDAR and weight sensor MQTT topics - Performs analytics to calculate item density (weight per LiDAR point) - Publishes analytics results to a dedicated MQTT topic () - Includes robust logging and error handling Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
- Introduced Grafana container configuration in docker-compose.yml - Configured Grafana to depend on mqtt-broker_1 Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
Can you please update the title of your PR with a conventional commit style message? |
@naman-ranka can you fix the security issues flagged by github-advanced-security bot. Also please follow the git conventional commit format for the PR title -
type here should be feat. |
Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
- Added required copyright header to newly created Python files. - Ensures compliance with repository licensing guidelines. Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@naman-ranka From the Design, app.py, Dockerfile and requirements.txt look the same for all 3 services. What is the difference between app.py in each of these services ? Can you consolidate all into one service then ? Looks like only sensor data type is changing here. Are you adding any business logic to any of them to make them unique ? Why duplicate ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@naman-ranka I was able to run your app, but I had to make so many changes in the docker-compose specifically mqtt and all the networks so the services can communicate with each other. Also, you can create a dashboard template to show the data for demo purposes.
…blisher logic - Consolidated sensor-specific directories into a single common-sources directory - Implemented a common publisher.py to streamline all types of publishing (MQTT, Kafka, HTTP) across sensor types - Added support for multiple sensors of the same type to improve scalability - Introduced a custom MQTT Docker configuration to resolve previous network configuration issues - Removed redundant directories to simplify the codebase Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
- Introduced Grafana container configuration in docker-compose.yml - Configured Grafana to depend on mqtt-broker_1 Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
- Added required copyright header to newly created Python files. - Ensures compliance with repository licensing guidelines. Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
…blisher logic - Consolidated sensor-specific directories into a single common-sources directory - Implemented a common publisher.py to streamline all types of publishing (MQTT, Kafka, HTTP) across sensor types - Added support for multiple sensors of the same type to improve scalability - Introduced a custom MQTT Docker configuration to resolve previous network configuration issues - Removed redundant directories to simplify the codebase Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
- Integrated a Grafana dashboard to visualize and analyze data from LiDAR and weight sensors. - Configured dashboard panels to display time series, sensor counts, and analytics metrics. - Dashboard pulls data from our existing MQTT data source for real-time insights. Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
- Implemented Grafana datasource provisioning via YAML to auto-load the MQTT datasource. - Updated dashboard.json to improve data visualization and remove manual refresh requirement. - Note: Datasource URL still needs to be manually set due to Grafana's provisioning limitations. Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
- Added to test HTTP publishing inside . - Updated to expose port 5000 for internal HTTP testing. - Verified HTTP publishing via Webhook.site without modifying . Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
…tion - Updated Kafka Docker configuration for improved stability and compatibility. - Added to verify message consumption from any user-defined topic. - Supports command-line arguments for dynamic topic selection and timeout configuration. - Ensures Kafka messages are received correctly and provides meaningful test results. Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
- Added a README file inside the common-service directory. - Includes details on setup, environment variables, and testing procedures. Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
Replaced COPY commands with volumes in docker-compose.yml Allows dynamic updates to dashboards and datasources without rebuilding the image Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
… image Replaced custom-built Mosquitto image with the official eclipse-mosquitto:2.0.18. Mounted mosquitto.conf as a volume to allow dynamic updates without rebuilding. Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
Co-authored-by: NeethuES <[email protected]>
Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
Co-authored-by: ejlee-intel <[email protected]>
…t into I-537 merge divergent branches
Signed-off-by: Naman Yeshwanth Kumar <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job getting the PR comments closed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - Nice work!
Introduces a single
common-service
for managing both LiDAR and Weight sensors, configurable through environment variables for MQTT, Kafka, and HTTP publishing. Integrates Grafana (with a pre-loaded dashboard and data source) for real-time visualization over MQTT.Closes #537
PR Checklist
What are you changing?
This PR introduces the following features:
1. Overview
LiDAR & Weight Sensors handled within one container (
common-service
).Each sensor has its own configuration (e.g., sensor ID, port, mock mode).
Publishes data to one or more protocols:
MQTT (e.g., broker host, port, topic)
Kafka (e.g., bootstrap server, topic)
HTTP (e.g., URL endpoint)
Uses a shared framework (
publisher.py
&config.py
) plus two apps (lidar_app.py
,weight_app.py
).Fully controlled via Fully controlled via
docker-compose.yml
.Example snippet for LiDAR (2 sensors) & Weight (2 sensors):
Change
true/false
to enable or disable each protocol.Adjust intervals, logging levels, or sensor counts as needed.
Included in the
docker-compose.yml
file.By default, Kafka listens on
PLAINTEXT://:9093
.mqtt-broker_1:1883
.Preloaded Dashboard : Sensor-Analytics.
Datasource Provisioning : An MQTT data source is set up (may require manual URI update in Grafana’s Data Sources if the hostname differs).
Issue this PR will close
close: #537
(Build a microservice to get sensor details from a Lidar sensor).
Test Instructions :
Run the Demo
A. MQTT (via Grafana)
Go to http://localhost:3000
Default Credentials :
admin
/admin
Look for Sensor-Analytics in the Dashboards list.
Panels should be configured for:
lidar/data
weight/data
If you see no data:
Go to Configuration > Data Sources and confirm the MQTT data source URI is set to
tcp://mqtt-broker_1:1883
ortcp://mqtt-broker:1883
(depending on your Docker network name).Click Test to ensure it connects.
You should see sensor data updating in each panel.
Adjust the refresh interval (top-right in Grafana) if needed.
B. Kafka Publishing
docker-compose.yml
, set:docker exec asc_common_service python kafka_publisher_test.py --topic lidar-data
This script subscribes to the
lidar-data
topic.Verify it prints incoming LiDAR messages published to Kafka.
C. HTTP Publishing
This feature can be verified in two ways :
Local HTTP Test (Inside Docker)
docker-compose.yml
, set:common-service
container:docker exec asc_common_service python http_publisher_test.py
common-service
will print the received LiDAR data, confirming that HTTP publishing is working.Webhook.site for External Validation
Go to Webhook.site and generate a unique URL.
Set
LIDAR_HTTP_URL
indocker-compose.yml
to that URL, for example:4. Additional Notes
Mock Mode : If you set
LIDAR_MOCK_1
orWEIGHT_MOCK_1
to"true"
, the service publishes randomized demo data instead of reading from hardware.Multi-Sensor Support :
LIDAR_COUNT
andWEIGHT_COUNT
define how many sensors to handle. Each has its own environment variables (e.g.,LIDAR_SENSOR_ID_1
,LIDAR_PORT_1
, etc.).Topic & Interval Config : The publish interval can be tuned (e.g.,
LIDAR_PUBLISH_INTERVAL
,WEIGHT_PUBLISH_INTERVAL
), and each sensor’s MQTT/Kafka topic is customizable.