Commit Graph
2530 Commits
Author SHA1 Message Date
Huaijin 9190a9d650 feat: upgrade datafusion to 51 (#9202) 2025-11-25 23:16:09 +08:00
de5edadb9e feat: added destination type for remote destination (#9080)
Signed-off-by: Yashodhan Joshi <yjdoc2@gmail.com>
Co-authored-by: Yashodhan Joshi <yjdoc2@gmail.com>
Co-authored-by: mmosarafO2 <mosraf@openobserve.ai>
Co-authored-by: Yashodhan Joshi <yashodhan@openobserve.ai>
2025-11-25 14:07:37 +05:30
Loakesh Indiran 152218942e fix: write_results cache start & end times (#9200) 2025-11-25 13:12:02 +05:30
Loakesh IndiranandShrinath Rao 4b2cd9d69e fix: cache start and end time calc (#9268)
problem: 
```
 INFO service::search::search_stream_h2:service:search:stream_cache:handle_cache_responses_and_deltas: openobserve::service::search::streaming::cache: [HTTP2_STREAM trace_id 019aa5f8430a716d90be83e2a587baaa] Handling cache response and deltas, curr_res_size: 0, cached_search_duration: -6739886800, remaining_query_duration: 24, deltas_len: 4, cache_start_time: 1763646864583000, cache_end_time: 1763640124696200,
```

---------

Co-authored-by: Shrinath Rao <shnath@openobserve.ai>
2025-11-25 12:32:48 +05:30
Hengfei Yang 2e28f9be47 fix: use result cache env for metrics (#9281) 2025-11-25 14:14:46 +08:00
udev a5751f3c28 feat: add logic to keep the root token before camel case split (#9185) 2025-11-25 07:16:26 +08:00
Harsh Mahajan 7f9a4b7359 fix: small bug in runtime config API (#9278)
There was case in which root-password was not hidden, PR makes this go
away
2025-11-24 19:38:51 +05:30
Subhra264 b9d50d5330 fix: make triggers and error events reporting non-blocking in alert manager (#8934)
# Self-Reporting Non-Blocking Implementation

## Summary

Implements a comprehensive non-blocking architecture for the
self-reporting system to prevent indefinite blocking of alert/pipeline
handlers when queues are saturated. This enhancement improves system
stability and prevents resource exhaustion under high load while
maintaining data reliability appropriate to each data type's
criticality.

## Problem Statement

Previously, alert and pipeline handlers could block indefinitely when
publishing usage, trigger, and error data to self-reporting queues.
Under high load:
- Multiple alerts firing simultaneously caused unbounded task
accumulation
- Blocking `mpsc::Sender::send().await` would wait indefinitely for
queue space
- System could experience memory exhaustion and degraded performance
- No visibility into queue depth or dropped events

## Solution

Implemented a **priority-based non-blocking strategy** with different
behaviors for different data types:

| Data Type | Strategy | Timeout | Can Drop | Priority |
|-----------|----------|---------|----------|----------|
| **Usage** | Blocking | ∞ | No | CRITICAL (billing) |
| **Triggers** | Non-blocking | 0s | Yes | MEDIUM (metrics) |
| **Errors** | Timeout-based | 2s (configurable) | Yes (after timeout) |
HIGH (debugging) |

## Changes

### Core Functionality (Phases 1-3)

#### 1. Infrastructure (Phase 1)
- Added `try_enqueue()` - non-blocking immediate return
- Added `enqueue_with_timeout()` - bounded timeout waiting
- Added `EnqueueError` type for better error handling
- Enhanced existing `enqueue()` with timing logs

#### 2. Non-Blocking Triggers (Phase 2)
- Changed `publish_triggers_usage()` from `async fn` to `fn`
- Uses `try_enqueue()` - drops immediately if queue full
- Updated 9 call sites to remove `.await`
- Added `SELF_REPORTING_DROPPED_TRIGGERS` metric

#### 3. Timeout-Based Errors (Phase 3)
- Updated `publish_error()` to use `enqueue_with_timeout()`
- Added `ZO_ERROR_PUBLISH_TIMEOUT_SECS` config (default: 2s)
- Prevents indefinite blocking (max 2 seconds wait)
- Added `SELF_REPORTING_TIMEOUT_ERRORS` metric

### Observability (Phase 4)

Added comprehensive metrics for monitoring:
- `zo_self_reporting_dropped_triggers_total` - Counter for dropped
triggers
- `zo_self_reporting_timeout_errors_total` - Counter for error timeouts
- `zo_self_reporting_queue_depth{queue_type}` - Real-time queue depth
gauge

Queue depth tracking integrated in ingestion workers for proactive
capacity monitoring.

### Debug Logging (Bonus)

Enhanced logging throughout the system:
- Pre/post operation logs with timing information
- Context (org, key, source, status) for troubleshooting
- Slow operation detection (warns if > 100ms)
- Appropriate log levels (TRACE/DEBUG/WARN/ERROR)

### Configuration (Phase 5)

- **New**: `ZO_ERROR_PUBLISH_TIMEOUT_SECS` (default: 2)
- **Existing**: All previous config options retained
- Comprehensive configuration guide with templates for different
deployment sizes

## Files Modified

### Config Package
- `src/config/src/config.rs` - Added error timeout configuration
- `src/config/src/metrics.rs` - Added 3 new metrics
- `src/config/src/meta/self_reporting/mod.rs` - Added non-blocking
enqueue methods

### Service Package
- `src/service/self_reporting/mod.rs` - Updated publish functions with
non-blocking behavior
- `src/service/self_reporting/queues.rs` - Added queue depth tracking
- `src/service/alerts/scheduler/handlers.rs` - Updated trigger publish
call sites
- `src/service/ingestion/mod.rs` - Updated trigger publish call site

**Total**: 7 files modified, ~300 lines of code changes

## Benefits

### Stability
- ✅ No indefinite blocking - max 2 seconds for errors, immediate for
triggers
- ✅ Prevents task accumulation and memory exhaustion
- ✅ System remains responsive under extreme load
- ✅ Graceful degradation (drops non-critical data)

### Observability
- ✅ Real-time queue depth visibility
- ✅ Metrics track all drops and timeouts
- ✅ Comprehensive debug logging for troubleshooting
- ✅ Proactive monitoring (detect issues before saturation)

### Reliability
- ✅ Critical usage data unchanged (zero risk to billing)
- ✅ Acceptable data loss for non-critical data (triggers, errors)
- ✅ Configurable timeout for different environments
- ✅ Backwards compatible - existing deployments work unchanged

## Configuration

### Minimal (Use Defaults)
```bash
export ZO_USAGE_REPORTING_ENABLED=true
# All other values use sensible defaults
```

### Recommended for High Load
```bash
export ZO_USAGE_REPORTING_ENABLED=true
export ZO_USAGE_BATCH_SIZE=5000
export ZO_USAGE_REPORTING_THREAD_NUM=8
export ZO_USAGE_PUBLISH_INTERVAL=30
export ZO_ERROR_PUBLISH_TIMEOUT_SECS=3
```

## Monitoring

### Key Metrics to Watch
```promql
# Should remain at 0 in healthy system
rate(zo_self_reporting_dropped_triggers_total[5m])
rate(zo_self_reporting_timeout_errors_total[5m])

# Should be < 75% of capacity
zo_self_reporting_queue_depth{queue_type="usage"}
```

### Alerts
If metrics > 0, scale capacity:
- Increase `ZO_USAGE_BATCH_SIZE`
- Increase `ZO_USAGE_REPORTING_THREAD_NUM`

## Testing

- ✅ All unit tests pass
- ✅ Build successful (zero compilation errors)
- ✅ Backwards compatible with existing deployments
- ✅ Tested with small queues to simulate saturation
- ✅ Metrics validated via Prometheus endpoint

**Total**: ~6000+ lines of documentation

## Backwards Compatibility

✅ **Fully backwards compatible**
- All existing configuration options work unchanged
- Default values remain the same
- Existing deployments work without any changes
- Only new option: `ZO_ERROR_PUBLISH_TIMEOUT_SECS` (optional)
- Behavior change is internal (non-blocking vs blocking)

## Risk Assessment

### Low Risk ✅
- Infrastructure well-tested with existing patterns
- Only affects trigger/error publishing (non-critical for system
operation)
- Usage data unchanged (zero risk to billing/compliance)
- Can scale capacity if drops occur

### Medium Risk ⚠️
- May lose trigger metrics under extreme load (acceptable trade-off)
- May lose error data after timeout (configurable, acceptable for v1)

### Mitigation
- Comprehensive metrics track all drops/timeouts
- Clear logging with actionable messages
- Configuration guide helps operators tune capacity
- Proactive queue depth monitoring

## Future Work (v2)

After v1 runs in production for 1-2 weeks:
1. Evaluate adding timeout to usage data (currently unchanged for
safety)
2. Consider separate queue for triggers (full isolation)
3. Implement FIFO dropping for better data quality
4. Add circuit breaker pattern for automatic backoff

## Checklist

- [x] Code changes implemented
- [x] Unit tests pass
- [x] Build successful
- [x] Metrics added and registered
- [x] Debug logging added
- [x] Configuration documented
- [x] Implementation summaries written
- [x] Backwards compatibility verified
- [x] No breaking changes
2025-11-24 18:58:14 +05:30
Subhra264 5c465c1fc5 feat: add a warning about future deprecation of mysql support (#9229) 2025-11-24 16:28:05 +05:30
Subhra264andmmosarafO2 f57b1d3c05 fix: mysql migration error for alert row_template_type field (#9227)
Co-authored-by: mmosarafO2 <mosraf@openobserve.ai>
2025-11-24 14:44:54 +05:30
Hengfei Yang 5ffd64d65b feat: add configurable batch size for file list deletion (#9264) 2025-11-24 16:42:12 +08:00
Loakesh Indiran 1e7af6372a fix: add use_cache & clear_cache for _multi_search_stream (#9249) 2025-11-23 19:38:25 +05:30
udev a765af49bc feat: bill data retention (#9132)
- [x] Ingest to data_retention_usage fn
- [x] UI for data retention
2025-11-21 10:20:22 +05:30
Subhra264 de734bd5d8 feat: Allow Json values in alert row templates (#9137)
# Add Row Template Type Support for Alerts

## Overview
This PR adds support for configurable row template types in alerts,
allowing users to choose between **String** and **JSON** formats for row
templates. This provides flexibility in how alert data is formatted and
sent to destinations.

## Features

### Row Template Type Selection
- Added a new `row_template_type` field to alerts with two options:
- **String**: Traditional string-based templates with variable
interpolation
  - **JSON**: Structured JSON templates for programmatic consumption

### Database Layer
- Uses efficient `smallint` (i16) storage: `0` for String, `1` for JSON
- Added migration `m20251118_000001_add_alert_row_template_type` with
backward compatibility (defaults to String)
- Includes support for PostgreSQL, MySQL, and SQLite

### API Layer
- Returns enum string representation (`"String"` or `"Json"`) in API
responses
- Full support in GET, CREATE, and UPDATE alert endpoints

### UI Changes
- Added toggle button in alert creation/editing form to switch between
String and JSON template types
- Dynamic placeholder text based on selected template type
- Persists user's template type selection in the database

## Usage Example

### String Template (Default)
When creating an alert with row template type set to **String**:

```
Template Type: [String] JSON
Row Template: Alert triggered: {alert_name} at {timestamp} Affected user: {user_id} Error count: {error_count}
```

### JSON Template
When creating an alert with row template type set to **JSON**:

```
Template Type: String [JSON]
Row Template: { "alert": "{alert_name}", "timestamp": "{timestamp}", "user": { "id": "{user_id}", "name": "{user_name}" }, "metrics": { "error_count": {error_count}, "severity": "{severity}" } }
```

The JSON template type automatically parses and validates JSON
structure, making it ideal for:
- Webhook integrations that expect JSON payloads
- Structured logging systems
- API endpoints requiring specific JSON schemas
- Downstream systems that need programmatic access to alert data

## Technical Details

### Architecture
- **Database**: Stores as `smallint` (0 or 1) for efficiency
- **Service Layer**: Uses `RowTemplateType` enum throughout application
logic
- **API**: Serializes enum as strings (`"String"`, `"Json"`)
- **Frontend**: TypeScript interface uses string type with toggle UI
component

### Backward Compatibility
- Existing alerts without `row_template_type` default to `String`
- Migration adds column with `DEFAULT 0` ensuring zero downtime
- API handles both old and new alert formats seamlessly

## Testing
- Added unit tests for database migration (PostgreSQL, MySQL, SQLite)
- Tested enum serialization/deserialization
- Verified UI toggle behavior and data persistence
- Confirmed backward compatibility with existing alerts

<img width="1070" height="770" alt="Screenshot 2025-11-19 at 5 46 34 PM"
src="https://github.com/user-attachments/assets/900edb1c-815e-4240-91e2-50a1a582a9b0"
/>
2025-11-20 14:44:08 +05:30
Hengfei Yang f3f5b29aa2 feat: introduce query_values_default_num configuration. (#9206)
This PR add a new ENV that allow you to change the default num of field
values.
```
ZO_QUERY_VALUES_DEFAULT_NUM=10
```
2025-11-20 16:25:12 +08:00
HuaijinandHengfei Yang 5e8b32f0e1 fix: tantivy distinct not work for alias (#9187)
Co-authored-by: Hengfei Yang <hengfei.yang@gmail.com>
2025-11-20 11:22:32 +08:00
Hengfei Yang 51a0980323 feat: [BE] PromQL streaming output support (#9191) 2025-11-20 10:30:55 +08:00
Sai Nikhil f98183787f fix: mainlayout page refactoring (#9176)
1. we have created header component which will seperate out the header
part from mainlayout
2. introduced custom dark logo feature , it will fallback to light mode
logo if dark mode logo is not there
2025-11-19 15:48:35 +05:30
Harsh Mahajan ab260764b3 feat:adding config api (#9160) 2025-11-19 14:59:18 +08:00
Harsh Mahajan 1f06d4a46a feat:adding configuration ENV for colour theme (#9165) 2025-11-19 14:23:09 +08:00
ByteBaker 84aa3902db feat: move graceful drain to enterprise
Moves all graceful shutdown logic from PR #8876 to enterprise repository.
2025-11-19 10:10:56 +05:30
ByteBaker 2c75a4fea9 fix: broken tests from #9009
https://github.com/openobserve/openobserve/pull/9009
broke a few tests by introducing a new param in a function.

Fixed those as well as a few clippy issues.
2025-11-19 09:27:48 +05:30
sktrpathiandAshish Kolhe ee28cab80b fix: prevent triggers stream schema divergence across organizations (#9163)
When `ZO_USAGE_REPORT_TO_OWN_ORG` is enabled (default: true), triggers
are written to both _meta and originating orgs. This caused schema
divergence where some orgs missing fields like 'error', breaking
dashboard queries.

Add ensure_triggers_stream_schema() to auto-sync missing TriggerData
fields before ingestion. Runs once per stream, logs missing fields, and
updates defined_schema_fields gracefully without blocking ingestion.

Fixes queries like: SELECT error FROM triggers WHERE status='failed'

---------

Co-authored-by: Ashish Kolhe <ashish.j.kolhe@gmail.com>
2025-11-18 14:53:18 +05:30
Ashish Kolhe 9059afdb2b feat: sso claim parser (#9156) 2025-11-18 13:30:44 +05:30
Hengfei Yang 8aeff17410 fix: remove no need middleware for actix-web (#9167) 2025-11-18 08:44:01 +08:00
Loakesh Indiran ee3bc9c11c perf: cache aware partition generation for streaming aggs (#9009) 2025-11-17 22:32:05 +05:30
Huaijin dc2cdcbf0b perf: improve data load and code clean up (#9150) 2025-11-17 21:47:59 +08:00
Simha G 6ca371ec99 fix: Concurrency control for file locking has multiple anti-concurrent design patterns in the way (#8523) 2025-11-17 20:35:43 +08:00
ByteBaker 187cdd72f4 fix: make WAL_DIR_DEFAULT_PREFIX pub
https://github.com/openobserve/openobserve/pull/8876 had made
this variable private, resulting in failed enterprise builds.

It also removed one of the imports causing build failure.

This commit reverts those specific changes.
2025-11-17 12:22:29 +05:30
ByteBaker d8e8e27661 fix: address code review feedback on graceful drain API
- Fix panic on path canonicalization in check_has_pending_files()
- Implement proper recursive directory checking for parquet files
- Add exponential backoff to draining loop (50ms -> 1s)
- Validate query parameter strictly in enable endpoint to prevent accidental node disablement

These changes address critical robustness issues identified in the code review:
1. Prevents potential panics during shutdown when WAL path is missing
2. Ensures correct pending file detection instead of assuming all subdirectories have files
3. Reduces CPU usage during drain with exponential backoff
4. Prevents unintentional node disablement from invalid/missing parameters
2025-11-17 05:45:44 +05:30
ByteBaker 2bbb915862 feat: add graceful drain API for Kubernetes autoscaling
Implements cloud-agnostic graceful shutdown mechanism to support
Kubernetes preStop hooks and other orchestration platforms.

Changes:
- Add IS_INGESTER_DRAINING global flag with atomic operations
- Enhance /enable?value=false to trigger flush and set draining mode
- Add /drain_status endpoint to monitor shutdown readiness
- Modify parquet upload job to prioritize draining mode
- Exit upload loop when all files are uploaded to S3

API Usage:
- PUT /node/enable?value=false - Initiates drain (flushes memory, sets flag)
- GET /node/drain_status - Returns readyForShutdown status

Benefits:
- Eliminates fixed 900s wait in Helm charts
- Cloud-agnostic (works with K8s, ECS, Docker Swarm, systemd)
- Data-safe: ensures all WAL files uploaded before shutdown
2025-11-17 05:45:44 +05:30
Hengfei Yang f597793de6 fix: deadlock of usage report (#9149)
There is a potential deadlock of usage report, it will resend to queue
when ingest failed. but if the queue is full, the resend will block and
waiting consume, but the consumer is itself, then it deadlock.
2025-11-16 16:56:13 +08:00
Hengfei Yang b950b1cec1 fix: debug metrics stream keep update (#9141)
I saw a lot of logs like this:

```
DEBUG openobserve::service::db::schema: [Schema:watch] Received event: Put(EventData { key: "/schema/default/metrics/http_server_duration", value: Some(b""), start_dt: None
```

This PR optimized the metadata check logic also try to debug this case.
2025-11-15 23:40:51 +08:00
Hengfei YangandHuaijin 7528b024e7 perf: drop the data early for ingestion (#9124)
Same test, reduce 1GB memory compare to before.

---------

Co-authored-by: Huaijin <haohuaijin@gmail.com>
2025-11-15 17:22:41 +08:00
Harsh Mahajan c84d7f52d6 chore: error handling for check_schema in metric and traces (#9130) 2025-11-15 15:50:02 +08:00
Harsh Mahajan 31a4206062 feat: adding alert worker group (#9055)
resolves https://github.com/openobserve/openobserve/issues/8991

### Summary

- Introduces `is_background()` method in `SearchEventType`.  
- Identifies **Alerts**, **Reports**, and **DerivedStreams** as
background tasks.
- Routes these tasks to a dedicated **`BACKGROUND`** work group.
2025-11-15 15:12:59 +08:00
ByteBaker bb37f8f1af feat: add comprehensive service graph visualization with tree/graph views
Backend:
- Add `stream_name` parameter to service graph query API for multi-stream filtering
- Pass `stream_name` through `handle_otlp_request` to service graph tracking
- Filter Prometheus metrics by both `org_id` and optional `stream_name`
- Update API documentation with stream filtering examples

Frontend:
- Add tree view and graph view visualization modes with toggle
- Implement tree layouts: horizontal, vertical, and radial
- Implement graph layouts: force-directed and circular
- Add stream selector dropdown to filter metrics by trace stream
- Add auto-refresh toggle with configurable interval (5-300 seconds)
- Refactor graph rendering to use `ChartRenderer` component with ECharts
- Implement D3-force physics simulation for force-directed layout
- Add `convertServiceGraphToTree` and `convertServiceGraphToNetwork` utilities
- Preserve node positions during graph updates to prevent re-layout jitter
- Use incremental updates (`notMerge: false`) for stable graph view
- Store user preferences (visualization type, layout, stream filter) in localStorage
- Update `ChartRenderer` to respect `notMerge` and `lazyUpdate` flags from props

Dependencies:
- Add `d3-force` for force-directed graph layout calculations
- Add `@types/d3-force` for TypeScript support
- Add `d3-quadtree` for spatial indexing in force simulation
2025-11-14 16:19:04 +05:30
Sai Nikhil 803434bd30 fix: theme customization (#9077) 2025-11-14 11:55:50 +05:30
udev bc26231c12 fix: stream stats sleep after job done (#9018) 2025-11-13 21:19:40 +08:00
Huaijin a634b91aed perf: improve promql topk, bottomk, count_values and some code cleanup (#9096) 2025-11-13 20:52:50 +08:00
Zhao.wei 46c2f6afe3 feat: improve ingestion (#9069) 2025-11-13 20:20:04 +08:00
Subhra264 5004be110c fix: put a limit on the keep alive timeout for scheduled jobs (#9092)
Currently in the alert manager, we run a keep alive thread for every
scheduled job pulled, so that if the timeout for the job is near and the
job is still in progress, we can increase the timeout a bit so that the
job can complete. But in edge cases, if the job itself is complete, but
the keep-alive thread is still not stopped, it will keep running the
keep alive thread forever.

Hence, a limit is added to the keep alive thread, so that it stops after
the timeout.
2025-11-13 10:11:52 +05:30
Hengfei Yang 561ddd3b4d fix: add some debug logs for query slow (#9072) 2025-11-12 22:34:18 +08:00
Simha Gandsai nikhil kethe e92f385751 feat: Alert and Pipeline History columns are now sortable (#9052)
# PR Type
Enhancement

# Description
The columns in the Alerts and Pipelines History are augmented to be
sortable. The backend endpoint is updated accordingly too.

---------

Co-authored-by: sai nikhil kethe <nikhil@openobserve.ai>
2025-11-12 19:03:47 +05:30
Hengfei Yang df43cf0d66 perf: improve load data for metrics (#9070) 2025-11-12 19:08:54 +08:00
ByteBaker d0cf8d3fc3 chore: utilize with_capacity in collections + cleanup 2025-11-12 14:18:01 +05:30
Hengfei Yang b48a72dbc2 fix: search wal on windows (#9054) 2025-11-12 09:25:10 +08:00
udev a5b9facdc8 fix: migration issue (#9067)
fixes migration issue where older format pipeline would fail to load if
the pipeline contains a `condition` node.
2025-11-11 23:20:23 +05:30
udev 2854a33791 feat: pipeline or operator (#8911)
with this PR we add OR operator support in pipeline conditions along
with the ability to nest conditions, creating complex conditions
quickly. existing conditions will be treated as legacy conditions and
still be honoured in the new evaluation logic.
2025-11-11 17:39:11 +05:30
Subhra264 2dc0527d43 fix: alert_trigger_time should use the timestamp when it was triggered (#9045) 2025-11-11 16:35:11 +05:30