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 support for log metrics #9

Open
calebhailey opened this issue Feb 24, 2021 · 1 comment
Open

Add support for log metrics #9

calebhailey opened this issue Feb 24, 2021 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@calebhailey
Copy link

Add support for extracting actual metrics reported in a log file, or generating/calculating metrics based on some trend or "pattern" in a log file (e.g. "N errors in the last 10 seconds"). The latter capability more or less already exists via the -match flag, but it would need to produce event.metrics as a result.

@echlebek
Copy link
Contributor

echlebek commented Mar 1, 2021

What if we enabled an SQL interface to accomplish this? We could stream the log into an in-memory sqlite database and allow users to produce metrics with SQL.

For instance, assume our log is a series of JSON objects, and we make the top level keys available:

{"verb": "GET", "status": 200, "user": "kermit"}
{"verb": "POST", "status": 301, "user": "ms. piggy"}
{"verb": "GET", "status": 404, "user": "cookie monster"}
WITH ok_status(count) AS (SELECT count(status) FROM log WHERE log.status = 200)
WITH kermit_requests(count) AS (SELECT count(user) FROM log WHERE log.user = 'kermit')
SELECT ok_status.count AS ok_requests, kermit_requests.count AS kermit_requests
FROM ok_status, kermit_requests;

sensu-check-log can use the resulting table to create Sensu metrics. We could even get fancy and output labels.

@calebhailey calebhailey added this to the 6.6.0 milestone Sep 24, 2021
@calebhailey calebhailey modified the milestones: 6.6.0, 6.next Nov 15, 2021
@asachs01 asachs01 added the enhancement New feature or request label Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants