Skip to content

reduce log level in metrics logger not to trash the log #708

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nirrozenbaum
Copy link
Contributor

metrics logger is trashing the epp log. so instead of allowing a focused view of what changed, the epp log looks like this:

{"level":"Level(-3)","ts":"2025-04-17T21:04:48Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:04:53Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:04:58Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:05:03Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:05:08Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"info","ts":"2025-04-17T21:05:10Z","caller":"runnable/grpc.go:19","msg":"gRPC server starting","name":"ext-proc"}
{"level":"info","ts":"2025-04-17T21:05:10Z","caller":"runnable/grpc.go:28","msg":"gRPC server listening","name":"ext-proc","port":9002}
{"level":"Level(-3)","ts":"2025-04-17T21:05:13Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:05:18Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:05:23Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:05:28Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:05:33Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:05:38Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:05:43Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:05:48Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:05:53Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:05:58Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:06:03Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:06:08Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:06:13Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:06:18Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:06:23Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:06:28Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:06:33Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:06:38Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:06:43Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:06:48Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:06:53Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:06:58Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:07:03Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:07:08Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:07:13Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:07:18Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:07:23Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:07:28Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:07:33Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:07:38Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:07:43Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:07:48Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:07:53Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:07:58Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:08:03Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:08:08Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:08:13Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:08:18Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:08:23Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:08:28Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}
{"level":"Level(-3)","ts":"2025-04-17T21:08:33Z","caller":"metrics/logger.go:101","msg":"Flushing Prometheus Metrics","ReadyPods":1}

since EPP default log level is 4, this PR reduces the log level of the metrics logger (only this specific message) to TRACE to reduce this noise in the log.

additionally, as a followup to previous PR, change in few more places to use NamespacedName instead of passing around name + namespace as separate args.

Signed-off-by: Nir Rozenbaum <nirro@il.ibm.com>
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 17, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nirrozenbaum
Once this PR has been reviewed and has the lgtm label, please assign ahg-g for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested review from ahg-g and robscott April 17, 2025 21:14
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 17, 2025
@nirrozenbaum
Copy link
Contributor Author

cc @kfswain

Copy link

netlify bot commented Apr 17, 2025

Deploy Preview for gateway-api-inference-extension ready!

Name Link
🔨 Latest commit c9a456f
🔍 Latest deploy log https://app.netlify.com/sites/gateway-api-inference-extension/deploys/6803d7f5dcb8890008b69079
😎 Deploy Preview https://deploy-preview-708--gateway-api-inference-extension.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@danehans
Copy link
Contributor

+1 on changing the log level to DEBUG. Additionally, pool in the following log message should be capitalized:

logger.V(logutil.DEFAULT).Info("pool is not initialized, skipping flushing metrics")

In reviewing flushPrometheusMetricsOnce(), the Pod metrics are not being "flushed" but are instead being "Regenerated", "Recalculated", etc. We should consider renaming the function and the associated log message.

Signed-off-by: Nir Rozenbaum <nirro@il.ibm.com>
@nirrozenbaum
Copy link
Contributor Author

+1 on changing the log level to DEBUG. Additionally, pool in the following log message should be capitalized:

logger.V(logutil.DEFAULT).Info("pool is not initialized, skipping flushing metrics")

In reviewing flushPrometheusMetricsOnce(), the Pod metrics are not being "flushed" but are instead being "Regenerated", "Recalculated", etc. We should consider renaming the function and the associated log message.

@danehans updated the log level and capitalized log message.
as for the function name, I updated it to refreshPrometheusMetrics to stay aligned with the terminology used in the code (the cmd-ling flag is called refreshPrometheusMetricsInterval, the function arg is called refreshPrometheusMetricsInterval, default value is defined in runserver.DefaultRefreshPrometheusMetricsInterval, etc)

return
}

var kvCacheTotal float64
var queueTotal int

podMetrics := datastore.PodGetAll()
logger.V(logutil.VERBOSE).Info("Flushing Prometheus Metrics", "ReadyPods", len(podMetrics))
logger.V(logutil.TRACE).Info("Refreshing Prometheus Metrics", "ReadyPods", len(podMetrics))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an alternative log in verbose or default level that logs the number of ready pods when they change?

Copy link
Contributor Author

@nirrozenbaum nirrozenbaum Apr 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen any other place logging the ready pods (it's reported as a metric though).
I completely agree this is information we would like to know.

having said that, I don't think it belongs here.
the refreshMetrics function runs every few seconds to update metrics, which makes perfect sense since we would like to update metrics very frequently.
BUT, printing to the EPP log the number of ready pods every 5 seconds is spamming the log and making it very hard to debug (see example above).

IMO the number of pods in the pool shouldn't be printed as part of metrics recalculation function, it should be part of the Inf Pool status (kinda similar to ready pods status in deployment).
we could easily add this field to Inf Pool status + additional printer columns to show it when running kubectl get InferencePool. it's pretty easy to implement in the controllers reconcile event which also updates only when something changes (as opposed to this log printing, which happens every 5 seconds even if nothing has changed).
If this sounds reasonable I'm happy to implement it this week.

@ahg-g cc @kfswain

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proposed this change in #714

Signed-off-by: Nir Rozenbaum <nirro@il.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants