-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New Components - splunk_http_event_collector #16058
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
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fba0203
new actions
michelle0927 2e213fe
new components
michelle0927 e4e5c5a
pnpm-lock.yaml
michelle0927 f0e8070
pnpm-lock.yaml
michelle0927 f44ede1
package.json
michelle0927 541397b
pnpm-lock.yaml
michelle0927 2f42c3e
fix prop
michelle0927 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
components/splunk_http_event_collector/actions/check-health/check-health.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import splunk from "../../splunk_http_event_collector.app.mjs"; | ||
|
||
export default { | ||
key: "splunk_http_event_collector-check-health", | ||
name: "Check Splunk HTTP Event Collector Health", | ||
description: "Checks the health status of the Splunk HTTP Event Collector to ensure it is available and ready to receive events. [See the documentation](https://docs.splunk.com/Documentation/Splunk/8.2.0/RESTREF/RESTinput#services.2Fcollector.2Fhealth)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
splunk, | ||
}, | ||
async run({ $ }) { | ||
try { | ||
const response = await this.splunk.checkHealth({ | ||
$, | ||
}); | ||
$.export("$summary", `Splunk HTTP Event Collector health status: "${response.text}"`); | ||
return response; | ||
} catch (error) { | ||
$.export("$summary", `Failed to check Splunk HTTP Event Collector health: ${error.message}`); | ||
throw new Error(`Health check failed: ${error.message}`); | ||
} | ||
}, | ||
}; |
57 changes: 57 additions & 0 deletions
57
components/splunk_http_event_collector/actions/send-batch-events/send-batch-events.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import splunk from "../../splunk_http_event_collector.app.mjs"; | ||
import { parseJson } from "../../common/utils.mjs"; | ||
|
||
export default { | ||
key: "splunk_http_event_collector-send-batch-events", | ||
name: "Send Batch Events", | ||
description: "Sends multiple events in a single request to the Splunk HTTP Event Collector. [See the documentation](https://docs.splunk.com/Documentation/Splunk/8.2.0/RESTREF/RESTinput#services.2Fcollector.2Fraw)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
splunk, | ||
batchEvents: { | ||
type: "string[]", | ||
label: "Batch Events", | ||
description: "A batch of event data to send to Splunk", | ||
}, | ||
channel: { | ||
propDefinition: [ | ||
splunk, | ||
"channel", | ||
], | ||
}, | ||
sourcetype: { | ||
propDefinition: [ | ||
splunk, | ||
"sourcetype", | ||
], | ||
}, | ||
index: { | ||
propDefinition: [ | ||
splunk, | ||
"index", | ||
], | ||
}, | ||
host: { | ||
propDefinition: [ | ||
splunk, | ||
"host", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.splunk.sendMultipleEvents({ | ||
$, | ||
params: { | ||
channel: this.channel, | ||
sourcetype: this.sourcetype, | ||
index: this.index, | ||
host: this.host, | ||
}, | ||
data: parseJson(this.batchEvents), | ||
}); | ||
|
||
$.export("$summary", `Successfully sent ${this.batchEvents.length} events to Splunk.`); | ||
return response; | ||
}, | ||
}; |
58 changes: 58 additions & 0 deletions
58
components/splunk_http_event_collector/actions/send-event/send-event.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import splunk from "../../splunk_http_event_collector.app.mjs"; | ||
import { parseJson } from "../../common/utils.mjs"; | ||
|
||
export default { | ||
key: "splunk_http_event_collector-send-event", | ||
name: "Send Event", | ||
description: "Sends an event to Splunk HTTP Event Collector. [See the documentation](https://docs.splunk.com/Documentation/Splunk/8.2.0/RESTREF/RESTinput#services.2Fcollector.2Fevent)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
splunk, | ||
eventData: { | ||
type: "string", | ||
label: "Event Data", | ||
description: "The event data to send to Splunk", | ||
}, | ||
channel: { | ||
propDefinition: [ | ||
splunk, | ||
"channel", | ||
], | ||
}, | ||
sourcetype: { | ||
propDefinition: [ | ||
splunk, | ||
"sourcetype", | ||
], | ||
}, | ||
index: { | ||
propDefinition: [ | ||
splunk, | ||
"index", | ||
], | ||
}, | ||
host: { | ||
propDefinition: [ | ||
splunk, | ||
"host", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.splunk.sendEvent({ | ||
$, | ||
params: { | ||
channel: this.channel, | ||
}, | ||
data: { | ||
event: parseJson(this.eventData), | ||
sourcetype: this.sourcetype, | ||
index: this.index, | ||
host: this.host, | ||
}, | ||
}); | ||
$.export("$summary", "Successfully sent event to Splunk HTTP Event Collector"); | ||
return response; | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
function parseJson(obj) { | ||
if (!obj) { | ||
return undefined; | ||
} | ||
|
||
if (typeof obj === "string") { | ||
try { | ||
return JSON.parse(obj); | ||
} catch { | ||
return obj; | ||
} | ||
} | ||
|
||
if (Array.isArray(obj)) { | ||
return obj.map((o) => { | ||
if (typeof o === "string") { | ||
try { | ||
return JSON.parse(o); | ||
} catch { | ||
return o; | ||
} | ||
} | ||
return o; | ||
}); | ||
} | ||
|
||
return obj; | ||
} | ||
|
||
export { | ||
parseJson, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@pipedream/splunk_http_event_collector", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Pipedream Splunk HTTP Event Collector Components", | ||
"main": "splunk_http_event_collector.app.mjs", | ||
"keywords": [ | ||
|
@@ -11,5 +11,8 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^3.0.3" | ||
} | ||
} | ||
} |
67 changes: 62 additions & 5 deletions
67
components/splunk_http_event_collector/splunk_http_event_collector.app.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,68 @@ | ||
import { axios } from "@pipedream/platform"; | ||
|
||
export default { | ||
type: "app", | ||
app: "splunk_http_event_collector", | ||
propDefinitions: {}, | ||
propDefinitions: { | ||
channel: { | ||
type: "string", | ||
label: "Channel", | ||
description: "Channel GUID to differentiate data from different clients", | ||
}, | ||
sourcetype: { | ||
type: "string", | ||
label: "Sourcetype", | ||
description: "The sourcetype of the event", | ||
}, | ||
index: { | ||
type: "string", | ||
label: "Index", | ||
description: "The index to send the event to", | ||
optional: true, | ||
}, | ||
host: { | ||
type: "string", | ||
label: "Host", | ||
description: "The host sending the event", | ||
optional: true, | ||
}, | ||
}, | ||
methods: { | ||
// this.$auth contains connected account data | ||
authKeys() { | ||
console.log(Object.keys(this.$auth)); | ||
_baseUrl() { | ||
return `${this.$auth.api_url}:${this.$auth.port}`; | ||
}, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_makeRequest({ | ||
$ = this, | ||
path, | ||
...otherOpts | ||
}) { | ||
return axios($, { | ||
url: `${this._baseUrl()}${path}`, | ||
headers: { | ||
"Authorization": `Splunk ${this.$auth.api_token}`, | ||
}, | ||
...otherOpts, | ||
}); | ||
}, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
checkHealth(opts = {}) { | ||
return this._makeRequest({ | ||
path: "/services/collector/health", | ||
...opts, | ||
}); | ||
}, | ||
sendEvent(opts = {}) { | ||
return this._makeRequest({ | ||
method: "POST", | ||
path: "/services/collector", | ||
...opts, | ||
}); | ||
}, | ||
sendMultipleEvents(opts = {}) { | ||
return this._makeRequest({ | ||
method: "POST", | ||
path: "/services/collector/raw", | ||
...opts, | ||
}); | ||
}, | ||
}, | ||
}; | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.