Esempio n. 1
0
    def start_parse_unstructured_data(self, action, **params):
        session = cherrypy.session.get("sessionKey")
        splunk_uri = scc.getMgmtUri()
        app_name = params['app_name']
        sourcetype = params['sourcetype']
        batch_size = params.get("batch_size", None)

        try:
            tabuilder = TABuilder(app_name, splunk_uri, session)
            tabuilder.remove_all_unstructured_data_inputs()
            tabuilder.start_parse_unstructured_data(sourcetype, batch_size)
            return self.render_json({"data": {"successful": True,
                                              "app_name": app_name,
                                              "sourcetype": sourcetype}})

        except CommonException as e:
            tabuilder.cancel_parse_unstructured_data(sourcetype)
            logger.error('Get CommonException when getting auto extraction results. meta:%s, error:%s',
                         params, traceback.format_exc())
            return self.render_json({'err_code': e.get_err_code(),
                                     'err_args': e.get_options()})
        except Exception as e:
            tabuilder.cancel_parse_unstructured_data(sourcetype)
            logger.error("Cannot get extractions for sourcetype %s. error: %s",
                         sourcetype, traceback.format_exc())
            raise e
Esempio n. 2
0
    def get_unstructured_data_status(self, action, **params):
        session = cherrypy.session.get("sessionKey")
        splunk_uri = scc.getMgmtUri()
        app_name = params['app_name']
        sourcetype = params['sourcetype']

        try:
            tabuilder = TABuilder(app_name, splunk_uri, session)
            results = tabuilder.get_unstructured_data_status(sourcetype)
            if results.get("error"):
                tabuilder.cancel_parse_unstructured_data(sourcetype)
                return self.render_json(results.get("error"))

            return self.render_json({"data": results})
        except CommonException as e:
            tabuilder.cancel_parse_unstructured_data(sourcetype)
            logger.error('Get CommonException when getting auto extraction results. meta:%s, error:%s',
                         params, traceback.format_exc())
            return self.render_json({'err_code': e.get_err_code(),
                                     'err_args': e.get_options()})
        except Exception as e:
            tabuilder.cancel_parse_unstructured_data(sourcetype)
            logger.error("Cannot get extractions for sourcetype %s. error: %s",
                         sourcetype, traceback.format_exc())
            raise e