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

Parameters for Scripted Fields #19716

Closed
dcode opened this issue Jun 7, 2018 · 2 comments
Closed

Parameters for Scripted Fields #19716

dcode opened this issue Jun 7, 2018 · 2 comments
Labels
Feature:Kibana Management Feature label for Data Views, Advanced Setting, Saved Object management pages impact:needs-assessment Product and/or Engineering needs to evaluate the impact of the change. loe:small Small Level of Effort painless painless

Comments

@dcode
Copy link
Contributor

dcode commented Jun 7, 2018

Expose parameters for scripted fields as documented in the Search API reference.

The UI would allow adding a dynamic form field with a "Add parameter" button. This would create two text input controls, specifying the parameter name and value. Maybe there's a performance reason to set a limit on the maximum number of fields.

For the backend field definition in the fields attribute of the index pattern, I recommend simply adding a params object like so:

    "bro_fields": {
        "aggregatable": true, 
        "count": 0, 
        "lang": "painless", 
        "name": "network.pcap", 
        "readFromDocValues": false, 
        "params": { 
            "baseUrl": "https://127.0.0.1/docket/api/"
         },
        "script": "String baseUrl = params.api_url; \nif (doc['event.type'].value == 'network') {  \n    String host1 = doc['source.ip'].value; \n    String host2 = doc['destination.ip'].value; \n    String port1 = doc['source.port'].toString(); \n    String port2 = doc['destination.port'].toString(); \n  return baseUrl + \n        'host/' + host1 + '/port/' + port1 + \n        '/host/' + host2 + '/port/' + port2  \n } \nreturn '';", 
        "scripted": true, 
        "searchable": true, 
        "type": "string"
    }

My particular use case is that I'm a core developer of RockNSM and I want to create a calculated field that depends on both the schema (which is static) and the deployment (which changes every install). Namely, I have to be able to build a URL field given the record data and point to an IP/hostname that depends on the deployment.

Short of #16252 with the granularity of individual field manipulation parameters would make my life a lot easier. The workd around is:

  1. extract the index pattern
  2. extract both the fields and fieldFormatMap data, decode them to JSON
  3. update the JSON for the individual field
  4. push back to kibana, overwriting the entire index
  5. ...
  6. Profit!

P.S. ~ Not likely, but I'll give you a bonus 🍄 (<-- GitHub doesn't have a 1UP) if you can make this by 6.3 or a patch release soon thereafter.

@spalger spalger removed the v6.6.0 label Aug 14, 2018
@timroes timroes added Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Kibana Management Feature label for Data Views, Advanced Setting, Saved Object management pages and removed :Management DO NOT USE labels Nov 27, 2018
@cjcenizal cjcenizal added the painless painless label Mar 5, 2020
@flash1293 flash1293 added Team:AppServicesSv and removed Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Nov 19, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServicesSv)

@exalate-issue-sync exalate-issue-sync bot added impact:needs-assessment Product and/or Engineering needs to evaluate the impact of the change. loe:small Small Level of Effort labels Dec 13, 2021
@mattkime
Copy link
Contributor

Scripted fields have been deprecated and are being replaced with runtime fields. We have APIs that would help you do something approximating this - https://www.elastic.co/guide/en/kibana/current/index-patterns-api.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Kibana Management Feature label for Data Views, Advanced Setting, Saved Object management pages impact:needs-assessment Product and/or Engineering needs to evaluate the impact of the change. loe:small Small Level of Effort painless painless
Projects
None yet
Development

No branches or pull requests

8 participants