Exemple #1
0
 def GetJobEvents(self, request, context):
     try:
         return self._server.get_job_events(request, context)
     except UnauthorizedException as e:
         return service_pb2.GetJobEventsResponse(status=common_pb2.Status(
             code=common_pb2.STATUS_UNAUTHORIZED, msg=repr(e)))
     except Exception as e:
         logging.error('GetJobMetrics rpc server error: %s', repr(e))
         return service_pb2.GetJobEventsResponse(status=common_pb2.Status(
             code=common_pb2.STATUS_UNKNOWN_ERROR, msg=repr(e)))
Exemple #2
0
    def get_job_events(self, request, context):
        with self._app.app_context():
            project, party = self.check_auth_info(request.auth_info, context)
            job = Job.query.filter_by(name=request.job_name,
                                      project_id=project.id).first
            assert job is not None, \
                f'Job {request.job_name} not found'

            result = es.query_events('filebeat-*', job.name,
                                     'fedlearner-operator', request.start_time,
                                     int(time.time() *
                                         1000))[:request.max_lines][::-1]

            return service_pb2.GetJobEventsResponse(
                status=common_pb2.Status(code=common_pb2.STATUS_SUCCESS),
                logs=result)