本文整理汇总了Python中splunk.models.saved_search.SavedSearch类的典型用法代码示例。如果您正苦于以下问题:Python SavedSearch类的具体用法?Python SavedSearch怎么用?Python SavedSearch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SavedSearch类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_headlines_detail
def get_headlines_detail(self, headlines, app, user, count, earliest, severity=None, srtd=None):
search_string = ""
sorted_list = []
if earliest is not None:
search_string = search_string + ' trigger_time > ' + str(self.get_time(earliest))
for headline in headlines:
try:
s = SavedSearch.get(SavedSearch.build_id(headline.alert_name, app, user))
alerts = None
if s.alert.severity in severity:
alerts = s.get_alerts()
if alerts is not None:
if len(search_string) > 0:
alerts.search(search_string)
for alert in alerts:
h = {'message' : self.replace_tokens(headline.message, alert.sid),
'job_id' : alert.sid,
'severity' : s.alert.severity,
'count' : alert.triggered_alerts,
'time' : alert.trigger_time.strftime('%s'),
'timesince' : timesince(alert.trigger_time)}
sorted_list.append(h)
except Exception, ex:
logger.warn('problem retreiving alerts for saved search %s' % headline.alert_name)
logger.debug(ex)
开发者ID:parth88,项目名称:GitHub,代码行数:26,代码来源:unixheadlines.py
示例2: create
def create(self, app, action, **params):
owner = splunk.auth.getCurrentUser()['name']
params['name'] = params.get('name', '')
saved_search = SavedSearch(app, owner, **params)
saved_search.metadata.sharing = params.get('sharing', 'user')
if saved_search.passive_save():
raise cherrypy.HTTPRedirect(self.make_url(['savesearchwizard', app, 'success'], _qs=dict(id=saved_search.id)), 303)
return self.render_template('savesearchwizard/new.html', dict(app=app, saved_search=saved_search))
开发者ID:DRArpitha,项目名称:splunk,代码行数:8,代码来源:savesearchwizard.py
示例3: step1_new
def step1_new(self, app, step, action, **params):
owner = splunk.auth.getCurrentUser()["name"]
params["name"] = params.get("name", "")
saved_search = SavedSearch(app, owner, **params)
saved_search.ui_howoften = "realtime"
saved_search.ui_schedule = None
saved_search.ui_rolling_value = "1"
saved_search.ui_rolling_unit = None
return self.render_template("alertswizardv2/step1_new.html", dict(app=app, saved_search=saved_search))
开发者ID:mealy,项目名称:splunk,代码行数:9,代码来源:alertswizardv2.py
示例4: new
def new(self, app, action, **params):
owner = splunk.auth.getCurrentUser()['name']
params['name'] = params.get('name', '')
saved_search = SavedSearch(app, owner, **params)
saved_search.setSummarizationDetails()
return self.render_template('savesearchwizard/new.html', dict(app=app, saved_search=saved_search))
开发者ID:MobileWebApps,项目名称:splunk-search-tools-app,代码行数:9,代码来源:savesearchwizard.py
示例5: step1_create
def step1_create(self, app, step, action, **params):
owner = splunk.auth.getCurrentUser()['name']
saved_search = SavedSearch(app, owner, **params)
saved_search.is_disabled = True
# no need to suppress or track dashboard searches
saved_search.alert.track = False
saved_search.alert.suppress.enabled = False
if saved_search.passive_save():
raise cherrypy.HTTPRedirect(self.make_url(['dashboardwizard', app, 'step2', 'new'], _qs=dict(id=saved_search.id)), 303)
return self.render_template('dashboardwizard/step1_new.html', dict(app=app, saved_search=saved_search))
开发者ID:DRArpitha,项目名称:splunk,代码行数:10,代码来源:dashboardwizard.py
示例6: step1_create
def step1_create(self, app, step, action, **params):
owner = splunk.auth.getCurrentUser()['name']
params['name'] = params.get('name', '')
saved_search = SavedSearch(app, owner, **params)
saved_search.is_disabled = True
self.step1_from_ui(params, saved_search)
if saved_search.passive_save():
raise cherrypy.HTTPRedirect(self.make_url(['scheduledigestwizard', app, 'step2'], _qs=dict(id=saved_search.id)), 303)
self.step1_to_ui(saved_search)
return self.render_template('scheduledigestwizard/step1_new.html', dict(app=app, saved_search=saved_search))
开发者ID:MobileWebApps,项目名称:splunk-search-tools-app,代码行数:10,代码来源:scheduledigestwizard.py
示例7: step1_create
def step1_create(self, app, step, action, **params):
owner = splunk.auth.getCurrentUser()["name"]
params["name"] = params.get("name", "")
saved_search = SavedSearch(app, owner, **params)
saved_search.is_disabled = True
self.step1_from_ui(params, saved_search)
if len(saved_search.errors) == 0 and saved_search.passive_save():
raise cherrypy.HTTPRedirect(
self.make_url(["alertswizardv2", app, "step2"], _qs=dict(id=saved_search.id)), 303
)
self.step1_to_ui(saved_search)
return self.render_template("alertswizardv2/step1_new.html", dict(app=app, saved_search=saved_search))
开发者ID:mealy,项目名称:splunk,代码行数:12,代码来源:alertswizardv2.py
示例8: create
def create(self, app, action, **params):
owner = splunk.auth.getCurrentUser()['name']
params['name'] = params.get('name', '')
saved_search = SavedSearch(app, owner, **params)
saved_search.metadata.sharing = params.get('sharing', 'user')
#TODO: remove this
#saved_search.auto_summarize.cron_schedule = '*/10 * * * *'
if saved_search.passive_save():
raise cherrypy.HTTPRedirect(self.make_url(['savesearchwizard', app, 'success'], _qs=dict(id=saved_search.id)), 303)
saved_search.setSummarizationDetails()
return self.render_template('savesearchwizard/new.html', dict(app=app, saved_search=saved_search))
开发者ID:MobileWebApps,项目名称:splunk-search-tools-app,代码行数:15,代码来源:savesearchwizard.py
示例9: step3_update
def step3_update(self, app, step, action, **params):
saved_search = SavedSearch.get(params.get('id'))
saved_search.update(params)
saved_search.action.rss.enabled = False if params.get('action.rss.enabled') is None else True
saved_search.action.script.enabled = False if params.get('action.script.enabled') is None else True
saved_search.action.email.enabled = False if params.get('action.email.enabled') is None else True
email_results_type = params.get('email_results_type')
if email_results_type == 'csv':
saved_search.action.email.format = 'csv'
saved_search.action.email.sendresults = True
saved_search.action.email.inline = False
elif email_results_type == 'inline':
saved_search.action.email.format = 'html'
saved_search.action.email.sendresults = True
saved_search.action.email.inline = True
elif email_results_type == 'pdf':
saved_search.action.email.format = None
saved_search.action.email.sendresults = False
saved_search.action.email.sendpdf = True
elif email_results_type == 'raw' or email_results_type == 'plain':
saved_search.action.email.format = email_results_type
saved_search.action.email.sendresults = True
saved_search.action.email.inline = True
saved_search.alert.track = False if params.get('alert.track') is None else True
saved_search.is_disabled = False
has_action = saved_search.action.email.enabled or saved_search.action.rss.enabled or saved_search.action.script.enabled or saved_search.alert.track
if saved_search.passive_save() and has_action:
raise cherrypy.HTTPRedirect(self.make_url(['alertswizard', app, 'success'], _qs=dict(id=saved_search.id)), 303)
pdf_config = PDFConfig.get()
if has_action is False:
saved_search.errors.append(_('Please select at least one action'))
return self.render_template('alertswizard/step3.html', dict(app=app, email_results_type=email_results_type, saved_search=saved_search, pdf_config=pdf_config))
开发者ID:DRArpitha,项目名称:splunk,代码行数:32,代码来源:alertswizard.py
示例10: step3_update
def step3_update(self, app, step, action, **params):
saved_search = SavedSearch.get(params.get("id"))
saved_search.update(params)
saved_search.is_disabled = False
metadata_sharing = params.get("metadata.sharing")
if metadata_sharing == "user":
try:
saved_search.unshare()
except Exception:
saved_search.errors = [
_(
"Search %s cannot be private because it already exists. Try using another search name by cancelling this alert and creating a new one."
)
% saved_search.name
]
elif metadata_sharing == "app":
try:
saved_search.share_app()
except Exception:
saved_search.errors = [
_(
"Search %s cannot be shared because it already exists. Try using another search name by cancelling this alert and creating a new one."
)
% saved_search.name
]
if not saved_search.errors and saved_search.passive_save():
raise cherrypy.HTTPRedirect(
self.make_url(["alertswizardv2", app, "success"], _qs=dict(id=saved_search.id)), 303
)
self.step1_to_ui(saved_search)
return self.render_template("alertswizardv2/step3.html", dict(app=app, saved_search=saved_search))
开发者ID:mealy,项目名称:splunk,代码行数:31,代码来源:alertswizardv2.py
示例11: step3_update
def step3_update(self, app, step, action, **params):
# saved search models
saved_search = SavedSearch.get(params.get('id'))
schedule_type = params.get('schedule_type')
saved_search.schedule.is_scheduled = True
saved_search.is_disabled = False
if schedule_type=='preset':
alert_preset = params.get('alert_preset')
if alert_preset=='cron':
saved_search.schedule.cron_schedule = params.get('alert_cron')
else:
saved_search.schedule.cron_schedule = alert_preset
elif schedule_type=='never':
saved_search.schedule.is_scheduled = False
saved_search.schedule.cron_schedule = None
elif schedule_type=='continuous':
saved_search.schedule.cron_schedule = '* * * * *'
# dashboard model
dashboard = Dashboard.get(params.get('dashboard_id'))
panel_type = params.get('panel_type', 'event')
dashboard.create_panel(panel_type, saved_search=saved_search.name, title=params.get('panel_title'))
if saved_search.passive_save() and dashboard.passive_save():
# update saved search only on save success
raise cherrypy.HTTPRedirect(self.make_url(['dashboardwizard', app, 'success'], _qs=dict(search_id=saved_search.id, dashboard_id=dashboard.id)), 303)
template_args = dict(app=app, saved_search=saved_search, dashboard=dashboard, dashboard_action=params.get('dashboard_action'))
return self.render_template('dashboardwizard/step3.html', template_args)
开发者ID:DRArpitha,项目名称:splunk,代码行数:28,代码来源:dashboardwizard.py
示例12: step2_update
def step2_update(self, app, step, action, **params):
saved_search = SavedSearch.get(params.get("id"))
saved_search.update(params)
saved_search.action.email.enabled = False if params.get("action.email.enabled") is None else True
if saved_search.action.email.enabled is False:
saved_search.action.email.to = None
saved_search.action.script.enabled = False if params.get("action.script.enabled") is None else True
saved_search.alert.track = False if params.get("alert.track") is None else True
saved_search.alert.suppress.enabled = False if params.get("alert.suppress.enabled") is None else True
if (
saved_search.action.email.enabled is False
and saved_search.action.script.enabled is False
and saved_search.alert.track is False
):
saved_search.errors.append(_("Enable at least one action."))
self.step2_from_ui(params, saved_search)
if not saved_search.errors and saved_search.passive_save():
raise cherrypy.HTTPRedirect(
self.make_url(["alertswizardv2", app, "step3"], _qs=dict(id=saved_search.id)), 303
)
for idx, error in enumerate(saved_search.errors):
if error == "action.email.to is required if email action is enabled":
saved_search.errors[idx] = _("Provide at least one address for scheduled report emails.")
self.step1_to_ui(saved_search)
self.step2_to_ui(saved_search)
return self.render_template("alertswizardv2/step2.html", dict(app=app, saved_search=saved_search))
开发者ID:mealy,项目名称:splunk,代码行数:26,代码来源:alertswizardv2.py
示例13: step1_update
def step1_update(self, app, step, action, **params):
saved_search = SavedSearch.get(params.get('id'))
self.step1_from_ui(params, saved_search)
if saved_search.passive_save():
raise cherrypy.HTTPRedirect(self.make_url(['scheduledigestwizard', app, 'step2'], _qs=dict(id=saved_search.id)), 303)
self.step1_to_ui(saved_search)
return self.render_template('scheduledigestwizard/step1_edit.html', dict(app=app, saved_search=saved_search))
开发者ID:MobileWebApps,项目名称:splunk-search-tools-app,代码行数:7,代码来源:scheduledigestwizard.py
示例14: step1_create
def step1_create(self, app, step, action, **params):
owner = splunk.auth.getCurrentUser()['name']
params['name'] = params.get('name', '')
saved_search = SavedSearch(app, owner, **params)
saved_search.metadata.sharing = params.get('sharing', 'user')
saved_search.is_disabled = True
# set a default comparator otherwise always will be the first selected
saved_search.alert.type = 'number of events'
saved_search.alert.comparator = 'greater than'
saved_search.alert.threshold = '0'
# set some default values - we know this will be an alert so schedule it
# this way we get some default values set by the backend
saved_search.schedule.is_scheduled = True
saved_search.schedule.cron_schedule = '0 */12 * * *'
saved_search.alert.suppress.enabled = None
if saved_search.passive_save():
raise cherrypy.HTTPRedirect(self.make_url(['alertswizard', app, 'step2'], _qs=dict(id=saved_search.id)), 303)
return self.render_template('alertswizard/step1_new.html', dict(app=app, saved_search=saved_search))
开发者ID:DRArpitha,项目名称:splunk,代码行数:18,代码来源:alertswizard.py
示例15: step2_new
def step2_new(self, app, action, **params):
owner = splunk.auth.getCurrentUser()['name']
saved_search = SavedSearch.get(params.get('id'))
dashboard = Dashboard(app, owner, None)
dashboard.metadata.sharing = 'app'
dashboards = Dashboard.filter_by_can_write_simple_xml(app)
template_args = dict(app=app, saved_search=saved_search, dashboard=dashboard, dashboards=dashboards,
dashboard_action=None, panel_type='event', panel_title=None)
return self.render_template('dashboardwizard/step2.html', template_args)
开发者ID:DRArpitha,项目名称:splunk,代码行数:9,代码来源:dashboardwizard.py
示例16: step2_update
def step2_update(self, app, step, action, **params):
saved_search = SavedSearch.get(params.get('id'))
saved_search.update(params)
saved_search.action.email.enabled = False if params.get('action.email.enabled') is None else True
saved_search.action.script.enabled = False if params.get('action.script.enabled') is None else True
self.step2_from_ui(params, saved_search)
if saved_search.passive_save():
raise cherrypy.HTTPRedirect(self.make_url(['scheduledigestwizard', app, 'step3'], _qs=dict(id=saved_search.id)), 303)
self.step2_to_ui(saved_search)
return self.render_template('scheduledigestwizard/step2.html', dict(app=app, saved_search=saved_search))
开发者ID:DRArpitha,项目名称:splunk,代码行数:10,代码来源:scheduledigestwizard.py
示例17: step1_update
def step1_update(self, app, step, action, **params):
saved_search = SavedSearch.get(params.get("id"))
saved_search.update(params)
self.step1_from_ui(params, saved_search)
if len(saved_search.errors) == 0 and saved_search.passive_save():
raise cherrypy.HTTPRedirect(
self.make_url(["alertswizardv2", app, "step2"], _qs=dict(id=saved_search.id)), 303
)
self.step1_to_ui(saved_search)
return self.render_template("alertswizardv2/step1_edit.html", dict(app=app, saved_search=saved_search))
开发者ID:mealy,项目名称:splunk,代码行数:10,代码来源:alertswizardv2.py
示例18: step3_edit
def step3_edit(self, app, action, **params):
owner = splunk.auth.getCurrentUser()['name']
saved_search = SavedSearch.get(params.get('search_id'))
dashboard = Dashboard.get(params.get('dashboard_id'))
dashboard_action = params.get('dashboard_action')
panel_type = 'event'
if saved_search.ui.display_view in ['charting', 'report_builder_format_report', 'report_builder_display']:
panel_type = 'chart'
template_args = dict(app=app, saved_search=saved_search, dashboard=dashboard, dashboard_action=dashboard_action, panel_type=panel_type, panel_title=None)
return self.render_template('dashboardwizard/step3.html', template_args)
开发者ID:DRArpitha,项目名称:splunk,代码行数:10,代码来源:dashboardwizard.py
示例19: step3_edit
def step3_edit(self, app, action, **params):
saved_search = SavedSearch.get(params.get('id'))
pdf_config = PDFConfig.get()
email_results_type = None
if saved_search.action.email.format == 'html':
saved_search.action.email.format = 'inline'
elif saved_search.action.email.sendpdf:
saved_search.action.email.format = 'pdf'
# first time nudge them not to track if always was selected
saved_search.alert.track = False if saved_search.alert.type=='always' else True
return self.render_template('alertswizard/step3.html', dict(app=app, email_results_type=email_results_type, saved_search=saved_search, pdf_config=pdf_config))
开发者ID:DRArpitha,项目名称:splunk,代码行数:11,代码来源:alertswizard.py
示例20: step2_edit
def step2_edit(self, app, action, **params):
owner = splunk.auth.getCurrentUser()['name']
saved_search = SavedSearch.get(params.get('id'))
dashboard = Dashboard.get(params.get('dashboard_id'))
dashboard_action = params.get('dashboard_action')
if dashboard_action=='new':
dashboard.delete()
dashboards = Dashboard.filter_by_can_write_simple_xml()
template_args = dict(app=app, saved_search=saved_search, dashboard=dashboard, dashboards=dashboards,
dashboard_action=dashboard_action)
return self.render_template('dashboardwizard/step2.html', template_args)
开发者ID:DRArpitha,项目名称:splunk,代码行数:11,代码来源:dashboardwizard.py
注:本文中的splunk.models.saved_search.SavedSearch类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论