-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
WalkthroughThis 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
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
Assessment against linked issues
Suggested labels
Suggested reviewers
Poem
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
components/splunk_http_event_collector/actions/send-event/send-event.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 parsingThe 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 messageLine 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 requestsThere'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
⛔ 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 parsingThe
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 syntaxThe 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 appropriateThe 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 managementAdding 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 importsThe imports are correctly set up, bringing in the Splunk app and the
parseJson
utility function.
4-9
: Well-defined action metadataThe 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 handlingThe
run
method properly uses the Splunk app'ssendEvent
method with appropriate parameters. The use ofparseJson
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 setupThe 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 messagesThe
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 importsThe imports for the Splunk app and utility function are correctly defined.
4-9
: LGTM: Clear action definitionThe action is well-defined with an appropriate key, name, description (including documentation link), version, and type.
10-41
: LGTM: Well-structured propsProps 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 definitionsThe 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 implementationsThe
checkHealth
,sendEvent
, andsendMultipleEvents
methods are well-implemented to interact with different Splunk API endpoints, leveraging the centralized_makeRequest
method.
components/splunk_http_event_collector/actions/send-event/send-event.mjs
Outdated
Show resolved
Hide resolved
components/splunk_http_event_collector/actions/send-batch-events/send-batch-events.mjs
Show resolved
Hide resolved
components/splunk_http_event_collector/splunk_http_event_collector.app.mjs
Show resolved
Hide resolved
components/splunk_http_event_collector/splunk_http_event_collector.app.mjs
Show resolved
Hide resolved
There was a problem hiding this 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!
Resolves #15805
Summary by CodeRabbit
New Features
channel
,sourcetype
,index
, andhost
for enhanced customization.Chores