Class MetricStreamDefinition


  • public class MetricStreamDefinition
    extends java.lang.Object
    Describes what query to run for this particular MetricStream.
    See Also:
    InfluxdbMetricStreamerConfig
    • Constructor Summary

      Constructors 
      Constructor Description
      MetricStreamDefinition​(java.lang.String id, java.lang.String metricName, java.lang.String database, Query query, com.elastisys.scale.commons.json.types.TimeInterval dataSettlingTime, com.elastisys.scale.commons.json.types.TimeInterval queryChunkSize)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      java.lang.String getDatabase()
      The InfluxDB database to query.
      com.elastisys.scale.commons.json.types.TimeInterval getDataSettlingTime()
      The minimum age of requested data points.
      java.lang.String getId()
      The id of the metric stream.
      java.lang.String getMetric()  
      java.lang.String getMetricName()
      The metric name that will be assigned to the MetricValues produced by this stream.
      Query getQuery()
      The InfluxDB SELECT query to be used to fetch new metrics values.
      com.elastisys.scale.commons.json.types.TimeInterval getQueryChunkSize()
      The maximum time period that a single query against the InfluxDB server will attempt to fetch in a single call.
      int hashCode()  
      java.lang.String toString()  
      void validate()
      Checks the validity of field values.
      MetricStreamDefinition withDataSettlingTime​(com.elastisys.scale.commons.json.types.TimeInterval dataSettlingTime)
      Creates a field-by-field copy of this object but sets a different data settling time in the returned copy.
      MetricStreamDefinition withQuery​(Query query)
      Creates a field-by-field copy of this object but sets a different query in the returned copy.
      MetricStreamDefinition withQueryChunkSize​(com.elastisys.scale.commons.json.types.TimeInterval queryChunkSize)
      Creates a field-by-field copy of this object but sets a different query chunk size in the returned copy.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • DEFAULT_QUERY_CHUNK_SIZE

        public static final com.elastisys.scale.commons.json.types.TimeInterval DEFAULT_QUERY_CHUNK_SIZE
        Default value for queryChunkSize.
    • Constructor Detail

      • MetricStreamDefinition

        public MetricStreamDefinition​(java.lang.String id,
                                      java.lang.String metricName,
                                      java.lang.String database,
                                      Query query,
                                      com.elastisys.scale.commons.json.types.TimeInterval dataSettlingTime,
                                      com.elastisys.scale.commons.json.types.TimeInterval queryChunkSize)
        Parameters:
        id - The id of the metric stream. This is the id that will be used by clients wishing to subscribe to this metric stream. Required.
        metricName - The metric name that will be assigned to the MetricValues produced by this stream. Optional. Default: id.
        database - The InfluxDB database to query. An InfluxDB database acts as a container for time series data. For example, mydb. Required.
        query - The InfluxDB SELECT query to be used to fetch new metrics values. Required. Note: a query should avoid filtering on time in the WHERE clause, as selecting the approriate interval for which to fetch metrics will be handled by the InfluxdbMetricStreamer.
        dataSettlingTime - The minimum age of requested data points. The MetricStreamer will never request values newer than this from InfluxDB. This value can be regarded as the expected "settling time" of new data points.

        When requesting recent aggregate metric data points, there is always a risk of seeing partial/incomplete results before metric values from all sources have been registered. The data settling time is intended to give all sources a chance to report before fetching recent values.

        The value to set for this field depends on the reporting frequency of monitoring agents, but as a general rule-of-thumb, this value can be set to be about 1.5 times the length of the reporting-interval for monitoring agents. May be null.

        queryChunkSize - The maximum time period that a single query will attempt to fetch in a single call. A query with a longer time interval will be run incrementally, each fetching a sub-interval of this duration. This type of incremental retrieval of large QueryResultSets limits the amount of (memory) resources involved in processing large queries. May be null. Default: .
    • Method Detail

      • getId

        public java.lang.String getId()
        The id of the metric stream. This is the id that will be used by clients wishing to subscribe to this metric stream. Required.
        Returns:
      • getMetricName

        public java.lang.String getMetricName()
        The metric name that will be assigned to the MetricValues produced by this stream.
        Returns:
      • getMetric

        public java.lang.String getMetric()
      • getDatabase

        public java.lang.String getDatabase()
        The InfluxDB database to query. An InfluxDB database acts as a container for time series data. For example, mydb.
        Returns:
      • getQuery

        public Query getQuery()
        The InfluxDB SELECT query to be used to fetch new metrics values. Note: a query should avoid filtering on time in the WHERE clause, as selecting the approriate interval for which to fetch metrics will be handled by the InfluxdbMetricStreamer.
        Returns:
      • getDataSettlingTime

        public com.elastisys.scale.commons.json.types.TimeInterval getDataSettlingTime()
        The minimum age of requested data points. The MetricStreamer will never request values newer than this from InfluxDB. This value can be regarded as the expected "settling time" of new data points.

        When requesting recent aggregate metric data points, there is always a risk of seeing partial/incomplete results before metric values from all sources have been registered. The data settling time is intended to give all sources a chance to report before fetching recent values.

        The value to set for this field depends on the reporting frequency of monitoring agents, but as a general rule-of-thumb, this value can be set to be about 1.5 times the length of the reporting-interval for monitoring agents. May be null.

        Returns:
      • getQueryChunkSize

        public com.elastisys.scale.commons.json.types.TimeInterval getQueryChunkSize()
        The maximum time period that a single query against the InfluxDB server will attempt to fetch in a single call. A query with a longer time interval will be run incrementally, each fetching a sub-interval of this duration. This type of incremental retrieval of large QueryResultSets limits the amount of (memory) resources involved in processing large queries.
        Returns:
      • validate

        public void validate()
                      throws java.lang.IllegalArgumentException
        Checks the validity of field values. Throws an IllegalArgumentException if necessary conditions are not satisfied.
        Throws:
        java.lang.IllegalArgumentException
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • withQuery

        public MetricStreamDefinition withQuery​(Query query)
        Creates a field-by-field copy of this object but sets a different query in the returned copy.
        Parameters:
        query -
        Returns:
      • withDataSettlingTime

        public MetricStreamDefinition withDataSettlingTime​(com.elastisys.scale.commons.json.types.TimeInterval dataSettlingTime)
        Creates a field-by-field copy of this object but sets a different data settling time in the returned copy.
        Parameters:
        dataSettlingTime -
        Returns:
      • withQueryChunkSize

        public MetricStreamDefinition withQueryChunkSize​(com.elastisys.scale.commons.json.types.TimeInterval queryChunkSize)
        Creates a field-by-field copy of this object but sets a different query chunk size in the returned copy.
        Parameters:
        queryChunkSize -
        Returns: