Interface Events

  • All Superinterfaces:
    Namespaceable

    public interface Events
    extends Namespaceable
    Events are multi-dimensional time series data. { timestamp = 1521860720690, dimensions = ['cpu'=0.5, 'mem'=0.13], metadata: ['ip'='10.0.137.21', 'data-center'='dc-1'], payload: "arbitrary byte array" } Implementations of this interface provide functionalities to store and retrieve
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  Events.Event
      An event consists of a timestamp in milli-seconds, a map of string to string as metadata, and a map of string to double value as dimensions.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      List<Events.Event> dimension​(String namespace, String dimensionKey, long startTimestampMillis, long endTimestampMillis, Map<String,​String> metadataQuery, Map<String,​String> dimensionsQuery)
      Get a list of events values where each event only contains the specified dimension, for events in the given namespace, with timestamp between the start and end, metadata and dimensions matching the given queries.
      void expire​(String namespace, long endTimestampMillis)
      Expire all events with timestamp before the given end timestamp.
      default List<Events.Event> get​(String namespace, long startTimestampMillis, long endTimestampMillis)
      Get all events in the given namespace, with timestamp between the start and end.
      default List<Events.Event> get​(String namespace, long startTimestampMillis, long endTimestampMillis, boolean includePayloads)
      Get all events in the given namespace, with timestamp between the start and end.
      default List<Events.Event> get​(String namespace, long startTimestampMillis, long endTimestampMillis, Map<String,​String> metadataQuery, Map<String,​String> dimensionsQuery)
      Get all events in the given namespace, with timestamp between the start and end, and metadata and dimensions matching the given queries.
      default List<Events.Event> get​(String namespace, long startTimestampMillis, long endTimestampMillis, Map<String,​String> metadataQuery, Map<String,​String> dimensionsQuery, boolean includePayloads)
      Get all events in the given namespace, with timestamp between the start and end, and metadata and dimensions matching the given queries.
      List<Events.Event> get​(String namespace, long startTimestampMillis, long endTimestampMillis, Map<String,​String> metadataQuery, Map<String,​String> dimensionsQuery, boolean includePayloads, boolean ascending, int limit)
      Get all events in the given namespace, with timestamp between the start and end, and metadata and dimensions matching the given queries.
      Set<String> metadata​(String namespace, String metadataKey, long startTimestampMillis, long endTimestampMillis, Map<String,​String> metadataQuery, Map<String,​String> dimensionsQuery)
      Get distinct metadata values for the given metadata key for events in the given namespace, with timestamp between the start and end, metadata and dimensions matching the given queries.
      default void store​(String namespace, long timestampMillis, Map<String,​String> metadata, Map<String,​Double> dimensions)
      Store an event in the given namespace, with timestamp and optionally metadata and dimensions.
      default void store​(String namespace, long timestampMillis, Map<String,​String> metadata, Map<String,​Double> dimensions, byte[] payload)
      Store an event in the given namespace, with timestamp and optionally metadata and dimensions, along with an arbitrary byte array as payload.
      default void store​(String namespace, Events.Event event)
      Store an event object.
      void store​(String namespace, Collection<Events.Event> batch)
      Store batch of events in the given namespace.
    • Method Detail

      • store

        default void store​(String namespace,
                           long timestampMillis,
                           Map<String,​String> metadata,
                           Map<String,​Double> dimensions)
                    throws IOException
        Store an event in the given namespace, with timestamp and optionally metadata and dimensions.
        Parameters:
        namespace - the namespace identifier
        timestampMillis - event's UTC timestamp in milli-seconds
        metadata - metadata to be attached to the event
        dimensions - dimensions to be attached to the event
        Throws:
        IOException - exception thrown from the underlying storage implementation
      • store

        default void store​(String namespace,
                           Events.Event event)
                    throws IOException
        Store an event object.
        Parameters:
        namespace - the namespace identifier
        event - the event object
        Throws:
        IOException - exception thrown from the underlying storage implementation
      • store

        default void store​(String namespace,
                           long timestampMillis,
                           Map<String,​String> metadata,
                           Map<String,​Double> dimensions,
                           byte[] payload)
                    throws IOException
        Store an event in the given namespace, with timestamp and optionally metadata and dimensions, along with an arbitrary byte array as payload.
        Parameters:
        namespace - the namespace identifier
        timestampMillis - event's UTC timestamp in milli-seconds
        metadata - metadata to be attached to the event
        dimensions - dimensions to be attached to the event
        payload - payload to be attached to the event
        Throws:
        IOException - exception thrown from the underlying storage implementation
      • store

        void store​(String namespace,
                   Collection<Events.Event> batch)
            throws IOException
        Store batch of events in the given namespace.
        Parameters:
        namespace - the namespace identifier
        batch - batch of events
        Throws:
        IOException - exception thrown from the underlying storage implementation
      • get

        default List<Events.Event> get​(String namespace,
                                       long startTimestampMillis,
                                       long endTimestampMillis)
                                throws IOException
        Get all events in the given namespace, with timestamp between the start and end.
        Parameters:
        namespace - the namespace identifier
        startTimestampMillis - start UTC timestamp in milli-seconds
        endTimestampMillis - end UTC timestamp in milli-seconds
        Returns:
        list of all events in the namespace with timestamp between start/end
        Throws:
        IOException - exception thrown from the underlying storage implementation
      • get

        default List<Events.Event> get​(String namespace,
                                       long startTimestampMillis,
                                       long endTimestampMillis,
                                       boolean includePayloads)
                                throws IOException
        Get all events in the given namespace, with timestamp between the start and end.
        Parameters:
        namespace - the namespace identifier
        startTimestampMillis - start UTC timestamp in milli-seconds
        endTimestampMillis - end UTC timestamp in milli-seconds
        includePayloads - flag to include payloads in the response or not; if false, event.getPayload() returns null
        Returns:
        list of all events in the namespace with timestamp between start/end
        Throws:
        IOException - exception thrown from the underlying storage implementation
      • get

        default List<Events.Event> get​(String namespace,
                                       long startTimestampMillis,
                                       long endTimestampMillis,
                                       Map<String,​String> metadataQuery,
                                       Map<String,​String> dimensionsQuery)
                                throws IOException
        Get all events in the given namespace, with timestamp between the start and end, and metadata and dimensions matching the given queries.

        A metadata query can match against an exact value for a key, or use wild-card character (i.e., '*'). For example: "host" => "localhost" matches with all events where the value of metadata with key "host" is exactly "localhost"; and the query "host" => "~prod-*-example" matches all events where the value is "like 'prod-*-example'". Note that wild-card queries have to start with "~", exact queries can optionally start with "=".

        A dimensions query can match against exact values or less-than, less-than-or-equal, more-than, more-than-or-equal values for a set of dimensions. For example: "cpu" => ">=0.3" matches all events where the dimension with key "cpu" has a value higher than or equal to 0.3.

        Parameters:
        namespace - the namespace identifier
        startTimestampMillis - start UTC timestamp in milli-seconds
        endTimestampMillis - end UTC timestamp in milli-seconds
        metadataQuery - map of string to string representing a query to run against events metadata
        dimensionsQuery - map of string to string representing a query to run against events dimensions
        Returns:
        list of all events in the namespace with timestamp between start/end and metadata/dimensions matching the query
        Throws:
        IOException - exception thrown from the underlying storage implementation
      • get

        default List<Events.Event> get​(String namespace,
                                       long startTimestampMillis,
                                       long endTimestampMillis,
                                       Map<String,​String> metadataQuery,
                                       Map<String,​String> dimensionsQuery,
                                       boolean includePayloads)
                                throws IOException
        Get all events in the given namespace, with timestamp between the start and end, and metadata and dimensions matching the given queries. A metadata query can match against an exact value for a key, or use wild-card character (i.e., '*'). For example: "host" => "localhost" matches with all events where the value of metadata with key "host" is exactly "localhost"; and the query "host" => "~prod-*-example" matches all events where the value is "like 'prod-*-example'". Note that wild-card queries have to start with "~", exact queries can optionally start with "=". A dimensions query can match against exact values or less-than, less-than-or-equal, more-than, more-than-or-equal values for a set of dimensions. For example: "cpu" => ">=0.3" matches all events where the dimension with key "cpu" has a value higher than or equal to 0.3.
        Parameters:
        namespace - the namespace identifier
        startTimestampMillis - start UTC timestamp in milli-seconds
        endTimestampMillis - end UTC timestamp in milli-seconds
        metadataQuery - map of string to string representing a query to run against events metadata
        dimensionsQuery - map of string to string representing a query to run against events dimensions
        includePayloads - flag to include payloads in the response or not; if false, event.getPayload() returns null
        Returns:
        list of all events in the namespace with timestamp between start/end and metadata/dimensions matching the query
        Throws:
        IOException - exception thrown from the underlying storage implementation
      • get

        List<Events.Event> get​(String namespace,
                               long startTimestampMillis,
                               long endTimestampMillis,
                               Map<String,​String> metadataQuery,
                               Map<String,​String> dimensionsQuery,
                               boolean includePayloads,
                               boolean ascending,
                               int limit)
                        throws IOException
        Get all events in the given namespace, with timestamp between the start and end, and metadata and dimensions matching the given queries. A metadata query can match against an exact value for a key, or use wild-card character (i.e., '*'). For example: "host" => "localhost" matches with all events where the value of metadata with key "host" is exactly "localhost"; and the query "host" => "~prod-*-example" matches all events where the value is "like 'prod-*-example'". Note that wild-card queries have to start with "~", exact queries can optionally start with "=". A dimensions query can match against exact values or less-than, less-than-or-equal, more-than, more-than-or-equal values for a set of dimensions. For example: "cpu" => ">=0.3" matches all events where the dimension with key "cpu" has a value higher than or equal to 0.3.
        Parameters:
        namespace - the namespace identifier
        startTimestampMillis - start UTC timestamp in milli-seconds
        endTimestampMillis - end UTC timestamp in milli-seconds
        metadataQuery - map of string to string representing a query to run against events metadata
        dimensionsQuery - map of string to string representing a query to run against events dimensions
        includePayloads - flag to include payloads in the response or not; if false, event.getPayload() returns null
        ascending - order results ascending if true; descending if false
        limit - maximum number of events to return
        Returns:
        list of all events in the namespace with timestamp between start/end and metadata/dimensions matching the query
        Throws:
        IOException - exception thrown from the underlying storage implementation
      • metadata

        Set<String> metadata​(String namespace,
                             String metadataKey,
                             long startTimestampMillis,
                             long endTimestampMillis,
                             Map<String,​String> metadataQuery,
                             Map<String,​String> dimensionsQuery)
                      throws IOException
        Get distinct metadata values for the given metadata key for events in the given namespace, with timestamp between the start and end, metadata and dimensions matching the given queries.
        Parameters:
        namespace - the namespace identifier
        metadataKey - the given metadata key
        startTimestampMillis - start timestamp in milli-seconds
        endTimestampMillis - end timestamp in milli-seconds
        metadataQuery - map of string to string representing a query to run against events metadata
        dimensionsQuery - map of string to string representing a query to run against events dimensions
        Returns:
        set of metadata values for all events in the namespace with timestamp between start/end and metadata/dimensions matching the query
        Throws:
        IOException - exception thrown from the underlying storage implementation
      • dimension

        List<Events.Event> dimension​(String namespace,
                                     String dimensionKey,
                                     long startTimestampMillis,
                                     long endTimestampMillis,
                                     Map<String,​String> metadataQuery,
                                     Map<String,​String> dimensionsQuery)
                              throws IOException
        Get a list of events values where each event only contains the specified dimension, for events in the given namespace, with timestamp between the start and end, metadata and dimensions matching the given queries.
        Parameters:
        namespace - the namespace identifier
        dimensionKey - the given dimension key
        startTimestampMillis - start timestamp in milli-seconds
        endTimestampMillis - end timestamp in milli-seconds
        metadataQuery - map of string to string representing a query to run against events metadata
        dimensionsQuery - map of string to string representing a query to run against events dimensions
        Returns:
        list of events where each event only contains the specified dimension - no payload or metadata is included, in the namespace with timestamp between start/end and metadata/dimensions matching the query
        Throws:
        IOException - exception thrown from the underlying storage implementation
      • expire

        void expire​(String namespace,
                    long endTimestampMillis)
             throws IOException
        Expire all events with timestamp before the given end timestamp.
        Parameters:
        endTimestampMillis - end timestamp in milli-seconds
        Throws:
        IOException - exception thrown from the underlying storage implementation