java.lang.Object
org.elasticsearch.action.downsample.DownsampleConfig
- All Implemented Interfaces:
NamedWriteable,Writeable,ToXContent,ToXContentObject
This class holds the configuration details of a DownsampleAction that downsamples time series
(TSDB) indices. We have made great effort to simplify the rollup configuration and currently
only requires a fixed time interval and optionally the sampling method. So, it has the following format:
{
"fixed_interval": "1d",
"sampling_method": "aggregate"
}
fixed_interval is one or multiples of SI units and has no calendar-awareness (e.g. doesn't account
for leap corrections, does not have variable length months, etc). Calendar-aware interval is not currently
supported.
Also, the rollup configuration uses the UTC time zone by default and the "@timestamp" field as
the index field that stores the timestamp of the time series index.
Finally, we have left methods such as
getTimestampField(),
getTimeZone() and getIntervalType() for
future extensions.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TransportVersionstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionDownsampleConfig(DateHistogramInterval fixedInterval, DownsampleConfig.SamplingMethod samplingMethod) Create a newDownsampleConfigusing the given configuration parameters. -
Method Summary
Modifier and TypeMethodDescriptionCreate the rounding for this date histogramstatic Rounding.PreparedcreateRounding(String expr, String timeZone) booleanstatic DownsampleConfigfromXContent(XContentParser parser) static StringgenerateDownsampleIndexName(String prefix, IndexMetadata sourceIndexMetadata, DateHistogramInterval fixedInterval) Generates a downsample index name in the format prefix-fixedInterval-baseIndexName Note that this looks for the base index name of the provided index metadata via theIndexMetadata.INDEX_DOWNSAMPLE_ORIGIN_NAME_KEYsetting.Get the fixed_interval valueGet the interval valueGet the interval type.Get the timestamp field to be used for rolling up data.Get the timezone to applyReturns the name of the writeable objectinthashCode()toString()toXContent(XContentBuilder builder, ToXContent.Params params) toXContentFragment(XContentBuilder builder) static voidvalidateSourceAndTargetIntervals(DateHistogramInterval sourceFxedInterval, DateHistogramInterval targetFixedInterval) This method validates the target downsampling configuration can be applied on an index that has been already downsampled from the source configuration.voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Field Details
-
ADD_LAST_VALUE_DOWNSAMPLE_API
-
FIXED_INTERVAL
- See Also:
-
SAMPLING_METHOD
- See Also:
-
TIME_ZONE
- See Also:
-
DEFAULT_TIMEZONE
-
-
Constructor Details
-
DownsampleConfig
public DownsampleConfig(DateHistogramInterval fixedInterval, @Nullable DownsampleConfig.SamplingMethod samplingMethod) Create a newDownsampleConfigusing the given configuration parameters.- Parameters:
fixedInterval- the fixed interval to use for computing the date histogram for the rolled up documents (required).samplingMethod- the method used to downsample metrics, when null it default toDownsampleConfig.SamplingMethod.AGGREGATE.
-
DownsampleConfig
- Throws:
IOException
-
-
Method Details
-
validateSourceAndTargetIntervals
public static void validateSourceAndTargetIntervals(DateHistogramInterval sourceFxedInterval, DateHistogramInterval targetFixedInterval) This method validates the target downsampling configuration can be applied on an index that has been already downsampled from the source configuration. The requirements are: - The target interval needs to be greater than source interval - The target interval needs to be a multiple of the source interval throws an IllegalArgumentException to signal that the target interval is not acceptable -
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
getTimestampField
Get the timestamp field to be used for rolling up data. Currently, only the "@timestamp" value is supported. -
getIntervalType
Get the interval type. Currently, only fixed_interval is supported -
getInterval
Get the interval value -
getFixedInterval
Get the fixed_interval value -
getTimeZone
Get the timezone to apply -
createRounding
Create the rounding for this date histogram -
getSamplingMethod
- Returns:
- the user configured sampling method
-
getSamplingMethodOrDefault
- Returns:
- the sampling method that will be used based on this configuration.
-
getWriteableName
Description copied from interface:NamedWriteableReturns the name of the writeable object- Specified by:
getWriteableNamein interfaceNamedWriteable
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
toXContentFragment
- Throws:
IOException
-
fromXContent
- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
toString
-
createRounding
-
generateDownsampleIndexName
public static String generateDownsampleIndexName(String prefix, IndexMetadata sourceIndexMetadata, DateHistogramInterval fixedInterval) Generates a downsample index name in the format prefix-fixedInterval-baseIndexName Note that this looks for the base index name of the provided index metadata via theIndexMetadata.INDEX_DOWNSAMPLE_ORIGIN_NAME_KEYsetting. This means that in case the provided index was already downsampled, we'll use the original source index (of the current provided downsample index) as the base index name.
-