feathers-splunk
v1.0.7
Published
Integrates feathersjs + splunk for logging
Downloads
24
Maintainers
Readme
feathers-splunk
Installation
npm install feathers-splunk --save
Documentation
Complete Example
Here's an example of a Feathers server that uses feathers-splunk
.
app.js
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
})
);
xx.hooks.js
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: []
}
};
Customization
For creating custom index for splunk
- 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'
})
);
Changing the metadata of the splunk logging
- 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: []
}
License
Copyright (c) 2018
Licensed under the MIT license.