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)
def get(self, job_id): parser = reqparse.RequestParser() parser.add_argument('start_time', type=int, location='args', required=False, help='start_time must be timestamp') parser.add_argument('max_lines', type=int, location='args', required=True, help='max_lines is required') data = parser.parse_args() start_time = data['start_time'] max_lines = data['max_lines'] job = _get_job(job_id) if start_time is None: start_time = job.workflow.start_at return {'data': es.query_events(Envs.ES_INDEX, job.name, 'fedlearner-operator', start_time, int(time.time() * 1000 ), Envs.OPERATOR_LOG_MATCH_PHRASE )[:max_lines][::-1]}