Skip to content

chore: server side improvements #1396

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

Merged

Conversation

nikhilsinhaparseable
Copy link
Contributor

@nikhilsinhaparseable nikhilsinhaparseable commented Jul 31, 2025

  1. increase dataset fields limit to 1000
  2. add hostname to manifest file path
  3. update hostname handling
  4. list alerts to be sorted on state and then on severity

Summary by CodeRabbit

  • New Features

    • Increased the maximum allowed number of fields in a dataset from 250 to 1000.
  • Improvements

    • Alerts can now be filtered by tags and support pagination with detailed error messages for invalid queries.
    • Alerts are sorted by state and severity for clearer viewing.
    • Hostname handling for filenames and manifest files is more robust, with improved sanitization and fallback mechanisms ensuring safe and consistent file naming.
    • Enhanced alert state and severity sorting by adding full ordering capabilities.
    • Improved error messages with more detailed information on invalid query parameters.

1. increase dataset fields limit to 1000
2. add hostname to manifest file path
3. update hostname handling
4. list alerts to be sorted on state and then on severity
Copy link
Contributor

coderabbitai bot commented Jul 31, 2025

Walkthrough

This update increases the dataset field count limit from 250 to 1000, adds robust hostname retrieval and sanitization for filename and manifest generation, and introduces sorting logic for alert summaries by state and severity with pagination and tag filtering. It also enhances alert enums with ordering traits and improves error detail. No public API signatures were changed; only internal logic and constants were updated.

Changes

Cohort / File(s) Change Summary
Dataset Field Limit Constant
src/cli.rs
Increased DATASET_FIELD_COUNT_LIMIT from 250 to 1000.
Alert Sorting, Pagination, and Filtering
src/handlers/http/alerts.rs, src/alerts/mod.rs
Added pagination and tag filtering to alert listing; enhanced sorting of alert summaries by state (Triggered, Silenced, Resolved, Unknown) and severity (Critical, High, Medium, Low, Unknown). Updated AlertState and Severity enums to derive Eq, PartialOrd, and Ord. Modified AlertError::InvalidQueryParameter to carry detailed error messages.
Robust Hostname in Filenames
src/parseable/streams.rs
Improved hostname retrieval and sanitization for generating filenames, adding fallbacks and filtering to ensure safe, non-panicking behavior.
Hostname in Manifest Path
src/storage/object_storage.rs
Incorporated sanitized hostname into manifest file names, with fallback to ULID, and adjusted filename construction logic accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server (alerts.rs)
    participant AlertStore

    Client->>Server (alerts.rs): GET /alerts?tags=&offset=&limit=
    Server (alerts.rs)->>Server (alerts.rs): Parse and validate query parameters
    alt Invalid parameters
        Server (alerts.rs)-->>Client: Return InvalidQueryParameter error with details
    else Valid parameters
        Server (alerts.rs)->>AlertStore: Fetch alert summaries filtered by tags
        AlertStore-->>Server (alerts.rs): Return alert summaries
        Server (alerts.rs)->>Server (alerts.rs): Sort alerts by state and severity
        Server (alerts.rs)->>Server (alerts.rs): Paginate results by offset and limit
        Server (alerts.rs)-->>Client: Return sorted and paginated alerts as JSON
    end
Loading
sequenceDiagram
    participant Stream
    participant System
    participant ULID

    Stream->>System: Get hostname
    alt Hostname retrieval fails or invalid UTF-8
        Stream->>ULID: Generate new ULID string
    end
    Stream->>Stream: Sanitize hostname (alphanumeric, -, _)
    Stream->>Stream: Use sanitized hostname in filename
Loading
sequenceDiagram
    participant ObjectStorage
    participant System
    participant ULID

    ObjectStorage->>System: Get hostname
    alt Hostname retrieval fails or invalid UTF-8
        ObjectStorage->>ULID: Generate new ULID string
    end
    ObjectStorage->>ObjectStorage: Sanitize hostname
    ObjectStorage->>ObjectStorage: Build manifest filename with hostname
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

for next release

Suggested reviewers

  • parmesant

Poem

A thousand fields now fit with ease,
Alerts line up by state and degree.
Hostnames cleaned and sanitized,
ULIDs step in, if surprise!
Manifests and streams both know your name—
Oh what a tidy, sortable game!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d872cd and 5000767.

