Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@rentspree/express-elasticsearch-logger
Advanced tools
Log Express app requests to ElasticSearch.
Install using npm:
npm install @rentspree/express-elasticsearch-logger
const {requestHandler} = require('@rentspree/express-elasticsearch-logger')
app.use(
requestHandler({
host:'http://localhost:9200',
index: undefined, //use prefix and suffix instead fixing the index name
whitelist:{
request:['user'],
response:['my_response'],
},
censor:['password'],
includeDefault:true, // for whitelist and censor, include the predefined value or not
// below example will make index name 'service_log_q3'
indexPrefix :'service_log',
indexSuffixBy :'quarter', //available are monthly('m','M','month'), quarterly('q','Q','quarter') and bi-annually('h','H','halfYear')
indexSettings:{ // custom setting for index creating
index:{
refresh_interval:'20s'
}
}
})
)
Members
##logger.request
Document indexed with ElasticSearch. request
and response
properties
are included if they are whitelisted by config.whitelist
.
Properties
String
- defaults to "development"Error
- error object passed to next()
Number
- milliseconds between request and responseObject
String
Object
String
String
String
String
Object
Object
Number
Object
Number
- OS total memory in bytesNumber
- OS free memory in bytesArray.<Number>
- Array of 5, 10, and 15 min averagesObject
Number
- process memory in bytesString
- ISO time of requestType: Object
##logger.requestHandler(config, [client])
Returns Express middleware configured according to given options
.
Middleware must be mounted before all other middleware to ensure accurate capture of requests. The error handler must be mounted before other error handler middleware.
Params
Object
- elasticsearch configuration
String
- elasticsearch index (default: log_YEAR_MONTH)String
- elasticsearch request type (default: request)Object
Array.<String>
- request properties to logArray.<String>
- response properties to logArray.<String>
- list of request body properties to censor, this config will deep censor your data. for example, if you input 'data.deepdata'
, your property deepdata
inside data
object will be marked as CENSOREDelasticsearch.Client
- elasticsearch clientReturns: elasticsearchLoggerMiddleware
- express middleware
Example
var express = require('express');
var logger = require('express-elasticsearch-logger');
var app = express();
app
.use(logger.requestHandler({
host: 'http://localhost:9200'
}))
.get('/', function (req, res, next) {
res.sendStatus(204);
})
.use(logger.errorHandler)
.listen(8888);
##logger.errorHandler(err, req, res, next)
Error handler middleware exposes error to Response#end
This middleware is used in combination with requestHandler to capture request errors.
Params
Error
express.Request
express.Response
express.Request.next
Please submit all issues and pull requests to the alexmingoia/express-elasticsearch-logger repository!
Run tests using npm test
.
If you have any problem or suggestion please open an issue here.
FAQs
Log Express app requests to ElasticSearch.
The npm package @rentspree/express-elasticsearch-logger receives a total of 4 weekly downloads. As such, @rentspree/express-elasticsearch-logger popularity was classified as not popular.
We found that @rentspree/express-elasticsearch-logger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.