Skip to content
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

Enhance the ingest node simulate verbose output #60433

Merged
merged 20 commits into from
Aug 4, 2020

Conversation

jakelandis
Copy link
Contributor

@jakelandis jakelandis commented Jul 29, 2020

This commit enhances the verbose output for the
_ingest/pipeline/_simulate?verbose api. Specifically
this adds the following:

  • the pipeline processor is now included in the output
  • the conditional (if) and result is now included in the output iff it was defined
  • a status field is always displayed. the possible values of status are
    • success - if the processor ran with out errors
    • error - if the processor ran but threw an error that was not ingored
    • error_ignored - if the processor ran but threw an error that was ingored
    • skipped - if the process did not run (currently only possible if the if condition evaluates to false)
    • dropped - if the the drop processor ran and dropped the document
  • a processor_type field for the type of processor (e.g. set, rename, etc.)
  • throw a better error if trying to simulate with a pipeline that does not exist

closes #56004

===========

Example input:

POST _ingest/pipeline/_simulate?verbose
{
  "pipeline": {
    "description": "_description",
    "processors": [
      {
        "set": {
          "description": "processor_description",
          "tag": "processor_tag",
          "field": "field1",
          "value": "value1"
        }
      },
      {
        "rename": {
          "field": "dont_exist",
          "target_field": "field1",
          "ignore_failure": true
        }
      },
      {
        "rename": {
          "tag": "rename-1",
          "field": "foofield",
          "target_field": "field1",
          "on_failure": [
            {
              "set": {
                "field": "field2",
                "value": "value2"
              }
            }
          ]
        }
      },
      {
        "drop": {
          "if": "false"
        }
      },
      {
        "drop": {
          "if": "true"
        }
      }
    ]
  },
  "docs": [
    {
      "_index": "index",
      "_id": "id",
      "_source": {
        "foo": "bar"
      }
    }
  ]
}

Example output:

{
  "docs" : [
    {
      "processor_results" : [
        {
          "processor_type" : "set",
          "status" : "success",
          "description" : "processor_description",
          "tag" : "processor_tag",
          "doc" : {
            "_index" : "index",
            "_id" : "id",
            "_source" : {
              "field1" : "value1",
              "foo" : "bar"
            },
            "_ingest" : {
              "pipeline" : "_simulate_pipeline",
              "timestamp" : "2020-07-30T01:06:43.961586Z"
            }
          }
        },
        {
          "processor_type" : "rename",
          "status" : "error_ignored",
          "ignored_error" : {
            "error" : {
              "root_cause" : [
                {
                  "type" : "illegal_argument_exception",
                  "reason" : "field [dont_exist] doesn't exist"
                }
              ],
              "type" : "illegal_argument_exception",
              "reason" : "field [dont_exist] doesn't exist"
            }
          },
          "doc" : {
            "_index" : "index",
            "_id" : "id",
            "_source" : {
              "field1" : "value1",
              "foo" : "bar"
            },
            "_ingest" : {
              "pipeline" : "_simulate_pipeline",
              "timestamp" : "2020-07-30T01:06:43.961586Z"
            }
          }
        },
        {
          "processor_type" : "rename",
          "status" : "error",
          "tag" : "rename-1",
          "error" : {
            "root_cause" : [
              {
                "type" : "illegal_argument_exception",
                "reason" : "field [foofield] doesn't exist"
              }
            ],
            "type" : "illegal_argument_exception",
            "reason" : "field [foofield] doesn't exist"
          }
        },
        {
          "processor_type" : "set",
          "status" : "success",
          "doc" : {
            "_index" : "index",
            "_id" : "id",
            "_source" : {
              "field1" : "value1",
              "field2" : "value2",
              "foo" : "bar"
            },
            "_ingest" : {
              "pipeline" : "_simulate_pipeline",
              "on_failure_message" : "field [foofield] doesn't exist",
              "on_failure_processor_tag" : "rename-1",
              "timestamp" : "2020-07-30T01:06:43.961586Z",
              "on_failure_processor_type" : "rename"
            }
          }
        },
        {
          "processor_type" : "drop",
          "status" : "skipped",
          "if" : {
            "condition" : "false",
            "result" : false
          }
        },
        {
          "processor_type" : "drop",
          "status" : "dropped",
          "if" : {
            "condition" : "true",
            "result" : true
          }
        }
      ]
    }
  ]
}

