Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
statsd-parser
Advanced tools
a streaming parser for the statsd protocol
npm install statsd-parser
var statsd_parser = require('statsd-parser');
var statsd_parser = require("statsd-parser")
, parser = statsd_parser.parser()
;
parser.onerror = function (e) {
// an error happened. e is the error
};
parser.onstat = function (txt, obj) {
// got some value
};
parser.onend = function () {
// parser stream is done, and ready to have more stuff written to it.
};
parser.write('foo.bar:1|c').close();
//
// stream usage
// takes the same options as the parser
//
var stream = require("statsd-parser").createStream(options);
stream.on("error", function (e) {
// unhandled errors will throw, since this is a proper node
// event emitter.
console.error("error!", e);
// clear the error
this._parser.error = null;
this._parser.resume();
})
stream.on("stat", function (txt, obj) {
// same object as above
});
//
// pipe is supported, and it's readable/writable
// same chunks coming in also go out
//
fs.createReadStream("file.statsd")
.pipe(stream)
.pipe(fs.createReadStream("file-fixed.statsd"))
you also have two helper functions to see if a string is a statsd stat isStatsd
and one to check extract values from a statsd string (or null if it's not statsd)
> var statsd = require('statsd-parser');
> statsd.isStatsd('a:1|c|@0.1')
true
> statsd.matchStatsd('a:1|c|@0.1')
{ stat: 'a',
value: '1',
type: 'c',
sample_rate: '0.1' }
> statsd.matchStatsd('b:200|s')
{ stat: 'b',
value: '200',
type: 's' }
> statsd.matchStatsd('b:200|s@INVALID')
null
everyone is welcome to contribute. patches, bug-fixes, new features
statsd-parser
git checkout -b my_branch
git push origin my_branch
git clone git://github.com/dscape/statsd-parser.git
(oO)--',-
in caos
FAQs
Streaming parser for the statsd protocol
The npm package statsd-parser receives a total of 18,330 weekly downloads. As such, statsd-parser popularity was classified as popular.
We found that statsd-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.