Child pages
  • opEvents REST API Reference
Skip to end of metadata
Go to start of metadata

General

opEvents versions 2.0 and newer provide a REST-style API for limited event management, e.g. creation and retrieval of single events, and lookup of events.
This version also comes with a simple client (both source and compiled), /usr/local/omk/bin/create_remote_event.pl (and .exe).

Authentication

Authentication is required to access any of the methods listed below.

POST to /login to Authenticate

POST /omk/opEvents/login

You must authenticate to opEvents first. Two parameters must be supplied as post-body, username and password.

Request

Parameter
Description
usernameThe username to authenticate with
passwordThe password for the user

Successful Response

A cookie is created and sent with the response.  This must be saved and used with subsequent requests.

Event Management

POST to /events for Event Creation

The body of the request must be a valid JSON document, containing the desired event properties as a hash. Some properties (e.g. date, time) can be omitted and will be filled in automatically. As an absolute minimum, a node or a host property, and an event property must be present. If (and only if!) node is not present, then opEvents looks up host and attempts to find the canonical node for the hostname or IP address from the host property  - this heuristic is described in more detail here. The resulting node must be known to opEvents and must not be disabled for opEvents.

Successful Response

HTTP StatusHTTP HeadersBodyDescription
201LocationJSON hash with success and id propertiesThe success property is set to 1 and only if the request was successful.
The id property is the new event's ID (but see the Limitations section below)
The Location header contains the complete URL for retrieving the newly created event.

Unsuccessful Response

HTTP StatusBodyDescription
401N/AYou are not authenticated.
404N/AYou are authenticated but not authorised to create events in opEvents.
400JSON hash with  success being 0  and an error property.The error property contains an explanation
of what went wrong with your request, e.g. why the parameters were considered invalid.

 

GET of /events for Event Listing

If your GET call provides an Accept header indicating JSON, or if you use /events.json as URI, then opEvents will look for matching events and return their properties in the form of a JSON array of hashes. Extra query parameters can be used to narrow down the listing or search for particular events only; without  parameters you will get all events of the last two hours.

Optional Query Parameters

ParameterDescription
o_start, o_endStart and end of the period you are interested in.
Takes all standard opEvents Date/Time formats and UNIX seconds.
o_nodeName of the node you are interested in.
You can use "regex:<regular expression>" or a plain text string.
ev_event_nameName of the event you are interested in.
You can use "regex:<regular expression>" or a plain text string.
ev_event_typeType of the event, i.e. what source it came from.
e.g: nmis_eventlogapi.
ev_event_elementElement in question. Not present for all events.
Regex or plain text string.
ev_event_detailsDetails that were supplied with the event. Not present for all events.
Regex or plain text string.

 

Successful Response

HTTP StatusBodyDescription
200JSON array of hashesEach array element is a hash of the raw properties of the event in question.

Unsuccessful Response

HTTP StatusBodyDescription
401N/AYou are not authenticated.
404N/AYou are authenticated but not authorised to create events in opEvents.
200Empty JSON arrayYour request was valid, but there were no matching events.

GET of /events/<eventid> for Event Retrieval

If your GET call provides an Accept header indicating JSON, or if you use /events/<eventid>.json as URI, then the event will be looked up and all properties will be returned in the form of a JSON hash.

Successful Response

HTTP StatusBody
200JSON hash with all known event properties.

Unsuccessful Response

HTTP StatusBodyDescription
401N/AYou are not authenticated.
404N/AYou are authenticated but not authorised to view events in opEvents.
404JSON hash with an error property.

The error property contains an explanation of what went wrong
with your request, e.g. if you request a non-existent event.

Limitations

  • Events created by the REST API are subject to (stateful) deduplication, which is performed asynchronously and after the API call returns.
    If your newly created event is eliminated by the deduplication process, then the event ID returned by the creation API call will point to a non-existent event.

 

  • No labels