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

Watcher does not support passing the "params" to stored script #57625

Closed
jguay opened this issue Jun 3, 2020 · 4 comments
Closed

Watcher does not support passing the "params" to stored script #57625

jguay opened this issue Jun 3, 2020 · 4 comments
Labels

Comments

@jguay
Copy link
Contributor

jguay commented Jun 3, 2020

Elasticsearch version (bin/elasticsearch --version):
7.6.2 / 7.7.0
Description of the problem including expected versus actual behavior:
Currently watcher does not support passing params although there is an example in the doc
Steps to reproduce:
Run this in dev tools :

PUT _scripts/log-action
{
  "script": {
    "lang": "mustache",
    "source": "just color: {{color}}, params color: {{params.color}} executed at {{ctx.execution_time}}"
  }
}

PUT _watcher/watch/test
{
  "trigger": {
    "schedule": {
      "interval": "1m"
    }
  },
  "input": {
    "simple": {}
  },
  "condition": {
    "always": {}
  },
  "actions": {
    "log": {
      "logging": {
        "text": {
          "id": "log-action",
          "params": {
            "color": "blue"
          }
        }
      }
    }
  }
}

Provide logs (if relevant):

{"type": "server", "timestamp": "2020-06-03T09:15:48,493Z", "level": "INFO", "component": "o.e.x.w.a.l.ExecutableLoggingAction", "cluster.name": "cluster0", "node.name": "es0", "message": "just color: , params color:  executed at 2020-06-03T09:15:48.486126Z", "cluster.uuid": "A0eOxXQGSCyngs4q2mA-IQ", "node.id": "G0DexTtWStWbzb4dYfnIJg"  }

Workaround solution:
Use metadata instead of parameters in the script and watcher:

PUT _scripts/log-action
{
  "script": {
    "lang": "mustache",
    "source": "color: {{ctx.metadata.color}} executed at {{ctx.execution_time}}"
  }
}

PUT _watcher/watch/test
{
  "metadata": {
     "color": "blue"
  },
  "trigger": {
    "schedule": {
      "interval": "1m"
    }
  },
  "input": {
    "simple": {}
  },
  "condition": {
    "always": {}
  },
  "actions": {
    "log": {
      "logging": {
        "text": {
          "id": "log-action"
        }
      }
    }
  }
}
@jguay jguay added >bug :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache :Data Management/Watcher needs:triage Requires assignment of a team area label labels Jun 3, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Scripting)

@elasticmachine
Copy link
Collaborator

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

@elasticmachine elasticmachine added Team:Core/Infra Meta label for core/infra team Team:Data Management Meta label for data/management team labels Jun 3, 2020
@rjernst rjernst removed the :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache label Jun 3, 2020
@elasticmachine elasticmachine removed the Team:Core/Infra Meta label for core/infra team label Jun 3, 2020
@fbaligand
Copy link
Contributor

I get the same issue and am very interested by the fix!

@gwbrown gwbrown removed the needs:triage Requires assignment of a team area label label Jul 6, 2020
jakelandis pushed a commit that referenced this issue Sep 2, 2020
The main changes are:
* Fix custom params are missing when using template or script in watcher's 
  logging action or jira action.
* Add yaml tests to test passing params to template or script successfully.

Relates to #57625
jakelandis pushed a commit to jakelandis/elasticsearch that referenced this issue Sep 2, 2020
…8559)

The main changes are:
* Fix custom params are missing when using template or script in watcher's 
  logging action or jira action.
* Add yaml tests to test passing params to template or script successfully.

Relates to elastic#57625
jakelandis added a commit that referenced this issue Sep 3, 2020
) (#61885)

The main changes are:
* Fix custom params are missing when using template or script in watcher's 
  logging action or jira action.
* Add yaml tests to test passing params to template or script successfully.

Relates to #57625

Co-authored-by: bellengao <[email protected]>
@joegallo
Copy link
Contributor

joegallo commented Nov 4, 2020

Closing since #58559 has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants