-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[logging/metrics] Provide ability to log ops data from core metrics service #86162
Comments
Pinging @elastic/kibana-core (Team:Core) |
@lukeelmers I've gone with intercepting Logging metrics from within refreshMetrics()// src/core/server/metrics/metrics_service.ts
private async refreshMetrics() {
this.logger.debug('Refreshing metrics');
const metrics = await this.metricsCollector!.collect(); // capture the metrics
const opsLogsMetrics = this.extractOpsLogsData(metrics); // extract and format the metrics for logging
this.logger.info(opsLogsMetrics); // log the metrics out
this.metricsCollector!.reset();
this.metrics$.next(metrics);
} extracting and formatting metrics for logging:// src/core/server/mertics/metrics_service.ts
private extractOpsLogsData({ process, os }: Partial<OpsMetrics>): string {
const memoryLogEntryInMB = numeral(process?.memory?.heap?.used_in_bytes ?? 0).format('0.0b');
// ProcessMetricsCollector converts from seconds to milliseconds. Format here is HH:mm:ss for backward compatibility
const uptimeLogEntry = numeral((process?.uptime_in_millis ?? 0) / 1000).format('00:00:00');
const loadLogEntry = [...Object.values(os?.load ?? [])]
.map((val: number) => {
return numeral(val).format('0.00');
})
.join(' ');
const delayLogEntry = numeral(process?.event_loop_delay ?? 0).format('0.000');
return `memory: ${memoryLogEntryInMB} uptime: ${uptimeLogEntry} load: [${loadLogEntry}] delay: ${delayLogEntry}`;
} Example of the output: With logging appenders:
Without appenders, the logs are forwarded to the legacy logging system and we will get duplicate data:
I'd like to make sure this is the correct approach and there aren't any obvious issues with it, before diving into integration tests (for which I'll need to call on you for some more guidance 😉 ). |
That's the same issue @lukeelmers encountered with with request/response logging in #13241. I guess the solution will be to log them under the |
@pgayvallet In my draft for this work, I've gone with logging the data under the |
Related to #13241
In the legacy platform, we rely on the
@hapi/good
ops event for automatically logging ops metrics at a particular interval. TheopsInterval
is configurable and provided to the hapi/good configuration via the legacy logging server.As part of our effort to remove our dependency on
@hapi/good
, we should provide some equivalent functionality in the Kibana platform logger via the metrics service.Currently good includes a handful of metrics in the ops event payload**, however the legacy logger only pulls the following items from the ops event payload:
@hapi/good
ops payload'ops'
)@timestamp
** More detail on the items good includes in the payload can be found in these old docs from
even-better
Tasks:
ops.interval
from configops.interval
to specify the collection intervalOpen questions / things to investigate:
'metrics'
probably makes the most sense unless there's a reason we want it to be separate from the logs related to the service itself@kbn/legacy-logging
that still preserves BWC?The text was updated successfully, but these errors were encountered: