Conversation
Signed-off-by: Daniel Gerlag <daniel@gerlag.ca>
examples/lib/loki/grafana/provisioning/datasources/loki.yaml
Dismissed
Show dismissed
Hide dismissed
There was a problem hiding this comment.
Pull request overview
This PR adds a new Loki reaction component to the Drasi project, enabling continuous query results to be pushed to Grafana Loki for observability and monitoring. The implementation includes a complete builder API, configuration types, template-based log rendering, and a fully-featured example application with a pre-configured Grafana dashboard.
Changes:
- Added
drasi-reaction-lokicrate with builder pattern API, supporting per-query/default Handlebars templates for ADD/UPDATE/DELETE events, dynamic labels, and authentication (Bearer token, Basic auth, X-Scope-OrgID) - Implemented integration tests using testcontainers with Loki 3.4.3 to verify end-to-end push/query behavior
- Created comprehensive example stack (
examples/lib/loki/) with Docker Compose orchestration, provisioned Grafana dashboard demonstrating persistent hot sensor alerts and temperature history visualization
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
components/reactions/loki/src/loki.rs |
Core LokiReaction implementation with template rendering, label handling, and HTTP push logic |
components/reactions/loki/src/lib.rs |
Public API with LokiReactionBuilder fluent interface |
components/reactions/loki/src/config.rs |
Configuration types (LokiReactionConfig, BasicAuth, QueryConfig, TemplateSpec) |
components/reactions/loki/Cargo.toml |
Package manifest with dependencies (handlebars, reqwest, chrono, testcontainers) |
components/reactions/loki/tests/loki_integration_tests.rs |
Integration test verifying INSERT/UPDATE/DELETE event flow |
components/reactions/loki/tests/loki_helpers.rs |
Test utilities for Loki container setup and query verification |
components/reactions/loki/README.md |
Component documentation with usage examples and configuration reference |
components/reactions/loki/CHANGELOG.md |
Version 0.1.0 changelog |
components/reactions/loki/Makefile |
Build, test, integration-test, and lint targets |
examples/lib/loki/main.rs |
Example app demonstrating MockSource → Query → Loki reaction pipeline |
examples/lib/loki/docker-compose.yml |
Loki + Grafana stack orchestration |
examples/lib/loki/grafana/dashboards/drasi-loki-overview.json |
Pre-configured dashboard with HOT/COLD stat panels and temperature timeseries |
examples/lib/loki/grafana/provisioning/datasources/loki.yaml |
Loki datasource provisioning |
examples/lib/loki/grafana/provisioning/dashboards/provider.yaml |
Dashboard provider configuration |
examples/lib/loki/bootstrap_data.jsonl |
Initial sensor data for example |
examples/lib/loki/README.md |
Example documentation with LogQL query patterns |
examples/lib/loki/run.sh |
Helper script to launch stack and example |
examples/lib/loki/Makefile |
Example build targets |
examples/lib/loki/Cargo.toml |
Example dependencies |
Cargo.toml |
Added loki crate to workspace members |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,32 @@ | |||
| [package] | |||
There was a problem hiding this comment.
The Cargo.toml file is missing the copyright header that is present in other reaction Cargo.toml files throughout the codebase (e.g., components/reactions/http/Cargo.toml). For consistency with the codebase convention, add the Apache 2.0 copyright header at the beginning of this file.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
I have added a 'do not merge' label to this. We need to wait until the dynamic plugin PR is merged and then update this. |
Signed-off-by: Daniel Gerlag <daniel@gerlag.ca>
Add detailed logging throughout the Loki reaction plugin: - descriptor.rs: log reaction creation with config summary - loki.rs: log lifecycle events, result processing, template rendering, stream batching, HTTP push results, and shutdown All messages prefixed with [reaction_id] where possible. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
This PR adds a new Loki reaction for Drasi and a complete local Loki + Grafana example stack demonstrating
end-to-end continuous query observability.
What’s Included
New reaction crate:
drasi-reaction-lokicomponents/reactions/loki/with:with_query,with_queries, endpoint/auth/labels/templates options)LokiReactionConfig,QueryConfig,TemplateSpec,BasicAuth)/loki/api/v1/push)Testing
Example app + dashboard stack
examples/lib/loki/with:persistent-hot-sensorsquery:WHERE drasi.trueFor(s.temperature > 24, duration({ seconds: 5 }))all-sensorsquery for full temperature historypersistent-hot-sensorsall-sensors