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

Centralised logging for cryptnono? #2891

Open
manics opened this issue Jan 12, 2024 · 0 comments
Open

Centralised logging for cryptnono? #2891

manics opened this issue Jan 12, 2024 · 0 comments

Comments

@manics
Copy link
Member

manics commented Jan 12, 2024

Currently the Cryptnono pod logs are lost when there's an update.

There is a lot of interesting information in the logs, including, which cryptnominers were detected, processes that were incorrectly killed, which repos were involved, etc.

Could we forward the logs to a persistent location? BinderHub already sends some event logs to Google Cloud Logs

01-eventlog: |
import os
import google.cloud.logging
import google.cloud.logging.handlers
from traitlets.log import get_logger
# importing google cloud configures a root log handler,
# which prevents tornado's pretty-logging
import logging
logging.getLogger().handlers = []
class JSONCloudLoggingHandler(google.cloud.logging.handlers.CloudLoggingHandler):
def emit(self, record):
record.name = None
super().emit(record)
def _make_eventsink_handler(el):
client = google.cloud.logging.Client()
# These events are not parsed as JSON in stackdriver, so give it a different name
# for now. Should be fixed in https://github.com/googleapis/google-cloud-python/pull/6293
name = os.environ.get("EVENT_LOG_NAME") or "binderhub-events-text"
get_logger().info("Sending event logs to %s/logs/%s", client.project, name)
return [JSONCloudLoggingHandler(client, name=name)]
c.EventLog.handlers_maker = _make_eventsink_handler

so we could do something similar, though there'll be a cost for storing the logs.

Alternatively we could store them somewhere else?

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

1 participant