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

[Fleet] Support input-level vars & templates #83878

Merged
merged 9 commits into from
Nov 25, 2020

Conversation

jen-huang
Copy link
Contributor

@jen-huang jen-huang commented Nov 20, 2020

Summary

Resolves #82599. This PR enables input-level agent YAML templates, similar to stream-level templates. Input-level vars will be passed to the specified template in package info. The input can have streams or no streams. Here is an example showing the package info containing template_path field on the input, the contents of that template, and the final agent yaml generated by Kibana with this change:

(for cleaner illustration purposes, this input does not have streams)

Package info

  "policy_templates": [
    {
      "name": "input_level_templates",
      "title": "Input level templates",
      "description": "Input with input-level template to use input-level vars with",
      "inputs": [
        {
          "type": "logs",
          "vars": [
            {
              "name": "paths",
              "type": "text",
              "title": "Paths",
              "multi": true,
              "required": true,
              "show_user": false,
              "default": [
                "/foo/bar",
                "/test/path"
              ]
            },
            {
              "name": "host",
              "type": "text",
              "title": "Host",
              "multi": false,
              "required": true,
              "show_user": false
            }
          ],
          "title": "Collect logs",
          "template_path": "template.yml.hbs"
        }
      ],
      "multiple": true
    }
  ]

/agent/input/template.yml.hbs

fixedField: some value
paths:
{{#each paths}}
  - {{this}}
{{/each}}
host: {{host}}

Agent yaml

inputs:
  - id: b42d8fc8-6fb7-4c5a-96bb-c4fa3120b6b8
    name: input_level_templates-1
    revision: 1
    type: logs
    use_output: default
    meta:
      package:
        name: input_level_templates
        version: 1.0.0
    data_stream:
      namespace: default
    fixedField: some value
    paths:
      - /foo/bar
      - /test/path
    host: localhost

Here's what the integration policy form UI looks like for the same. Note that there is only a top-level Settings section for the input-level vars, and no stream toggles are displayed underneath it:

image

Testing

  1. Run Kibana using a local package registry running latest main or this PR branch
  2. Find and add the test integration called "Input level templates"
  3. The UI and agent policy yaml output should reflect above screenshots

@jen-huang jen-huang added v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.11.0 labels Nov 20, 2020
@jen-huang jen-huang self-assigned this Nov 20, 2020
@jen-huang jen-huang changed the title [Fleet] Allow input-level vars & templates, without streams [Fleet] Support input-level vars & templates Nov 20, 2020
@jen-huang jen-huang marked this pull request as ready for review November 20, 2020 20:01
@jen-huang jen-huang requested a review from a team November 20, 2020 20:02
@elasticmachine
Copy link
Contributor

Pinging @elastic/ingest-management (Team:Ingest Management)

@jen-huang
Copy link
Contributor Author

@elasticmachine merge upstream

@ruflin
Copy link
Member

ruflin commented Nov 24, 2020

@jen-huang Can we skip the streams part?

Copy link
Member

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍 and work as expected

@jen-huang
Copy link
Contributor Author

@nchaulet Thanks for testing!

@ruflin 493e54a Sure, removed empty streams: [] from agent yaml when there are no streams.

@jen-huang jen-huang requested review from a team as code owners November 25, 2020 00:34
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 1.1MB 1.1MB +558.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 374.7KB 374.8KB +93.0B

Saved Objects .kibana field count

Every field in each saved object type adds overhead to Elasticsearch. Kibana needs to keep the total field count below Elasticsearch's default limit of 1000 fields. Only specify field mappings for the fields you wish to search on or query. See https://www.elastic.co/guide/en/kibana/master/development-plugin-saved-objects.html#_mappings

id before after diff
ingest-package-policies 30 31 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@jalvz jalvz left a comment

Choose a reason for hiding this comment

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

works great, thanks!

@jen-huang jen-huang merged commit 284b104 into elastic:master Nov 25, 2020
@jen-huang jen-huang deleted the ingest/input-vars-templates branch November 25, 2020 18:13
jen-huang added a commit that referenced this pull request Nov 25, 2020
* Fix bug creating new policy on the fly

* Adjust UI for input with vars but no streams

* Revert "Fix bug creating new policy on the fly"

This reverts commit 34f7014.

* Add `compiled_input` field and compile input template, if any. Make compilation method names more generic (instead of only for streams). Add testts

* Add compiled input to generated agent yaml

* Don't return empty streams in agent yaml when there aren't any

* Update missed assertion

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Nov 26, 2020
* master: (70 commits)
  [Uptime] Fix headers io-ts type (elastic#84089)
  [fleet] Add config options to accepted docker env vars (elastic#84338)
  [Fleet] Support URL query state in agent logs UI (elastic#84298)
  [basePathProxy] include query in redirect (elastic#84356)
  [Security Solution] Add Endpoint policy feature checks (elastic#83972)
  Fix issues with show_license_expiration (elastic#84361)
  [Security Solution][Resolver] Add support for predefined schemas for endpoint and winlogbeat (elastic#84103)
  [cli/dev] log a warning when --no-base-path is used with --dev (elastic#84354)
  [Fleet] Support input-level vars & templates (elastic#83878)
  [APM] Elastic chart issues (elastic#84238)
  [Time to Visualize] Fix Unlink Action via Rollback of ReplacePanel (elastic#83873)
  redirect to visualize listing page when by value visualization editor doesn't have a value input (elastic#84287)
  add live region for field search (elastic#84310)
  [ML] Persisted URL state for Anomalies table (elastic#84314)
  [dev/cli] detect worker type using env, not cluster module (elastic#83977)
  [Workplace Search] Migrate DisplaySettings tree (elastic#84283)
  Deprecate `xpack.task_manager.index` setting (elastic#84155)
  [Search] Search batching using bfetch (again) (elastic#84043)
  Use .kibana instead of .kibana_current to mark migration completion (elastic#83373)
  [Monitoring] Only look at ES for the missing data alert for now (elastic#83839)
  ...
gmmorris added a commit to gmmorris/kibana that referenced this pull request Nov 26, 2020
* master: (119 commits)
  [Uptime] Fix headers io-ts type (elastic#84089)
  [fleet] Add config options to accepted docker env vars (elastic#84338)
  [Fleet] Support URL query state in agent logs UI (elastic#84298)
  [basePathProxy] include query in redirect (elastic#84356)
  [Security Solution] Add Endpoint policy feature checks (elastic#83972)
  Fix issues with show_license_expiration (elastic#84361)
  [Security Solution][Resolver] Add support for predefined schemas for endpoint and winlogbeat (elastic#84103)
  [cli/dev] log a warning when --no-base-path is used with --dev (elastic#84354)
  [Fleet] Support input-level vars & templates (elastic#83878)
  [APM] Elastic chart issues (elastic#84238)
  [Time to Visualize] Fix Unlink Action via Rollback of ReplacePanel (elastic#83873)
  redirect to visualize listing page when by value visualization editor doesn't have a value input (elastic#84287)
  add live region for field search (elastic#84310)
  [ML] Persisted URL state for Anomalies table (elastic#84314)
  [dev/cli] detect worker type using env, not cluster module (elastic#83977)
  [Workplace Search] Migrate DisplaySettings tree (elastic#84283)
  Deprecate `xpack.task_manager.index` setting (elastic#84155)
  [Search] Search batching using bfetch (again) (elastic#84043)
  Use .kibana instead of .kibana_current to mark migration completion (elastic#83373)
  [Monitoring] Only look at ES for the missing data alert for now (elastic#83839)
  ...
gmmorris added a commit to gmmorris/kibana that referenced this pull request Dec 9, 2020
* master: (119 commits)
  [Uptime] Fix headers io-ts type (elastic#84089)
  [fleet] Add config options to accepted docker env vars (elastic#84338)
  [Fleet] Support URL query state in agent logs UI (elastic#84298)
  [basePathProxy] include query in redirect (elastic#84356)
  [Security Solution] Add Endpoint policy feature checks (elastic#83972)
  Fix issues with show_license_expiration (elastic#84361)
  [Security Solution][Resolver] Add support for predefined schemas for endpoint and winlogbeat (elastic#84103)
  [cli/dev] log a warning when --no-base-path is used with --dev (elastic#84354)
  [Fleet] Support input-level vars & templates (elastic#83878)
  [APM] Elastic chart issues (elastic#84238)
  [Time to Visualize] Fix Unlink Action via Rollback of ReplacePanel (elastic#83873)
  redirect to visualize listing page when by value visualization editor doesn't have a value input (elastic#84287)
  add live region for field search (elastic#84310)
  [ML] Persisted URL state for Anomalies table (elastic#84314)
  [dev/cli] detect worker type using env, not cluster module (elastic#83977)
  [Workplace Search] Migrate DisplaySettings tree (elastic#84283)
  Deprecate `xpack.task_manager.index` setting (elastic#84155)
  [Search] Search batching using bfetch (again) (elastic#84043)
  Use .kibana instead of .kibana_current to mark migration completion (elastic#83373)
  [Monitoring] Only look at ES for the missing data alert for now (elastic#83839)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fleet] Add support for new template path above data stream folders
6 participants