Skip to content

[Transform] fixing naming in HLRC and _cat to match API content #54300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.Objects;

public abstract class IndexerJobStats {
public static final String NAME = "data_frame_indexer_transform_stats";
public static ParseField NUM_PAGES = new ParseField("pages_processed");
public static ParseField NUM_INPUT_DOCUMENTS = new ParseField("documents_processed");
public static ParseField NUM_OUTPUT_DOCUMENTS = new ParseField("documents_indexed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.client.transform.transforms;

import org.elasticsearch.client.core.IndexerJobStats;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.XContentParser;
Expand All @@ -29,11 +28,24 @@

import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optionalConstructorArg;

public class TransformIndexerStats extends IndexerJobStats {
public class TransformIndexerStats {
public static final String NAME = "transform_indexer_stats";

static ParseField EXPONENTIAL_AVG_CHECKPOINT_DURATION_MS = new ParseField("exponential_avg_checkpoint_duration_ms");
static ParseField EXPONENTIAL_AVG_DOCUMENTS_INDEXED = new ParseField("exponential_avg_documents_indexed");
static ParseField EXPONENTIAL_AVG_DOCUMENTS_PROCESSED = new ParseField("exponential_avg_documents_processed");
static ParseField PAGES_PROCESSED = new ParseField("pages_processed");
static ParseField DOCUMENTS_PROCESSED = new ParseField("documents_processed");
static ParseField DOCUMENTS_INDEXED = new ParseField("documents_indexed");
static ParseField TRIGGER_COUNT = new ParseField("trigger_count");
static ParseField INDEX_TIME_IN_MS = new ParseField("index_time_in_ms");
static ParseField SEARCH_TIME_IN_MS = new ParseField("search_time_in_ms");
static ParseField PROCESSING_TIME_IN_MS = new ParseField("processing_time_in_ms");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

processing_time_in_ms

Does this mean we need to add this property to the stats object in https://www.elastic.co/guide/en/elasticsearch/reference/master/get-transform-stats.html ?

Copy link

@hendrikmuhs hendrikmuhs Mar 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that's my fault. In #53770 I added processing_time_in_ms and processing_total.

The 2 are counterparts of the search and index one:

The amount of time processing results, in milliseconds.
The number of processing operations.

This is basically what happens between search and index and shows the time/load the transform task itself used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've created #54368 to add those.

static ParseField INDEX_TOTAL = new ParseField("index_total");
static ParseField SEARCH_TOTAL = new ParseField("search_total");
static ParseField PROCESSING_TOTAL = new ParseField("processing_total");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

processing_total

This also doesn't appear in https://www.elastic.co/guide/en/elasticsearch/reference/master/get-transform-stats.html
Should it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it should be in stats. I am not 100% sure it should be in the _cat API though. Right now processing times are so small that they are pretty insignificant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise this will be fixed in #54368

static ParseField SEARCH_FAILURES = new ParseField("search_failures");
static ParseField INDEX_FAILURES = new ParseField("index_failures");

public static final ConstructingObjectParser<TransformIndexerStats, Void> LENIENT_PARSER = new ConstructingObjectParser<>(
NAME,
Expand All @@ -58,10 +70,10 @@ public class TransformIndexerStats extends IndexerJobStats {
);

static {
LENIENT_PARSER.declareLong(optionalConstructorArg(), NUM_PAGES);
LENIENT_PARSER.declareLong(optionalConstructorArg(), NUM_INPUT_DOCUMENTS);
LENIENT_PARSER.declareLong(optionalConstructorArg(), NUM_OUTPUT_DOCUMENTS);
LENIENT_PARSER.declareLong(optionalConstructorArg(), NUM_INVOCATIONS);
LENIENT_PARSER.declareLong(optionalConstructorArg(), PAGES_PROCESSED);
LENIENT_PARSER.declareLong(optionalConstructorArg(), DOCUMENTS_PROCESSED);
LENIENT_PARSER.declareLong(optionalConstructorArg(), DOCUMENTS_INDEXED);
LENIENT_PARSER.declareLong(optionalConstructorArg(), TRIGGER_COUNT);
LENIENT_PARSER.declareLong(optionalConstructorArg(), INDEX_TIME_IN_MS);
LENIENT_PARSER.declareLong(optionalConstructorArg(), SEARCH_TIME_IN_MS);
LENIENT_PARSER.declareLong(optionalConstructorArg(), PROCESSING_TIME_IN_MS);
Expand All @@ -82,12 +94,24 @@ public static TransformIndexerStats fromXContent(XContentParser parser) throws I
private final double expAvgCheckpointDurationMs;
private final double expAvgDocumentsIndexed;
private final double expAvgDocumentsProcessed;
private final long pagesProcessed;
private final long documentsProcessed;
private final long documentsIndexed;
private final long triggerCount;
private final long indexTime;
private final long indexTotal;
private final long searchTime;
private final long searchTotal;
private final long processingTime;
private final long processingTotal;
private final long indexFailures;
private final long searchFailures;

public TransformIndexerStats(
long numPages,
long numInputDocuments,
long numOuputDocuments,
long numInvocations,
long pagesProcessed,
long documentsProcessed,
long documentsIndexed,
long triggerCount,
long indexTime,
long searchTime,
long processingTime,
Expand All @@ -100,20 +124,18 @@ public TransformIndexerStats(
double expAvgDocumentsIndexed,
double expAvgDocumentsProcessed
) {
super(
numPages,
numInputDocuments,
numOuputDocuments,
numInvocations,
indexTime,
searchTime,
processingTime,
indexTotal,
searchTotal,
processingTotal,
indexFailures,
searchFailures
);
this.pagesProcessed = pagesProcessed;
this.documentsProcessed = documentsProcessed;
this.documentsIndexed = documentsIndexed;
this.triggerCount = triggerCount;
this.indexTime = indexTime;
this.indexTotal = indexTotal;
this.searchTime = searchTime;
this.searchTotal = searchTotal;
this.processingTime = processingTime;
this.processingTotal = processingTotal;
this.indexFailures = indexFailures;
this.searchFailures = searchFailures;
this.expAvgCheckpointDurationMs = expAvgCheckpointDurationMs;
this.expAvgDocumentsIndexed = expAvgDocumentsIndexed;
this.expAvgDocumentsProcessed = expAvgDocumentsProcessed;
Expand All @@ -131,6 +153,127 @@ public double getExpAvgDocumentsProcessed() {
return expAvgDocumentsProcessed;
}

/**
* The number of pages read from the input indices
*/
public long getPagesProcessed() {
return pagesProcessed;
}

/**
* The number of documents read from the input indices
*/
public long getDocumentsProcessed() {
return documentsProcessed;
}

/**
* Number of times that the job woke up to write documents
*/
public long getTriggerCount() {
return triggerCount;
}

/**
* Number of documents written
*/
public long getDocumentsIndexed() {
return documentsIndexed;
}

/**
* The number of pages read from the input indices
* Deprecated, use {@link TransformIndexerStats#getPagesProcessed()} instead
*/
@Deprecated
public long getNumPages() {
return getPagesProcessed();
}

/**
* The number of documents read from the input indices
* Deprecated, use {@link TransformIndexerStats#getDocumentsProcessed()} instead
*/
@Deprecated
public long getNumDocuments() {
return getDocumentsProcessed();
}

/**
* Number of times that the job woke up to write documents
* Deprecated, use {@link TransformIndexerStats#getTriggerCount()} instead
*/
@Deprecated
public long getNumInvocations() {
return getTriggerCount();
}

/**
* Number of documents written
* Deprecated, use {@link TransformIndexerStats#getDocumentsIndexed()} instead
*/
@Deprecated
public long getOutputDocuments() {
return getDocumentsIndexed();
}

/**
* Number of index failures that have occurred
*/
public long getIndexFailures() {
return indexFailures;
}

/**
* Number of failures that have occurred
*/
public long getSearchFailures() {
return searchFailures;
}

/**
* Returns the time spent indexing (cumulative) in milliseconds
*/
public long getIndexTime() {
return indexTime;
}

/**
* Returns the time spent searching (cumulative) in milliseconds
*/
public long getSearchTime() {
return searchTime;
}

/**
* Returns the time spent processing (cumulative) in milliseconds
*/
public long getProcessingTime() {
return processingTime;
}

/**
* Returns the total number of indexing requests that have been processed
* (Note: this is not the number of _documents_ that have been indexed)
*/
public long getIndexTotal() {
return indexTotal;
}

/**
* Returns the total number of search requests that have been made
*/
public long getSearchTotal() {
return searchTotal;
}

/**
* Returns the total number of processing runs that have been made
*/
public long getProcessingTotal() {
return processingTotal;
}

@Override
public boolean equals(Object other) {
if (this == other) {
Expand All @@ -143,10 +286,10 @@ public boolean equals(Object other) {

TransformIndexerStats that = (TransformIndexerStats) other;

return Objects.equals(this.numPages, that.numPages)
&& Objects.equals(this.numInputDocuments, that.numInputDocuments)
&& Objects.equals(this.numOuputDocuments, that.numOuputDocuments)
&& Objects.equals(this.numInvocations, that.numInvocations)
return Objects.equals(this.pagesProcessed, that.pagesProcessed)
&& Objects.equals(this.documentsProcessed, that.documentsProcessed)
&& Objects.equals(this.documentsIndexed, that.documentsIndexed)
&& Objects.equals(this.triggerCount, that.triggerCount)
&& Objects.equals(this.indexTime, that.indexTime)
&& Objects.equals(this.searchTime, that.searchTime)
&& Objects.equals(this.processingTime, that.processingTime)
Expand All @@ -163,10 +306,10 @@ public boolean equals(Object other) {
@Override
public int hashCode() {
return Objects.hash(
numPages,
numInputDocuments,
numOuputDocuments,
numInvocations,
pagesProcessed,
documentsProcessed,
documentsIndexed,
triggerCount,
indexTime,
searchTime,
processingTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.client.transform.transforms;

import org.elasticsearch.client.core.IndexerJobStats;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.test.ESTestCase;

Expand Down Expand Up @@ -61,18 +60,18 @@ public static TransformIndexerStats randomStats() {
public static void toXContent(TransformIndexerStats stats, XContentBuilder builder) throws IOException {
builder.startObject();
if (randomBoolean()) {
builder.field(IndexerJobStats.NUM_PAGES.getPreferredName(), stats.getNumPages());
builder.field(IndexerJobStats.NUM_INPUT_DOCUMENTS.getPreferredName(), stats.getNumDocuments());
builder.field(IndexerJobStats.NUM_OUTPUT_DOCUMENTS.getPreferredName(), stats.getOutputDocuments());
builder.field(IndexerJobStats.NUM_INVOCATIONS.getPreferredName(), stats.getNumInvocations());
builder.field(IndexerJobStats.INDEX_TIME_IN_MS.getPreferredName(), stats.getIndexTime());
builder.field(IndexerJobStats.INDEX_TOTAL.getPreferredName(), stats.getIndexTotal());
builder.field(IndexerJobStats.INDEX_FAILURES.getPreferredName(), stats.getIndexFailures());
builder.field(IndexerJobStats.SEARCH_TIME_IN_MS.getPreferredName(), stats.getSearchTime());
builder.field(IndexerJobStats.SEARCH_TOTAL.getPreferredName(), stats.getSearchTotal());
builder.field(IndexerJobStats.PROCESSING_TIME_IN_MS.getPreferredName(), stats.getProcessingTime());
builder.field(IndexerJobStats.PROCESSING_TOTAL.getPreferredName(), stats.getProcessingTotal());
builder.field(IndexerJobStats.SEARCH_FAILURES.getPreferredName(), stats.getSearchFailures());
builder.field(TransformIndexerStats.PAGES_PROCESSED.getPreferredName(), stats.getPagesProcessed());
builder.field(TransformIndexerStats.DOCUMENTS_PROCESSED.getPreferredName(), stats.getDocumentsProcessed());
builder.field(TransformIndexerStats.DOCUMENTS_INDEXED.getPreferredName(), stats.getDocumentsIndexed());
builder.field(TransformIndexerStats.TRIGGER_COUNT.getPreferredName(), stats.getTriggerCount());
builder.field(TransformIndexerStats.INDEX_TIME_IN_MS.getPreferredName(), stats.getIndexTime());
builder.field(TransformIndexerStats.INDEX_TOTAL.getPreferredName(), stats.getIndexTotal());
builder.field(TransformIndexerStats.INDEX_FAILURES.getPreferredName(), stats.getIndexFailures());
builder.field(TransformIndexerStats.SEARCH_TIME_IN_MS.getPreferredName(), stats.getSearchTime());
builder.field(TransformIndexerStats.SEARCH_TOTAL.getPreferredName(), stats.getSearchTotal());
builder.field(TransformIndexerStats.PROCESSING_TIME_IN_MS.getPreferredName(), stats.getProcessingTime());
builder.field(TransformIndexerStats.PROCESSING_TOTAL.getPreferredName(), stats.getProcessingTotal());
builder.field(TransformIndexerStats.SEARCH_FAILURES.getPreferredName(), stats.getSearchFailures());
builder.field(
TransformIndexerStats.EXPONENTIAL_AVG_CHECKPOINT_DURATION_MS.getPreferredName(),
stats.getExpAvgCheckpointDurationMs()
Expand All @@ -84,18 +83,18 @@ public static void toXContent(TransformIndexerStats stats, XContentBuilder build
);
} else {
// a toXContent version which leaves out field with value 0 (simulating the case that an older version misses a field)
xContentFieldIfNotZero(builder, IndexerJobStats.NUM_PAGES.getPreferredName(), stats.getNumPages());
xContentFieldIfNotZero(builder, IndexerJobStats.NUM_INPUT_DOCUMENTS.getPreferredName(), stats.getNumDocuments());
xContentFieldIfNotZero(builder, IndexerJobStats.NUM_OUTPUT_DOCUMENTS.getPreferredName(), stats.getOutputDocuments());
xContentFieldIfNotZero(builder, IndexerJobStats.NUM_INVOCATIONS.getPreferredName(), stats.getNumInvocations());
xContentFieldIfNotZero(builder, IndexerJobStats.INDEX_TIME_IN_MS.getPreferredName(), stats.getIndexTime());
xContentFieldIfNotZero(builder, IndexerJobStats.INDEX_TOTAL.getPreferredName(), stats.getIndexTotal());
xContentFieldIfNotZero(builder, IndexerJobStats.INDEX_FAILURES.getPreferredName(), stats.getIndexFailures());
xContentFieldIfNotZero(builder, IndexerJobStats.SEARCH_TIME_IN_MS.getPreferredName(), stats.getSearchTime());
xContentFieldIfNotZero(builder, IndexerJobStats.SEARCH_TOTAL.getPreferredName(), stats.getSearchTotal());
xContentFieldIfNotZero(builder, IndexerJobStats.PROCESSING_TIME_IN_MS.getPreferredName(), stats.getProcessingTime());
xContentFieldIfNotZero(builder, IndexerJobStats.PROCESSING_TOTAL.getPreferredName(), stats.getProcessingTotal());
xContentFieldIfNotZero(builder, IndexerJobStats.SEARCH_FAILURES.getPreferredName(), stats.getSearchFailures());
xContentFieldIfNotZero(builder, TransformIndexerStats.PAGES_PROCESSED.getPreferredName(), stats.getPagesProcessed());
xContentFieldIfNotZero(builder, TransformIndexerStats.DOCUMENTS_PROCESSED.getPreferredName(), stats.getDocumentsProcessed());
xContentFieldIfNotZero(builder, TransformIndexerStats.DOCUMENTS_INDEXED.getPreferredName(), stats.getDocumentsIndexed());
xContentFieldIfNotZero(builder, TransformIndexerStats.TRIGGER_COUNT.getPreferredName(), stats.getTriggerCount());
xContentFieldIfNotZero(builder, TransformIndexerStats.INDEX_TIME_IN_MS.getPreferredName(), stats.getIndexTime());
xContentFieldIfNotZero(builder, TransformIndexerStats.INDEX_TOTAL.getPreferredName(), stats.getIndexTotal());
xContentFieldIfNotZero(builder, TransformIndexerStats.INDEX_FAILURES.getPreferredName(), stats.getIndexFailures());
xContentFieldIfNotZero(builder, TransformIndexerStats.SEARCH_TIME_IN_MS.getPreferredName(), stats.getSearchTime());
xContentFieldIfNotZero(builder, TransformIndexerStats.SEARCH_TOTAL.getPreferredName(), stats.getSearchTotal());
xContentFieldIfNotZero(builder, TransformIndexerStats.PROCESSING_TIME_IN_MS.getPreferredName(), stats.getProcessingTime());
xContentFieldIfNotZero(builder, TransformIndexerStats.PROCESSING_TOTAL.getPreferredName(), stats.getProcessingTotal());
xContentFieldIfNotZero(builder, TransformIndexerStats.SEARCH_FAILURES.getPreferredName(), stats.getSearchFailures());
xContentFieldIfNotZero(
builder,
TransformIndexerStats.EXPONENTIAL_AVG_CHECKPOINT_DURATION_MS.getPreferredName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ public static void assertTransformIndexerStats(
assertThat(serverTestInstance.getExpAvgCheckpointDurationMs(), equalTo(clientInstance.getExpAvgCheckpointDurationMs()));
assertThat(serverTestInstance.getExpAvgDocumentsProcessed(), equalTo(clientInstance.getExpAvgDocumentsProcessed()));
assertThat(serverTestInstance.getExpAvgDocumentsIndexed(), equalTo(clientInstance.getExpAvgDocumentsIndexed()));
assertThat(serverTestInstance.getNumPages(), equalTo(clientInstance.getNumPages()));
assertThat(serverTestInstance.getNumPages(), equalTo(clientInstance.getPagesProcessed()));
assertThat(serverTestInstance.getIndexFailures(), equalTo(clientInstance.getIndexFailures()));
assertThat(serverTestInstance.getIndexTime(), equalTo(clientInstance.getIndexTime()));
assertThat(serverTestInstance.getIndexTotal(), equalTo(clientInstance.getIndexTotal()));
assertThat(serverTestInstance.getNumDocuments(), equalTo(clientInstance.getNumDocuments()));
assertThat(serverTestInstance.getNumInvocations(), equalTo(clientInstance.getNumInvocations()));
assertThat(serverTestInstance.getOutputDocuments(), equalTo(clientInstance.getOutputDocuments()));
assertThat(serverTestInstance.getNumDocuments(), equalTo(clientInstance.getDocumentsProcessed()));
assertThat(serverTestInstance.getNumInvocations(), equalTo(clientInstance.getTriggerCount()));
assertThat(serverTestInstance.getOutputDocuments(), equalTo(clientInstance.getDocumentsIndexed()));
assertThat(serverTestInstance.getSearchFailures(), equalTo(clientInstance.getSearchFailures()));
assertThat(serverTestInstance.getSearchTime(), equalTo(clientInstance.getSearchTime()));
assertThat(serverTestInstance.getSearchTotal(), equalTo(clientInstance.getSearchTotal()));
Expand Down
Loading