Create a Basic Custom Event

A custom event can be used to report any performance, device, or business logic data. It is the most general, configurable and flexible data type available.

The Custom Event Builder takes two required parameters.

  • Event Type: A short human-readable description of the event, such as "FL Pressure Drop".
  • Description: A string describing the event, such as "Front Left Tire Pressure Drop".

To make reporting this event meaningful, it is recommended that you provide a timestamp and at least one kind of datatype.

  1. Create a basic custom event.
    import com.appdynamics.iot.events.CustomEvent;
    ...
    CustomEvent.Builder builder = CustomEvent.builder("FL Pressure Drop", "Front Left Tire Pressure Drop");
    long eventStartTime = System.currentTimeMillis();
    long duration = 6000;
    builder.withTimestamp(eventStartTime).withDuration(duration);
    builder.addLongProperty("PSI Drop", 37);
    CustomEvent customEvent = builder.build();
    Additional information can be added to the CustomEvent. For details, see the CustomEvent class in the latest Java IoT SDK documentation.
  2. Add the custom event to the instrumentation (this adds it to the in-memory buffer).
    Instrumentation.addEvent(customEvent);
  3. Send all the events to the EUM Server. This is a blocking call, so the application can send it on a separate thread as shown above.
    Instrumentation.sendAllEvents();