- match: { docs.0.processor_results.0.doc._source.field1: "123.42 400 <foo>" }
- match: { docs.0.processor_results.0.doc._source.status: 200 }
- length: { docs.0.processor_results.1: 2 }
- length: { docs.0.processor_results.1: 4 }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

because we now always return status and processor_type

@@ -731,16 +741,25 @@ teardown:
]
}
- length: { docs: 1 }
- length: { docs.0.processor_results: 3 }
- length: { docs.0.processor_results: 5 }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

because we now show the pipeline processor in the results

}
handler.accept(null, elasticsearchException);
}
} else {
//now that we know that there are no cycles between pipelines, decorate the processors for this pipeline and execute it
CompoundProcessor verbosePipelineProcessor = decorate(pipeline.getCompoundProcessor(), null, processorResultList);
//add the pipeline process to the results
processorResultList.add(new SimulateProcessorResult(actualProcessor.getType(), actualProcessor.getTag(),
actualProcessor.getDescription(), conditionalWithResult));
Copy link
Contributor Author

@jakelandis jakelandis Jul 30, 2020

Choose a reason for hiding this comment

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

I think we never added the pipeline processor in the past because there would have been nothing to display, but now that we always show the type (pipeline) and status (i.e. success) there is something to display, so this line is what adds this to the output. The addition of this output caused a few tests to need to be updated

@jakelandis jakelandis added :Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP >enhancement v7.10.0 v8.0.0 labels Jul 30, 2020
@jakelandis jakelandis marked this pull request as ready for review July 30, 2020 01:09
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (:Core/Features/Ingest)

@jakelandis jakelandis requested a review from jbaiera August 3, 2020 15:28
Copy link
Member

@jbaiera jbaiera left a comment

Choose a reason for hiding this comment

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

Just one question, but otherwise LGTM

@@ -35,6 +36,7 @@
private final ConditionalProcessor conditionalProcessor;
private final List<SimulateProcessorResult> processorResultList;
private final boolean ignoreFailure;
private Tuple<String, Boolean> conditionalWithResult = null; //null = no conditional
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this could be a local variable in the execute function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks @jbaiera , indeed. updated 5c26a6b

@jakelandis jakelandis merged commit 35fc997 into elastic:master Aug 4, 2020
@jakelandis jakelandis deleted the show_conditional branch August 4, 2020 18:09
jakelandis added a commit to jakelandis/elasticsearch that referenced this pull request Aug 4, 2020
This commit enhances the verbose output for the
`_ingest/pipeline/_simulate?verbose` api. Specifically
this adds the following:

* the pipeline processor is now included in the output
* the conditional (if) and result is now included in the output iff it was defined
* a status field is always displayed. the possible values of status are
  * `success` - if the processor ran with out errors
  * `error` - if the processor ran but threw an error that was not ingored
  * `error_ignored` - if the processor ran but threw an error that was ingored
  * `skipped` - if the process did not run (currently only possible if the if condition evaluates to false)
  * `dropped` - if the the `drop` processor ran and dropped the document
* a `processor_type` field for the type of processor (e.g. set, rename, etc.)
* throw a better error if trying to simulate with a pipeline that does not exist

closes elastic#56004
# Conflicts:
#	docs/reference/ingest/apis/simulate-pipeline.asciidoc
jakelandis added a commit that referenced this pull request Aug 27, 2020
This commit enhances the verbose output for the
`_ingest/pipeline/_simulate?verbose` api. Specifically
this adds the following:
* the pipeline processor is now included in the output
* the conditional (if) and result is now included in the output iff it was defined
* a status field is always displayed. the possible values of status are
  * `success` - if the processor ran with out errors
  * `error` - if the processor ran but threw an error that was not ingored
  * `error_ignored` - if the processor ran but threw an error that was ingored
  * `skipped` - if the process did not run (currently only possible if the if condition evaluates to false)
  * `dropped` - if the the `drop` processor ran and dropped the document
* a `processor_type` field for the type of processor (e.g. set, rename, etc.)
* throw a better error if trying to simulate with a pipeline that does not exist

closes #56004
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP >enhancement Team:Data Management Meta label for data/management team v7.10.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Ingest Node Pipelines] More detailed _simulate response
3 participants