java.lang.Object
org.elasticsearch.ingest.SamplingService
- All Implemented Interfaces:
ClusterStateListener
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic final class -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSamplingService(ScriptService scriptService, ClusterService clusterService, ProjectResolver projectResolver, LongSupplier relativeMillisTimeSupplier) -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidCalled when cluster state changes.getLocalSample(ProjectId projectId, String index) Gets the sample for the given projectId and index on this node only.getLocalSampleStats(ProjectId projectId, String index) Gets the sample stats for the given projectId and index on this node only.voidmaybeSample(ProjectMetadata projectMetadata, String indexName, IndexRequest indexRequest, IngestDocument ingestDocument) Potentially samples the given indexRequest, depending on the existing sampling configuration.voidmaybeSample(ProjectMetadata projectMetadata, IndexRequest indexRequest) Potentially samples the given indexRequest, depending on the existing sampling configuration.
-
Field Details
-
RANDOM_SAMPLING_FEATURE_FLAG
public static final boolean RANDOM_SAMPLING_FEATURE_FLAG
-
-
Constructor Details
-
SamplingService
public SamplingService(ScriptService scriptService, ClusterService clusterService, ProjectResolver projectResolver, LongSupplier relativeMillisTimeSupplier)
-
-
Method Details
-
maybeSample
Potentially samples the given indexRequest, depending on the existing sampling configuration.- Parameters:
projectMetadata- Used to get the sampling configurationindexRequest- The raw request to potentially sample
-
maybeSample
public void maybeSample(ProjectMetadata projectMetadata, String indexName, IndexRequest indexRequest, IngestDocument ingestDocument) Potentially samples the given indexRequest, depending on the existing sampling configuration.- Parameters:
projectMetadata- Used to get the sampling configurationindexRequest- The raw request to potentially sampleingestDocument- The IngestDocument used for evaluating any conditionals that are part of the sample configuration
-
getLocalSample
Gets the sample for the given projectId and index on this node only. The sample is not persistent.- Parameters:
projectId- The project that this sample is forindex- The index that the sample is for- Returns:
- The raw documents in the sample on this node, or an empty list if there are none
-
getLocalSampleStats
Gets the sample stats for the given projectId and index on this node only. The stats are not persistent. They are reset when the node restarts for example.- Parameters:
projectId- The project that this sample is forindex- The index that the sample is for- Returns:
- Current stats on this node for this sample
-
atLeastOneSampleConfigured
public boolean atLeastOneSampleConfigured() -
clusterChanged
Description copied from interface:ClusterStateListenerCalled when cluster state changes.Cluster states are applied one-by-one which means they can be a performance bottleneck. Implementations of this method should therefore be fast, so please consider forking work into the background rather than doing everything inline.
- Specified by:
clusterChangedin interfaceClusterStateListener
-