Skip to content
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

New Components - splunk_http_event_collector #16058

Merged
merged 7 commits into from
Apr 1, 2025
Merged

Conversation

michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Mar 26, 2025

Resolves #15805

Summary by CodeRabbit

  • New Features

    • Introduced actions that let you check the service health, send individual events, and send batch events to Splunk.
    • Expanded app configuration with additional options for channel, sourcetype, index, and host for enhanced customization.
    • Enhanced event data processing with improved JSON handling.
  • Chores

    • Updated the component version to 0.1.0 and added a new dependency to improve overall compatibility and performance.

Copy link

vercel bot commented Mar 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Mar 26, 2025 9:10pm
pipedream-docs ⬜️ Ignored (Inspect) Mar 26, 2025 9:10pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Mar 26, 2025 9:10pm

Copy link
Contributor

coderabbitai bot commented Mar 26, 2025

Walkthrough

This pull request introduces three new action modules for the Splunk HTTP Event Collector: one for checking health, one for sending a single event, and one for sending batch events. It also adds a JSON parsing utility and updates the Splunk app's configuration by adding new properties and refactoring methods to use centralized request logic, replacing the previous authentication method. Additionally, version and dependency updates in the package manifest support these changes.

Changes

File(s) Change Summary
components/splunk_http_event_collector/actions/{check-health, send-batch-events, send-event}.mjs New action modules added for health checks, sending a single event, and sending batch events with appropriate properties and asynchronous run methods.
components/splunk_http_event_collector/common/utils.mjs Added parseJson utility function to handle JSON conversion with fallback logic.
components/splunk_http_event_collector/package.json Updated version from 0.0.1 to 0.1.0 and added dependency on @pipedream/platform (^3.0.3).
components/splunk_http_event_collector/splunk_http_event_collector.app.mjs Extended app configuration by adding new properties (channel, sourcetype, index, host), removed authKeys(), and added _makeRequest(), checkHealth(), sendEvent(), and sendMultipleEvents() to handle API interactions.

Sequence Diagram(s)

sequenceDiagram
    participant Action as Action Module
    participant App as SplunkApp
    participant API as Splunk API

    Action->>App: run(context)
    App->>App: _makeRequest() [Invoked for checkHealth/sendEvent/sendMultipleEvents]
    App->>API: HTTP Request with parameters
    API-->>App: Response/Error
    App-->>Action: Return result or error
Loading

Assessment against linked issues

Objective (Linked Issue #15805) Addressed Explanation
send-event: Accepts event data, sourcetype, optionally index/host metadata
send-batch-events: Accepts batch of events, sourcetype, optionally index/host metadata
check-health: Verifies the health status of the Splunk HTTP Event Collector

Suggested labels

action, trigger / source

Suggested reviewers

  • jcortes

Poem

I'm a hopping rabbit with lines of code so neat,
Sending events and health checks with a rhythmic beat.
Single events, batch events—each step in the flow,
Leaping through the modules as I merrily go.
With every click and commit I cheer and boast,
Celebrating changes from coast to coast!
🐰💻 Happy coding, team!

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/splunk_http_event_collector/actions/send-event/send-event.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)


📜 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 541397b and 2f42c3e.

📒 Files selected for processing (1)
  • components/splunk_http_event_collector/actions/send-event/send-event.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/splunk_http_event_collector/actions/send-event/send-event.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: pnpm publish
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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: 4

🧹 Nitpick comments (3)
components/splunk_http_event_collector/actions/send-batch-events/send-batch-events.mjs (2)

51-51: Validate batch events before parsing

The code doesn't check if this.batchEvents exists or is properly formatted before parsing. This could lead to runtime errors if the input is malformed.

-      data: parseJson(this.batchEvents),
+      data: Array.isArray(this.batchEvents) && this.batchEvents.length > 0 
+        ? this.batchEvents.map(event => parseJson(event))
+        : [],

54-54: Add validation for summary message

Line 54 assumes this.batchEvents has a length property, which could cause an issue if the input is malformed.

-    $.export("$summary", `Successfully sent ${this.batchEvents.length} events to Splunk.`);
+    const eventCount = Array.isArray(this.batchEvents) ? this.batchEvents.length : 0;
+    $.export("$summary", `Successfully sent ${eventCount} events to Splunk.`);
components/splunk_http_event_collector/splunk_http_event_collector.app.mjs (1)

1-68: Verify token existence before making requests

There's no validation to ensure that the API token exists before making requests, which could lead to authentication errors.

Consider adding a validation method that's called before any API requests:

+ _validateAuth() {
+   if (!this.$auth.api_token) {
+     throw new Error("API Token is required for Splunk HTTP Event Collector");
+   }
+   if (!this.$auth.api_url) {
+     throw new Error("API URL is required for Splunk HTTP Event Collector");
+   }
+   if (!this.$auth.port) {
+     throw new Error("Port is required for Splunk HTTP Event Collector");
+   }
+ },

  _makeRequest({
    $ = this,
    path,
    ...otherOpts
  }) {
+   this._validateAuth();
    return axios($, {
      url: `${this._baseUrl()}${path}`,
      headers: {
        "Authorization": `Splunk ${this.$auth.api_token}`,
      },
      ...otherOpts,
    });
  },
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 17e5afe and 541397b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • components/splunk_http_event_collector/actions/check-health/check-health.mjs (1 hunks)
  • components/splunk_http_event_collector/actions/send-batch-events/send-batch-events.mjs (1 hunks)
  • components/splunk_http_event_collector/actions/send-event/send-event.mjs (1 hunks)
  • components/splunk_http_event_collector/common/utils.mjs (1 hunks)
  • components/splunk_http_event_collector/package.json (2 hunks)
  • components/splunk_http_event_collector/splunk_http_event_collector.app.mjs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
🔇 Additional comments (14)
components/splunk_http_event_collector/common/utils.mjs (2)

1-28: Well-structured utility function for JSON parsing

The parseJson function is implemented with good error handling and covers different data types appropriately. It handles:

  • Falsy values
  • String parsing with try/catch error handling
  • Arrays with string elements
  • All other data types

This is a robust implementation that safely attempts to parse JSON without throwing exceptions.


30-32: Clean export syntax

The export statement correctly exports the parseJson function, making it available for import in other modules.

components/splunk_http_event_collector/package.json (2)

3-3: Version bump looks appropriate

The version update from 0.0.1 to 0.1.0 follows semantic versioning principles since this PR is adding new functionality.


14-17: Good dependency management

Adding the @pipedream/platform dependency with a version constraint of ^3.0.3 is appropriate for this component that relies on the platform's capabilities.

components/splunk_http_event_collector/actions/send-event/send-event.mjs (3)

1-3: Appropriate imports

The imports are correctly set up, bringing in the Splunk app and the parseJson utility function.


4-9: Well-defined action metadata

The action definition includes all necessary metadata like key, name, description, version, and type. The documentation link is helpful for users to reference.


42-57: Clear implementation with proper data handling

The run method properly uses the Splunk app's sendEvent method with appropriate parameters. The use of parseJson for the event data is excellent for handling different input formats. The exported summary provides good user feedback.

components/splunk_http_event_collector/actions/check-health/check-health.mjs (2)

1-11: Well-structured component setup

The health check action is properly set up with appropriate metadata and imports. The documentation link provides excellent reference information.


12-23: Good error handling with informative messages

The run method implements excellent error handling using try/catch and provides informative error messages. The exported summary gives clear feedback on the health status.

components/splunk_http_event_collector/actions/send-batch-events/send-batch-events.mjs (3)

1-3: LGTM: Clean imports

The imports for the Splunk app and utility function are correctly defined.


4-9: LGTM: Clear action definition

The action is well-defined with an appropriate key, name, description (including documentation link), version, and type.


10-41: LGTM: Well-structured props

Props are properly defined with appropriate types, labels, and descriptions. The structure follows standard patterns by referencing prop definitions from the Splunk app for common fields.

components/splunk_http_event_collector/splunk_http_event_collector.app.mjs (2)

6-29: LGTM: Well-defined prop definitions

The prop definitions for channel, sourcetype, index, and host are well-structured with appropriate types, labels, descriptions, and optional flags where needed.


47-66: LGTM: Clear API method implementations

The checkHealth, sendEvent, and sendMultipleEvents methods are well-implemented to interact with different Splunk API endpoints, leveraging the centralized _makeRequest method.

Copy link
Collaborator

@luancazarine luancazarine left a comment

Choose a reason for hiding this comment

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

Hi @michelle0927, LGTM! Ready for QA!

@michelle0927 michelle0927 merged commit 0d52798 into master Apr 1, 2025
11 checks passed
@michelle0927 michelle0927 deleted the issue-15805 branch April 1, 2025 14:04
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.

[Components] splunk_http_event_collector
2 participants