Commit Graph
1666 Commits
Author SHA1 Message Date
Hengfei Yang 0d2e183739 perf: keep improve metrics performance (#5729) 2025-01-22 08:16:31 +08:00
Hengfei Yang 1117c871e4 perf: keep improve metrics performance (#5758) 2025-01-21 21:36:16 +08:00
Subhra264 87eb72ff19 fix: run upto the populate_alerts_table migration first (#5755)
This is a hack to fix #5740 . As mentioned in
https://github.com/openobserve/openobserve/pull/5752, with postgresql
there is an issue when upgrading from v0.14.0 to v0.14.1 or v0.14.2 -
The migration `m20250109_092400_recreate_tables_with_ksuids` fails with
an error message. So after testing, it looks like the earlier mentioned
migration requires the `m20241209_120000_create_alerts_table` migration
to be committed to db first (so upto
`m20241217_155000_populate_alerts_table` migration).

Earlier https://github.com/openobserve/openobserve/pull/5722 was used to
address the issue, but unfortunately it works when upgrading from below
`v0.14.0` to `v0.14.2`. Currently the way to upgrade to v0.14.2 from
v0.14.0 with postgresql is to first upgrade from `v0.14.0` to
`v0.14.1-rc1` and then to `v0.14.2`.

This PR should make the direct upgrade from v0.14.0 to v0.14.3 possible
with postgresql.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Bug Fixes**
- Improved migration process for alerts table to ensure correct index
selection and prevent potential migration failures.

- **Documentation**
- Enhanced comments to provide clearer context about migration logic and
order of execution.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-01-21 19:04:22 +05:30
Huaijin cb33b25331 chore: make search job message better (#5741) 2025-01-20 22:16:19 +08:00
Loakesh Indiran 2809ab571b fix: ws path proxy (#5746)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Improved WebSocket URL conversion logic to ensure more accurate URL
handling in proxy scenarios.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-01-20 16:19:50 +05:30
Taiming Liu 57fa94cc5b feat: enable trace ingestion for scheduled pipeline (#5672)
fix: #5522 

- [x] trace ingestion for scheduled pipelines
- [x] pause/unpause for scheduled pipelines
- [x] new trace ingestion handler that accepts json
2025-01-20 14:29:33 +08:00
Hengfei Yang a2d538c449 fix: tls with router (#5739) 2025-01-19 22:09:24 +08:00
Hengfei Yang 00fb627c32 fix: use http domain for tls inner communication (#5735) 2025-01-18 12:05:25 +08:00
Subhra264 e8f7cf33d7 fix: update error message for folder duplicate name error (#5732)
Currently, the backend returns a raw database internal server error
(500) when updating or creating a folder with a name that already exists
in the same organization. This pr avoids exposing the raw database error
to the api and instead returns a 400 bad request error.

Addresses #5723 

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced folder management with prevention of duplicate folder names
within an organization
- **Bug Fixes**
- Added validation to prevent creating folders with names that already
exist
- **Improvements**
	- Improved error handling for folder creation and update scenarios
	- More descriptive error messages for folder-related operations

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-01-17 22:14:28 +05:30
Patrick Sullivan ebf527b9fc fix: Non-random KSUIDs from hashes in folder, dashboard, and alert migrations (#5726)
### Summary

This PR updates the logic that is used to generate KSUID primary keys
for the `folders`, `dashboards`, and `alerts` tables in existing
migrations which transform data from the `meta` table into the
`folders`, `dashboards`, and `alerts` tables.

The new logic generates 160-bit "KSUIDs" which are actually 160-bit
SHA-1 hashes of the records being transformed rather than being truly
random KSUIDs.

### Motivation

In the existing implementation, the migrations generate random KSUIDs
for the records that are transformed from the `meta` table and into the
different `folders`, `dashboards`, and `alerts` tables. When running the
application in a single cluster this is acceptable behavior.

However when running the application in a multi-cluster environment this
causes problems. In a multi-cluster environment, each cluster will have
it's own copy of the application database, and each database should
contain the exact same data in the `meta` table. When we run the
migration scripts in each cluster, the data from the `meta` table will
be transformed into the `folders`, `dashboards`, and `alerts` tables.
However if the migration generates a random KSUID for each new record
inserted into those new tables, then different clusters will each
generate different KSUID `id`s for rows in the `folders`, `dashboards`,
and `alerts` tables which should actually have the same `id`s.

Our solution to this problem is that during the migration from the
`meta` table to the `folders`, `dashboards`, and `alerts` tables, rather
than generating random 160-bit KSUID `id`s for the new records, we
generate 160-bit SHA-1 hashes for each record and we use that SHA-1 hash
as the `id` of the each new record. This ensure that each record that is
transformed from the `meta` table will have an `id` in the `folders`,
`alerts`, or `dashboards` tables that is consistent across all clusters.

Newly generated records (ie, records generated AFTER the migration) in
the `folders`, `alerts`, and `dashboards` tables will continue to be
generated with random KSUID `id`s since these `id`s can be shared with
other clusters via NATS super-cluster events and then records with those
`id`s can be inserted into databases in other clusters, ensuring that
records have consistent `id`s across clusters.

### Notes about KSUID generation

To generate a KSUID this function generates the 160-bit SHA-1 hash of
the alert's `org`, `stream_type`, `stream_name`, and `name` and
interprets that 160-bit hash as a 160-bit KSUID. Therefore two KSUIDs
generated in this manner will always be equal if the alerts have the
same `org`, `stream_type`, `stream_name`, and `name`.

⚠️ It is important to note that although KSUIDs generated in this manner
can be parsed as KSUIDs since they are 160-bit values, the KSUIDs
generated in this manner will have timestamp bits which are effectively
random, meaning that the timestamp in any KSUID generated with this
function will be random. This will render the timestamp-sortability
property of these KSUIDs useless. This probably isn't a big deal since
we can always add and sort by a `created_at` column if we want to, but
we should be aware of this limitation.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added SHA-1 hashing dependency to generate unique identifiers (KSUIDs)
for alerts, folders, and dashboards.
	- Implemented KSUID generation based on specific entity attributes.

- **Refactor**
- Transitioned database tables from integer-based to KSUID-based primary
keys.
	- Updated `StreamType` enum to support more flexible usage.

- **Chores**
	- Updated project dependencies to include SHA-1 hashing library.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-01-17 09:56:47 +05:30
Taiming Liu 43967569e6 fix: check super_cluster_enabled before syncing (#5727) 2025-01-16 13:52:37 -08:00
Ashish Kolhe 6777d810cb fix: failing migration for releases before 0.14.1 (#5722)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Added a targeted migration step to resolve an issue with alerts
migration
- Implemented a temporary workaround to ensure successful database
migration process

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-01-16 16:40:41 +05:30
Hengfei Yang fea08d8f75 fix: multiple stream can't query with PromQL (#5719) 2025-01-16 14:47:47 +08:00
Hengfei Yang adc52c1ed1 feat: keep optimize metrics cache (#5716) 2025-01-16 11:38:58 +08:00
Patrick Sullivan c67e684a5c feat: Clean up old alerts code (#5712)
Now that the old alerts code, which stored alerts in the `meta` table,
has been removed, `alert/mod.rs` mostly just serves as a wrapper around
`alert/new.rs`.

This PR removes `alert/new.rs` and moves its logic into the parent
`alert` module. Also `alert/mod.rs` is replaced with `alert.rs` since
the `alert` module no longer contains child modules.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

- **New Features**
- Enhanced alert management functionality with improved listing and
caching capabilities
  - Added new methods for retrieving and managing alerts more flexibly

- **Changes**
- Updated alert listing method to support more specific filtering
parameters
  - Simplified alert retrieval and management processes

- **Refactor**
- Restructured alert-related functions to improve code organization and
maintainability
  - Streamlined database interaction methods for alerts

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-01-15 14:36:27 -06:00
Patrick SullivanandTaiming Liu 47dc8e4d44 feat: remove old alert code that stored alerts in meta table (#5711)
Follow-up:
Consolidate the `alert/new.rs` and `alert/mod.rs` files into one file,
since now the `alert/mod.rs` file mostly just acts as a wrapper around
the `alert/new.rs` file

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Refactor**
	- Removed legacy alert handling module
	- Simplified alert management logic
	- Eliminated dual-table approach for alerts
	- Streamlined alert operations to use new alerts table exclusively

- **Chores**
- Removed deprecated code and conditional checks related to old alert
management system

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Taiming Liu <liutaiming3@gmail.com>
2025-01-15 12:16:27 -06:00
Hengfei Yang c2d4866565 feat: impl metrics cache (#5688)
impl #5656 

## Todo

- [x] Router consistent hashing for PromQL
- [x] Remove the key from index if the key get nothing from cache
- [x] Some cache item is empty, it should not
- [x] Add cache control ENV: `ZO_METRICS_CACHE_ENABLED=true`
- [ ] Optimize cache gc logic
- [ ] New encoding of RangeValue for cache
- [x] New cache key generate
- [x] Load cache from disk
- [ ] Histogram query OOM without cache for 2 days
- [x] Fix response series order
- [x] Need to check stream is exists
- [x] Add trace_id to the response
2025-01-15 08:59:53 -08:00
Patrick SullivanandSubhradeep Chakraborty f66d069c55 fix: Emit supercluster events for folder creation/deletion/updates (#5702)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Release Notes

- **New Features**
- Enhanced folder management with improved unique identifier generation.
- Added enterprise-specific folder processing for create, update, and
delete operations.
- Introduced new asynchronous functions for processing folder-related
messages.
- Added optional ID parameter for alert creation, enhancing flexibility.

- **Changes**
- Updated folder-related function signatures to return more
comprehensive information.
- Integrated enterprise-level folder message processing in super cluster
queue.
- Relocated and centralized message definitions for alerts and
dashboards.

- **Improvements**
  - Refined error handling for folder operations.
  - Centralized message handling for folder-related events.
  - Improved clarity and maintainability in dashboard moving logic.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Subhradeep Chakraborty <chakrabortysubhradeep556@gmail.com>
2025-01-15 18:25:52 +05:30
Patrick Sullivan 1c80727adb feat: move FolderType into config::meta module (#5700)
We need to be able to reference the `FolderType` enum from
`o2-enterprise` without introducing a dependency on the `table` module.
Therefore, this PR moves the `FolderType` enum out of the `table` module
and into the shared `config::meta` module.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced a new `FolderType` enum to categorize folders as Dashboards
or Alerts.
- Enhanced folder management with more precise type handling across
different services.

- **Refactor**
- Updated import statements and type references for `FolderType` across
multiple modules.
	- Standardized folder type conversion and handling mechanisms.

- **Improvements**
	- Added more robust folder creation and validation logic.
	- Improved error handling for folder-related operations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-01-14 20:35:43 -06:00
Taiming Liu a2c175e412 fix: pipeline super_cluster update (#5699)
- [x] pipeline super cluster delete missing db update
- [x] use another local cache to map `pipeline_id` to `stream_params`
2025-01-14 18:02:36 -08:00
Patrick Sullivan a03526eaef feat: Decouple super_cluster from table via dependency injection (#5698)
This is the follow-up PR to [this other
PR](https://github.com/openobserve/o2-enterprise/pull/281#issue-2773724675).
Please see the other PR description for a detailed explanation of the
changes.

This PR copies the supercluster queue message handling code from
`o2-enterprise` which updates the database when different messages are
received. In this PR these message-handling functions are injected into
`o2-enterprise`'s various `SuperClusterQueue` structures so that the
`SuperClusterQueue`s can execute the logic to update the `openobserve`
database without the `o2-enterprise` crate needing a dependency on the
`table` module.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Added comprehensive message processing capabilities for various
enterprise components including alerts, dashboards, distinct values,
meta, pipelines, schemas, search jobs, and short URLs
- Introduced a new super cluster queue system with modular message
handling and initialization

- **Chores**
- Updated library and main application to support enterprise feature
initialization
	- Added conditional compilation for enterprise-specific modules

- **Infrastructure**
- Implemented robust error handling and logging for message processing
across different system components

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-01-14 18:04:10 -06:00
Patrick SullivanandSubhradeep Chakraborty 947a8ddc4e fix: Migration to enforce unique folder names (#5689)
### Summary

Folder names within an individual organization and within a specific
folder type should be unique.

This migration adds a migration to...
1. Rename any folders that have the same name, organization, and folder
type by appending a 27-character random KSUID to the name to ensure that
each name is unique.
2. Create a unique constraint on the `folders` table on the composite
key of `org`, `type`, and `name`. This will prevent new folders from
having duplicate names in the future.

### Follow-up work

If a user tries to create or update a folder so that the folder would
have the same name as another folder with the same `org` and `type`,
then the database will reject the query and the application will return
an error response. However the error response will likely just contain
the error text returned by SeaORM.

We should also update the logic in `/src/service/folders.rs` to check
for duplicate folder names when folders are created or updated and to
gracefully return a useful error.



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Implemented a database migration to ensure unique folder names within
an organization.
- Added a mechanism to automatically rename duplicate folders by
appending a unique identifier.
- Created a unique constraint for folder names across organization and
type.
	- Introduced a new API endpoint to retrieve folders by name.
- Added a deprecated API endpoint for retrieving folders by name with a
different structure.

- **Improvements**
- Enhanced database integrity by preventing naming conflicts in folder
management.
- Improved authorization logic for GET requests targeting folders by
name.
- Added functionality to retrieve folders by their name in the service
layer.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Subhradeep Chakraborty <chakrabortysubhradeep556@gmail.com>
2025-01-14 17:30:30 -06:00
Taiming Liu 98fd05211a fix: pipeline db event watch for updating in-memory cache (#5685)
Using database event watch to update in-memory cache for pipeline db
operations
2025-01-13 19:31:20 -08:00
Huaijin 70450ec01a feat: ignore time_range when join on enrichment_tables (#5684) 2025-01-13 23:47:06 +08:00
Huaijin e81d8da46a fix: union all with order by (#5674) 2025-01-13 12:11:18 +08:00
Zhao.wei 1a5350f62b feat: improve trace max query range (#5613) 2025-01-12 17:51:18 +08:00
Hengfei Yang 445a50ddde fix: metrics Mismatch between schema and batches (#5673) 2025-01-12 15:13:00 +08:00
Huaijin 36de81c437 feat: impl join right table only match once (#5661) 2025-01-11 11:57:57 +08:00
Hengfei Yang 44b5daf949 feat: add limit for uds (#5669) 2025-01-11 09:59:59 +08:00
Patrick SullivanandTaiming Liu 500c53295c feat: New MoveAlert endpoint (#5626)
Adds a new endpoint for moving an alert between different folders.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
	- Added ability to move alerts between folders.
	- Introduced new endpoint for moving alerts.
- Enhanced alert management with improved validation and error handling.

- **Bug Fixes**
	- Improved alert retrieval to include folder context.

- **Documentation**
	- Updated OpenAPI documentation to include new alert movement endpoint.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Taiming Liu <liutaiming3@gmail.com>
2025-01-10 11:18:54 -06:00
Subhra264 fe9eaa1f0e fix: move dashboard rbac ownership (#5671)
When we move a dashboard from one folder to another, currently the rbac
relations are not updated, so the folder still points to the old folder
as `parent` in the ofga `tuple` database.

This PR fixes this issue by updating the `parent` relationship between
the dashboard and the old and new folders.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced dashboard management with improved access control integration
- Added support for setting and removing parent relations for dashboards
using OpenFGA system

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-01-10 22:14:52 +05:30
Ashish Kolhe 7a9a2c52eb fix: migration failing without specifying fetch order (#5665)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Chores**
	- Enhanced database migration script to improve record processing order
	- Added logging for KSUID generation during migration process
	- Updated import statements to support query ordering functionality

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-01-10 18:01:45 +05:30
Hengfei Yang 2c7f4dff53 fix: aws ingestion (#5660) 2025-01-10 18:53:44 +08:00
Huaijin 46cc4cb880 feat: search job return total result (#5663)
- [x] for search job, in `total` field, will return the total records
numbers.
- [x] if not set the from and size when get result, we set default from
= 0 and size = 100
2025-01-10 18:03:24 +08:00
Huaijin 3c3d9a46e8 feat: retention for search jobs (#5655)
close #5645 

## New Env
```
ZO_SEARCH_JOB_RETENTION
```

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

- **New Features**
  - Added configurable search job retention setting
  - Implemented job retention management for search jobs

- **Enterprise Features**
  - Enhanced job deletion mechanism based on retention period
  - Added ability to automatically clean up older search jobs

- **Configuration**
- New option to specify how long search jobs are kept (default: 30 days)

These updates improve system management and provide more control over
job lifecycle, particularly for enterprise users.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-01-10 10:10:41 +05:30
Patrick Sullivan c2ccf4a3a1 fix: Fix new UpdateAlert endpoint (#5652) 2025-01-09 21:42:56 -06:00
Patrick Sullivan 0383959603 fix: Mirgration to use KSUIDs instead of auto-incrementing integers as PKs (#5651)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Database Migration**
- Transitioned database tables to use KSUIDs (K-Sortable Unique
Identifiers) as primary keys.
- Recreated `folders`, `dashboards`, and `alerts` tables with a new
identifier system.
- Updated `id` and `folder_id` fields in `alerts`, `dashboards`, and
`folders` tables from numeric to string types.
- Ensured unique identifiers are generated upon creation of new folders
and dashboards.
	- Preserved existing data during the migration process.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-01-09 21:05:18 -06:00
Taiming Liu 9927d2e4a7 fix: add a distributed lock for database migration (#5653) 2025-01-09 17:52:51 -08:00
Patrick Sullivan 8cdf9aff3b fix: Fix UpdateAlert v2 endpoint (#5647)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
	- Improved alert update and enablement process
	- Enhanced transactional handling for alert state changes

- **Refactor**
- Updated alert management logic to provide more robust state
transitions

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-01-09 14:50:33 -06:00
Hengfei Yang a686ec6927 fix: metrics ingestion with otlp json (#5649) 2025-01-10 00:22:36 +08:00
Huaijin 43b7bad404 feat: add pagination for search job result (#5640)
- [x] list status order by createdat desc
- [x] add pagination for search job result
```
curl --request GET \
  --url 'http://localhost:5080/api/default/search_jobs/bL3PkaKBp9maA6DpJ8Z/result?from=10&size=30' 
```
2025-01-09 17:41:40 +08:00
Hengfei Yang 3baaf1a8c2 fix: mmdb client error after update asn file (#5636) 2025-01-09 16:18:23 +08:00
Hengfei Yang f4a7388aae feat: add option for extra default index fields (#5631) 2025-01-09 12:47:18 +08:00
Taiming Liu fa96ae2c6d fix: pipeline migration name (#5611)
fix: #5608
2025-01-08 18:01:47 -08:00
Hengfei Yang 5e449ce63c feat: add option for compact old data (#5615) 2025-01-09 08:53:21 +08:00
Ashish Kolhe d6fc3fe53c fix: panic when mmdb download is disabled (#5623)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced configuration handling for enterprise geographic IP
enrichment when the enterprise feature is enabled.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-01-08 18:51:16 +05:30
Ashish Kolhe b4999c7f65 fix: restrict service accounts login to web (#5621)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Security Enhancement**
	- Added validation to prevent service accounts from logging in
- Implemented additional authentication checks during user login process

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-01-08 18:04:38 +05:30
Ashish Kolhe 92b75075c7 fix: allow geo lite db with enterprise mmdb (#5620)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Refactor**
- Simplified the Maxmind database download and client initialization
process.
	- Streamlined logic for handling file downloads and client updates.
- Removed unnecessary conditional checks, enhancing the overall flow of
operations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-01-08 17:12:37 +05:30
Huaijin d7dd9128b7 feat: support limit join's right side (#5616)
related #5602

## New env
```
ZO_FEATURE_JOIN_RIGHT_SIDE_MAX_ROWS=0
```
default is 0, means disable
2025-01-08 15:40:13 +08:00
Huaijin 1a27d16e1e feat: batch read data to avoid metrics OOM (#5584) 2025-01-06 20:11:56 +08:00