Sidebar

api:alert:get

Table of Contents

get()

Available since version: 1.8
This function allows you to retrieve alert details based on filtering options. All parameters are optional. If parameter is set in query this option counted as ON, except if parameter is equal to NULL.

Parameters

ParameterTypeDescriptionDetails
nodeidsarrayNode IDs
groupidsarrayHostGroup IDs
hostidsarrayHost IDs
alertidsarrayAlert IDs
triggeridsarrayTrigger IDs
eventidsarrayEvent IDs
editableintegeronly with read-write permission. Ignored for SuperAdmins
time_fromintegerSearch alerts from given date Unix timestamp
time_tillintegerSearch alerts till given date Unix timestamp
filterarrayOptional filter by alert fields
searcharrayReturn alerts by any given alert object field pattern
startSearchintegerSearch alerts field pattern only in start of the field
excludeSearchintegerExclude from result, alerts by given field pattern
searchWildcardsEnabledintegerSearch pattern in whole field using wildcards 1 - enable, 0 - disable
outputstringOutput options Values: shorten, refer, extend
select_hostsstringSelect hosts Values: shorten, refer, extend
select_mediatypesstringSelect mediatypes Values: shorten, refer, extend
select_usersstringSelect users Values: shorten, refer, extend
countOutputintegerCount alerts, return number of alerts found
groupCountintegerReturn the number of results grouped by given IDs
preservekeysintegerReturn hash instead of array Keys of hash are object IDs
sortfieldstringSort by alert field Values: alertid,clock,eventid,status
sortorderstringSort order Values: ASC, DESC
limitintmax number of alert objects to return

Returns

ParameterDescription
resultOperation successful. Result will contain array of Alert objects.
errorIn case of any errors

Example

Get alerts details by trigger IDs and limit output to 10 alerts, return only alert IDS:

{
"jsonrpc":"2.0",
"method":"alert.get",
"params":{
	"output":"shorten",
	"triggerids": ["100100000010137", "100100000010138"],
	"time_from": 1285077093,
	"time_till": 1285107165,
	"limit": 10
},
"auth":"6f38cddc44cfbb6c1bd186f9a220b5a0",
"id":2
}

Retrieved alerts details:

{
"jsonrpc":"2.0",
"result":[
	{"alertid":"100100000010048"},
	{"alertid":"100100000010137"},
	{"alertid":"100100000017431"},
	{"alertid":"100100000017533"},
	{"alertid":"100100000017635"},
	{"alertid":"100100000017737"},
	{"alertid":"100100000017839"},
	{"alertid":"100100000017941"},
	{"alertid":"100100000018043"},
	{"alertid":"100100000018145"}
],
"id":2
}