📒 Files selected for processing (1)
  • src/alerts/mod.rs (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/alerts/mod.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: coverage
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/storage/object_storage.rs (1)

1014-1022: Robust hostname handling with minor optimization opportunity.

The hostname retrieval and sanitization logic is well-implemented with proper fallbacks. However, there's redundant character collection on lines 1021-1022.

Apply this diff to remove the redundant character collection:

-        .chars()
-        .filter(|c| c.is_alphanumeric() || *c == '-' || *c == '_')
-        .collect::<String>()
-        .chars()
-        .collect::<String>();
+        .chars()
+        .filter(|c| c.is_alphanumeric() || *c == '-' || *c == '_')
+        .collect::<String>();
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ecdb27f and ad026eb.

📒 Files selected for processing (4)
  • src/cli.rs (1 hunks)
  • src/handlers/http/alerts.rs (1 hunks)
  • src/parseable/streams.rs (2 hunks)
  • src/storage/object_storage.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: nikhilsinhaparseable
PR: parseablehq/parseable#1276
File: src/prism/logstream/mod.rs:335-338
Timestamp: 2025-03-28T06:30:13.566Z
Learning: The datasets API in Parseable is exclusively used by the datasets page in the Parseable UI and only queries the specific fields "p_src_ip" and "p_user_agent", making additional field validation unnecessary.
📚 Learning: the datasets api in parseable is exclusively used by the datasets page in the parseable ui and only ...
Learnt from: nikhilsinhaparseable
PR: parseablehq/parseable#1276
File: src/prism/logstream/mod.rs:335-338
Timestamp: 2025-03-28T06:30:13.566Z
Learning: The datasets API in Parseable is exclusively used by the datasets page in the Parseable UI and only queries the specific fields "p_src_ip" and "p_user_agent", making additional field validation unnecessary.

Applied to files:

  • src/cli.rs
📚 Learning: in the parseable alert system (src/alerts/mod.rs), alert versions are server-generated and controlle...
Learnt from: nikhilsinhaparseable
PR: parseablehq/parseable#1388
File: src/alerts/mod.rs:88-104
Timestamp: 2025-07-24T11:09:21.781Z
Learning: In the Parseable alert system (src/alerts/mod.rs), alert versions are server-generated and controlled via CURRENT_ALERTS_VERSION constant, not user input. The AlertVerison enum's From<&str> implementation correctly defaults unknown versions to V2 since the server only generates known versions (v1, v2). Unknown versions would only occur in exceptional cases like file corruption, making the current fallback approach appropriate.

Applied to files:

  • src/handlers/http/alerts.rs
📚 Learning: in parseable's logstream handlers, stream existence checks must be performed for both query and stan...
Learnt from: de-sh
PR: parseablehq/parseable#1185
File: src/handlers/http/logstream.rs:255-261
Timestamp: 2025-02-14T09:49:25.818Z
Learning: In Parseable's logstream handlers, stream existence checks must be performed for both query and standalone modes. The pattern `!PARSEABLE.streams.contains(&stream_name) && (PARSEABLE.options.mode != Mode::Query || !PARSEABLE.create_stream_and_schema_from_storage(&stream_name).await?)` ensures proper error handling in both modes.

Applied to files:

  • src/parseable/streams.rs
📚 Learning: in parseable's ingest or query mode, the node_id is always available because it's generated during s...
Learnt from: nikhilsinhaparseable
PR: parseablehq/parseable#1346
File: src/parseable/streams.rs:319-331
Timestamp: 2025-06-16T09:50:38.636Z
Learning: In Parseable's Ingest or Query mode, the node_id is always available because it's generated during server initialization itself, before the get_node_id_string() function in streams.rs would be called. This makes the .expect() calls on QUERIER_META.get() and INGESTOR_META.get() safe in this context.

Applied to files:

  • src/parseable/streams.rs
📚 Learning: in parseable server, filenames for arrow files are generated server-side during ingestion using a st...
Learnt from: nikhilsinhaparseable
PR: parseablehq/parseable#1346
File: src/storage/object_storage.rs:838-840
Timestamp: 2025-06-16T02:09:49.200Z
Learning: In Parseable server, filenames for arrow files are generated server-side during ingestion using a strict format pattern: `{stream_hash}.date={date}.hour={hour}.minute={minute}.{custom_partitions}{hostname}.data.{extension}`. This guarantees that when splitting by dots, the second element will always be `date={value}`, making direct indexing safe when extracting the date part by splitting on '=' and accessing index 1.

Applied to files:

  • src/parseable/streams.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: coverage
🔇 Additional comments (4)
src/cli.rs (1)

38-38: LGTM! Dataset field limit increase implemented correctly.

The constant has been properly updated from 250 to 1000 fields, aligning with the PR objective to increase dataset capacity.

src/handlers/http/alerts.rs (1)

64-98: LGTM! Alert sorting logic correctly implemented.

The sorting implementation properly prioritizes alerts by state (Triggered > Silenced > Resolved) and then by severity (Critical > High > Medium > Low). The helper closures provide clean mapping to numeric priorities, and unknown values are appropriately handled with lowest priority.

src/storage/object_storage.rs (1)

1024-1038: LGTM! Manifest file naming correctly incorporates hostname.

The updated manifest file naming scheme properly includes the sanitized hostname in both ingest mode (ingestor.{hostname}.{id}.{MANIFEST_FILE}) and other modes ({hostname}.{MANIFEST_FILE}), fulfilling the PR objective to add hostname to the manifest file path.

src/parseable/streams.rs (1)

44-44: LGTM! Clean import addition.

The ULID import is necessary for the new hostname fallback logic and is properly placed.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 31, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 1, 2025
@nitisht nitisht merged commit 4c634b5 into parseablehq:main Aug 1, 2025
13 checks passed
@nikhilsinhaparseable nikhilsinhaparseable deleted the increase-dataset-field-limit branch August 1, 2025 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants