-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: Expose log count metric from Runner #684
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import express from 'express'; | ||
import { Gauge, Histogram, Counter, AggregatorRegistry } from 'prom-client'; | ||
import { Gauge, Histogram, Counter, AggregatorRegistry, register } from 'prom-client'; | ||
|
||
import logger from './logger'; | ||
|
||
|
@@ -56,6 +56,12 @@ const EXECUTION_DURATION = new Histogram({ | |
labelNames: ['indexer'], | ||
}); | ||
|
||
const LOGS_COUNT = new Counter({ | ||
name: 'queryapi_runner_logs_count', | ||
help: 'Number of messages logged', | ||
labelNames: ['level'], | ||
}); | ||
|
||
export const METRICS = { | ||
HEAP_TOTAL_ALLOCATION, | ||
HEAP_USED, | ||
|
@@ -66,6 +72,7 @@ export const METRICS = { | |
UNPROCESSED_STREAM_MESSAGES, | ||
LAST_PROCESSED_BLOCK_HEIGHT, | ||
EXECUTION_DURATION, | ||
LOGS_COUNT | ||
}; | ||
|
||
const aggregatorRegistry = new AggregatorRegistry(); | ||
|
@@ -87,7 +94,9 @@ export const startServer = async (): Promise<void> => { | |
app.get('/metrics', async (_req, res) => { | ||
res.set('Content-Type', aggregatorRegistry.contentType); | ||
|
||
const metrics = await AggregatorRegistry.aggregate(Array.from(workerMetrics.values())).metrics(); | ||
const mainThreadMetrics = await register.getMetricsAsJSON(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What extra information does this provide? It seems we weren't getting this before. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I outlined this in the description - mainly just the log counts :) |
||
const metrics = await AggregatorRegistry.aggregate([...Array.from(workerMetrics.values()), mainThreadMetrics]).metrics(); | ||
|
||
res.send(metrics); | ||
}); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this going to count only .log calls? Or is this applied to all log calls (.warn, .error, etc.)? Another thing, it would be nice if we could similarly differentiate between error logs too for metrics. For example, it would be nice to distinguish between a single "Encountering error processing stream" error log and many "Error writing..." error calls. The former indicating the worker shut down whereas the latter could be any of these three: Hasura is down, our system queries are malformed, or an indexer is trying to run some faulty query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could definitely add that, but it may be expensive given all the different log messages. My motive behind this was to be able to quickly see if we are erroring out from Grafana, alert from it, and then go in to GCP to see the actual issue/log messages.