Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
A client implementation for Loggly in node.js
curl http://npmjs.org/install.sh | sh
[sudo] npm install loggly
The node-loggly library is compliant with the Loggly API. Using node-loggly is easy for a variety of scenarios: logging, working with devices and inputs, searching, and facet searching.
Before we can do anything with loggly, we have to create a client with valid credentials. We will authenticate for you automatically:
var loggly = require('loggly'); var config = { subdomain: "your-subdomain", auth: { username: "your-username", password: "your-password" } }; var client = loggly.createClient(config);
There are two ways to send log information to loggly via node-loggly. The first is to simply call client.log with an appropriate input token:
client.log('your-really-long-input-token', '127.0.0.1 - Theres no place like home', function (err, result) { // Do something once you've logged });
Note that the callback in the above example is optional, if you prefer the 'fire and forget' method of logging:
client.log('your-really-long-input-token', '127.0.0.1 - Theres no place like home');
The second way to send log information to loggly is to do so once you've retrieved an input directly from loggly:
client.getInput('your-input-name', function (err, input) { input.log('127.0.0.1 - Theres no place like home'); });
Again the callback in the above example is optional and you can pass it if you'd like to.
In addition to logging pure strings it is also possible to pass shallow JSON object literals (i.e. no nested objects) to client.log(..) or input.log(..) methods, which will get converted into the Loggly recommended string representation. So
var source = { foo: 1, bar: 2, buzz: 3 }; input.log(source);
will be logged as:
foo=1,bar=2,buzz=3
Searching with node-loggly is easy. All you have to do is use the search() method defined on each loggly client:
var util = require('util'); client.search('404', function (err, results) { // Inspect the result set util.inspect(results.data); });
The search() exposes a chainable interface that allows you to set additional search parameters such as: ip, input name, rows, start, end, etc.
var util = require('util'); client.search('404') .meta({ ip: '127.0.0.1', inputname: test }) .context({ rows: 10 }) .run(function (err, results) { // Inspect the result set util.inspect(results.data); });
The context of the search (set using the .context()
method) represents additional parameters in the Loggly API besides the search query itself. See the Search API documentation for a list of all options.
Metadata set using the .meta()
method is data that is set in the query parameter of your Loggly search, but :
delimited. For more information about search queries in Loggly, check out the Search Language Guide on the Loggly Wiki.
Loggly also exposes searches that can return counts of events over a time range. These are called facets. The valid facets are 'ip', 'date', and 'input'. Performing a facet search is very similar to a normal search:
var util = require('util'); client.facet('ip', '404') .context({ rows: 10 }) .run(function (err, results) { // Inspect the result set util.inspect(results.data); });
The chaining and options for the facet method(s) are the same as the search method above.
Loggly exposes several entities that are available through node-loggly: inputs and devices. For more information about these terms, checkout the Loggly Jargon on the wiki. There are several methods available in node-loggly to work with these entities:
// // Returns all inputs associated with your account // client.getInputs(function (err, inputs) { /* ... */ }); // // Returns an input with the specified name // client.getInput('input-name', function (err, input) { /* ... */ }); // // Returns all devices associated with your account // client.getDevices(function (err, devices) { /* ... */ });
All of the node-loggly tests are written in vows, and cover all of the use cases described above. You will need to add your Loggly username, password, subdomain, and a test input to test/data/test-config.json before running tests:
{ "subdomain": "your-subdomain", "auth": { "username": "your-username", "password": "your-password" }, "inputs": [{ "token": "your-really-long-token-you-got-when-you-created-an-http-input", "id": 000 // ID of this input }] }
Once you have valid Rackspace credentials you can run tests with vows:
vows test/*-test.js --spec
FAQs
A client implementation for Loggly cloud Logging-as-a-Service API
The npm package loggly receives a total of 31,390 weekly downloads. As such, loggly popularity was classified as popular.
We found that loggly demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.