npm install feathers-splunk --save
Here's an example of a Feathers server that uses feathers-splunk
.
const feathers = require("@feathersjs/feathers");
const { splunk } = require("feathers-splunk");
// Initialize the application
const app = feathers();
// Initialize the plugin
app.configure(
splunk({
token: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
url: "<SPLUNK_URL>" // usually have the port of 8088
})
);
const { splunkHooks } = require("feathers-splunk");
// Add it to the hooks of services
module.exports = {
before: {
all: [splunkHooks()], // for logging data when before hook called
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
},
after: {
all: [splunkHooks()], // for logging data when after hook called
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
},
error: {
all: [splunkHooks()], // For logging errors
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
}
};
- Create New Index in settings/Indexes (splunk)
- Link the created indexes into settings/indexes (HTTP Event Collector)
- Modify the app.js configuration to the below
app.configure(
splunk({
token: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
url: "<SPLUNK_URL>" // usually have the port of 8088,
index: 'senthil'
})
);
- Modify the xx.hooks.js to the metadata below
before: {
all: [
splunkHooks({
source: "/message",
sourcetype: "rest-call",
index: "senthil",
host: "http://localhost",
port: "3000"
})
], // for logging data when before hook called
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
}
Copyright (c) 2018
Licensed under the MIT license.