Add experiment auditing to events api
@@ -6,6 +6,8 @@ from websockets import ConnectionClosed
from django.core.exceptions import ValidationError
+import auditor
+from event_manager.events.experiment import EXPERIMENT_RESOURCES_VIEWED, EXPERIMENT_LOGS_VIEWED
from event_monitors.authentication import authorized
from event_monitors.consumers import Consumer
from event_monitors.socket_manager import SocketManager
@@ -132,6 +134,7 @@ async def experiment_resources(request, ws, username, project_name, experiment_s
exceptions.Forbidden("You don't have access to this project")
experiment = _get_validated_experiment(project, experiment_sequence)
experiment_uuid = experiment.uuid.hex
+ auditor.record(event_type=EXPERIMENT_RESOURCES_VIEWED, instance=experiment)
if not RedisToStream.is_monitored_experiment_resources(experiment_uuid=experiment_uuid):
logger.info(
@@ -270,6 +273,7 @@ async def experiment_logs(request, ws, username, project_name, experiment_sequen
exceptions.Forbidden("You don't have access to this project")
experiment = _get_validated_experiment(project, experiment_sequence)
experiment_uuid = experiment.uuid.hex
+ auditor.record(event_type=EXPERIMENT_LOGS_VIEWED, instance=experiment)
if not RedisToStream.is_monitored_experiment_logs(experiment_uuid=experiment_uuid):
logger.info('Experiment uuid `%s` logs is now being monitored', experiment_uuid)
