The events resource can be used to retrieve events in the system.

Available methods:

GET POST /api/2/reports/events/list Events overview
GET POST /api/2/reports/events/get Event details
GET POST /api/2/reports/events/summary Events summary
GET POST /api/2/reports/events/dismiss Dismiss active failed events

list

Returns a list of events stored in M/Monit. Arguments can be combined to select specific events.

Arguments

active number optional The active events filter. Possible values: 0=show all events, 1=show only active errors, 2=show only active errors but exclude user dismissed errors
hostid number optional Show only events from hosts with matching host id. The argument can be used multiple times to select multiple hosts
hostgroupid number optional Show only events for hosts that are member of the given hostgroupid
servicenameid number optional Show only events for the given service name id
servicegroupid number optional Show only events for the given servicegroup id
servicetype number optional Show only events for the given service type. Possible values: 0=filesystem, 1=directory, 2=file, 3=process, 4=remote host, 5=system, 6=fifo, 7=program
eventtype number optional Show only events with the given type. Possible values: 1=checksum, 2=resource, 4=timeout, 8=timestamp, 16=size, 32=connection, 64=permission, 128=UID, 256=GID, 512=nonexist, 1024=invalid, 2048=data, 4096=exec, 8192=fsflags, 16384=icmp, 32768=content, 65536=instance, 131072=action, 262144=PID, 524288=PPID, 1048576=heartbeat, 2097152=status, 4194304=uptime
state number optional Show only events with the given state. Possible values: 0=success, 1=error, 2=change
datefrom unix timestamp optional Show only events from the given time stamp
dateto unix timestamp optional Show only events until the given time stamp
results number optional Returns only the given number of events (page size)
startindex number optional Result set offset (page index)
sort string optional The sort key. Possible values: "date", "hostname", "servicename", "event", "note"
dir string optional The sort direction. Possible values: "desc" (descending), "asc" (ascending)
curl -b ~/.mmonit/cookie \
 https://127.0.0.1:8080/api/2/reports/events/list

Output

recordsReturned The number of events in the result set
pageSize The maximum number of events to return (page size)
totalRecords The total number of events which match the selection. If the totalRecords exceeds the pageSize value, the result is paginated
startIndex The page index (position) in the selection
sort The sort key. Possible values: "date", "hostname", "servicename", "event", "note"
dir The sort direction. Possible values: "desc" (descending), "asc" (ascending)
records
id The internal event id assigned by M/Monit when the event is stored
date Unix timestamp (GMT timezone)
hostname The host name
hostid The host id
servicename The service name
servicenameid The unique id assigned to the servicename string (shared by any instance of the same string)
event The event description
eventtype The event type. Possible values: 0=success, 1=error, 2=change
note The event notice flag. Possible values: 0=no event notice, 1=event notice is set
{
    "recordsReturned": 1,
    "pageSize": 15,
    "totalRecords": 1,
    "startIndex": 0,
    "sort": "date",
    "dir": "desc",
    "records": [
        {
            "id": 272,
            "date": 1414560357,
            "hostname": "myhost",
            "hostid": 185,
            "servicename": "devfs",
            "servicenameid": 8,
            "event": "unmonitor action done",
            "eventtype": 2,
            "note": 0
        }
    ]
}

get

Returns details for a spesific event.

Arguments

id number required The event id to get
curl -b ~/.mmonit/cookie \
 https://127.0.0.1:8080/api/2/reports/events/get?id=274

Output

id The event id
hostid The host id
host The host name
date Unix timestamp (GMT timezone)
servicename The service name
servicetype The service type (string representation)
event The event type (string representation)
eventstate The event state. Possible values: 0=success, 1=error, 2=change
action The event action (string representation)
message The event description
note
date The note timestamp
uname The note author username
message The note body
{
    "id": 274,
    "hostid": 185,
    "host": "trilobite.local",
    "date": 1414560351,
    "servicename": "devfs",
    "servicetype": "Filesystem",
    "event": "Action done",
    "eventstate": 2,
    "action": "Alert",
    "message": "monitor action done",
    "note": [
        {
            "date": 1414560557,
            "uname": "admin",
            "message": "Lorem ipsum"
        }
    ]
}

summary

Returns the events summary for the last 24 hours.

Arguments

none
curl -b ~/.mmonit/cookie \
 https://127.0.0.1:8080/api/2/reports/events/summary

Output

datefrom The time range start (now - 24 hours) [unix timestamp]
dateto The time range stop (now) [unix timestamp]
events
label The event state
data An array of unix timestamps, events count pairs. Each unix timestamp represents a 10-minutes sample with a counter of related events
{
    "datefrom": 1374972247,
    "dateto": 1375058647,
    "events": [
        {
            "label": "Failed",
            "data": []
        },
        {
            "label": "Changed",
            "data": [
                [ 1375008000, 1 ],
                [ 1375009200, 2 ]
            ]
        },
        {
            "label": "Succeeded",
            "data": [
                [ 1375014600, 1 ]
            ]
        }
    ]
}

dismiss

Dismiss the given active event so it doesn’t show up in the event list if active filter is set to 2.

Arguments

id number required The event id to dismiss
curl -b ~/.mmonit/cookie \
 -d "id=723" \
 https://127.0.0.1:8080/api/2/reports/events/dismiss