* WIP: alarms service * fix(alarms): remove rule entity since it is not stored here Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * test(alarms): add tests cases for invalid alarms * feat(alarms): add authorization * feat(alarms): add docker deployment files Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * fix: update go mod file * feat(alarms): support filtering by resolved_by, updated_by and severity Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * style: fix linter errors Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * fix(alarms): provide correct otel naming for create alarm Fixes https://github.com/absmach/magistrala/pull/106#discussion_r2030151971 Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * fix(alarms): group routes appropriately Resolves https://github.com/absmach/magistrala/pull/106#discussion_r2030160891 Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * fix(alarms): extract alarm id from url path rather than query params Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * fix(alarms): add all status to help in decoding Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * style(alarms): maintain consistent import as naming for supermq api package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * refactor(alarms): update supermq dependecy to the latest Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * fix(alarms): Add domains gRPC service config to alarms service Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * test(alarms): all CRUD operations from the service Return empty results instead of nil This standardizes error responses across alarm endpoints to return empty result structs rather than nil. Also renames entityReq to alarmReq and adds HTTP status codes for created/deleted alarms. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * test(alarms): fix failing tests due to introduction of context on sdk Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * fix(alarms): remove channel id Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * fix(alarms): standardize error handling across CRUD operations Updated error responses to use specific repository errors for consistency Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * feat(alarms): add assignment fields to Alarm model and database Introduced AssignedAt and AssignedBy fields to the Alarm struct and updated the database schema accordingly. Enhanced the UpdateAlarm function to handle these new fields, ensuring proper assignment tracking in the alarms system. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * feat(alarms): enhance Alarm model with measurement attributes Updated the Alarm struct to include Measurement, Value, Unit, and Cause fields. Modified the validation logic to ensure these fields are present. Adjusted logging and tracing middleware to reflect the new attributes. Updated database schema and related functions to accommodate these changes, ensuring comprehensive alarm data management. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * feat(alarms): consume events from pubsub for creation of alarms Removed session dependencies from CreateAlarm method and enhanced alarm validation to ensure all required fields are present Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * style(alarms): add newline at the end of docker compose Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * fix(alarms): Add assignee id and metadata fields when consuming messages Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * feat(alarms): add acknowledged field Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * feat(alarms): Add threshold value for the specific measurement Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * feat(alarms): Add channel, thing, and subtopic fields to Alarm model This change adds required fields for tracking alarm sources and reorganizes alarm-related fields for better grouping. Alarms now track the channel, thing, and subtopic that triggered them, along with domain and rule info. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * test(alarms): add service layer tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * fix(alarms): consume created at from message rather than creating it Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * feat(alarms): ready alarm as a gob encoded object Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * fix(alarms): read alarms from alarms queue and remove transformer g Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * feat(alarms): update version of supermq Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * feat(alarms): add gob transformer Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * fix(alarms): rename thing id to client id Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * fix(alarms): create alarms stream Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * fix(alarms): check on logic to create new alarm create new alarm if severity, status, subtopic changes enhance logging with additional details for alarms management Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * remove conusmer and use pubsub Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * fix(alarms): use build tags for rabbitmq and nats * fix(alarms): add health and metrics endpoint * fix(magistrala): use supermq as build flags to see version and commit * fix(alarms): use js config * fix(alarms): remove validation when updating an alarm fix authorization too --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
Magistrala
A Modern IoT Platform Built on SuperMQ
Scalable • Secure • Open-Source
Guide | Contributing | Website | Chat
Made with ❤️ by Abstract Machines
Introduction 🌍
Magistrala is a cutting-edge, open-source IoT cloud platform built on top of SuperMQ. It serves as a robust middleware solution for building complex IoT applications. With Magistrala, you can connect and manage IoT devices seamlessly using multi-protocol support, all while ensuring security and scalability.
Key Benefits:
- Unified IoT Management: Connect sensors, actuators, and applications over various network protocols.
- Scalability and Performance: Designed to handle enterprise-grade IoT deployments.
- Secure by Design: Features such as mutual TLS authentication and fine-grained access control.
- Open-Source Freedom: Patent-free, community-driven, and designed for extensibility.
✨ Features
- 🏢 Multi-Tenancy: Support for managing multiple independent domains seamlessly.
- 👥 Multi-User Platform: Unlimited organizational hierarchies and user roles for streamlined collaboration.
- 🌐 Multi-Protocol Connectivity: HTTP, MQTT, WebSocket, CoAP, and more (see contrib repository for LoRa and OPC UA).
- 💻 Device Management and Provisioning: Including Zero-Touch provisioning for seamless device onboarding.
- 🛡️ Mutual TLS Authentication (mTLS): Secure communication using X.509 certificates.
- 📜 Fine-Grained Access Control: Support for ABAC and RBAC policies.
- 💾 Message Persistence: Timescale and PostgreSQL support (see contrib repository for Cassandra, InfluxDB, and MongoDB).
- 🔄 Rules Engine (RE): Automate processes with flexible rules for decision-making.
- 🚨 Alarms and Triggers: Immediate notifications for critical IoT events.
- 📅 Scheduled Actions: Plan and execute tasks at predefined times.
- 📝 Audit Logs: Maintain a detailed history of platform activities for compliance and debugging.
- 📊 Platform Logging and Instrumentation: Integrated with Prometheus and OpenTelemetry.
- ⚡ Event Sourcing: Streamlined architecture for real-time IoT event processing.
- 🐳 Container-Based Deployment: Fully compatible with Docker and Kubernetes.
- 🌍 Edge and IoT Ready: Agent and Export services for managing remote IoT gateways.
- 🛠️ Developer Tools: Comprehensive SDK and CLI for efficient development.
- 🏗️ Domain-Driven Design: High-quality codebase and extensive test coverage.
🔧 Install
Clone the repository and start the services:
git clone https://github.com/absmach/magistrala.git
cd magistrala
docker compose -f docker/docker-compose.yaml --env-file docker/.env up
Alternatively, use the Makefile for a simpler command:
make run args=-d
📤 Usage
Using the CLI:
Check the health of a specific service using the CLI:
make cli
./build/cli health <service>
Replace <service> with the name of the service you want to check.
Using Curl:
Alternatively, use a simple HTTP GET request to check the platform's health:
curl -X GET http://localhost:8080/health
For additional usage examples and advanced configurations, visit the official documentation.
📚 Documentation
Complete documentation is available at the Magistrala official docs page.
For CLI usage details, visit the CLI Documentation.
🌐 Community and Contributing
Join the community and contribute to the future of IoT middleware:
📜 License
Magistrala is open-source software licensed under the Apache-2.0 license. Contributions are welcome and encouraged!
💼 Professional Support
Need help deploying Magistrala or integrating it into your systems? Contact Abstract Machines for expert guidance and support.