Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more capabilities for severity and priority #26

Open
kenperkins opened this issue Dec 10, 2014 · 10 comments
Open

Add more capabilities for severity and priority #26

kenperkins opened this issue Dec 10, 2014 · 10 comments

Comments

@kenperkins
Copy link
Owner

Figure out how to not hardcode <25> as part of our message to Papertrail. I presume there is a specification for this, perhaps as part of syslog. cc @eric for more info

@troy
Copy link
Contributor

troy commented Dec 10, 2014

Sure is, it's RFC 3164 in section 4.1.1, "PRI part." You'll see the facilities and severities listed with names and IDs and how to calculating the resulting PRI.

I recommend retaining the same facility for all messages and only changing the severity. The challenge is deciding what messages are more critical severity. If event severity is exposed from Node and Winston, I'd make it 1-to-1 (or many-to-1 if it has lots of severities) with that.

If it's not exposed, a static value like exists today may be the best that the adaptor can do.

@kenperkins
Copy link
Owner Author

Winston supports log levels, i.e. debug, verbose, info, warn and error are common levels. Generally speaking error (and maybe crit) are considered the most severe.

@kenperkins
Copy link
Owner Author

Excerpt:

The Priority value is calculated by first multiplying the Facility
   number by 8 and then adding the numerical value of the Severity. For
   example, a kernel message (Facility=0) with a Severity of Emergency
   (Severity=0) would have a Priority value of 0.  Also, a "local use 4"
   message (Facility=20) with a Severity of Notice (Severity=5) would
   have a Priority value of 165.  In the PRI part of a syslog message,
   these values would be placed between the angle brackets as <0> and
   <165> respectively.  The only time a value of "0" will follow the "<"
   is for the Priority value of "0". Otherwise, leading "0"s MUST NOT be
   used.

So do we still want to use a hardcoded facility (25) and then map log levels to severity and formulate accordingly? That doesn't seem terrible. Does Papertrail make use of this information?

@troy
Copy link
Contributor

troy commented Dec 10, 2014

Yes, though the current hardcoded 25 is the value of both severity and facility, so it will go away entirely. I'd recommend using Local0 or User for the hardcoded facility. With User, facility code 1, the resulting value would be 1 * 8 + the severity code, or 8 + 2 = 10 for critical.

All of these values have one major problem: they're set once by the framework developer, not by the app developer or ops staff, even though something that is critical in one environment is debug in another. Papertrail uses that as a design consideration and puts relatively little faith in these. They're usable as search attributes (for example, severity:error or severity:(err crit)) and retained in log archives, but don't appear in the interactive log viewer.

@kenperkins
Copy link
Owner Author

It wouldn't be hard to tell the transport what facility to use at transport creation time.

@kenperkins
Copy link
Owner Author

This appears to be resolved as part of #29

@kenperkins
Copy link
Owner Author

And of course I published this, without reconciling that @jahqueel's work on #29 is a different RFC than this one. I'll have to do some due diligence to see how these RFCs are different.

@eric
Copy link
Contributor

eric commented Dec 17, 2014

Using the newer RFC isn't a problem at all (and is preferable) for Papertrail.

@eric
Copy link
Contributor

eric commented Dec 17, 2014

I haven't reviewed the library in detail to ensure that it is compliant, but assuming it is, everything should be great.

@kenperkins
Copy link
Owner Author

I (probably not obviously) tested it against Papertrail, and was able to search on severity successfully. But, I didn't do any research beyond that before I published. I assumed (When it worked) that it was the same RFC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants