-
Notifications
You must be signed in to change notification settings - Fork 8k
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] Config in "Configs" tab in integrations app is malformed #180307
Comments
Pinging @elastic/fleet (Team:Fleet) |
Hey @flash1293 - we are starting to take a look at this. Can you clarify whether you were following the notes on the config tab page and pasting these into |
@kpollich I copy-pasted the contents of the "Config" tab into the "inputs" section of my I configured the output separately / on my own. |
I traced back the source of the issue to this line. As @flash1293 noticed, we are flattening the streams. I don't recall anymore why is that, but that's the main difference between the inputs in Configs vs generated agent policy. I'll have a fix for it and I'll make sure to backport as well. |
Example of ningx inputs generated in Configs tab without the flattening: inputs:
- id: logfile-nginx
streams:
- id: logfile-nginx.access
data_stream:
dataset: nginx.access
type: logs
ignore_older: 72h
paths:
- /var/log/nginx/access.log*
tags:
- nginx-access
exclude_files:
- .gz$
processors:
- add_locale: null
- id: logfile-nginx.error
data_stream:
dataset: nginx.error
type: logs
ignore_older: 72h
paths:
- /var/log/nginx/error.log*
tags:
- nginx-error
exclude_files:
- .gz$
multiline:
pattern: '^\d{4}\/\d{2}\/\d{2} '
negate: true
match: after
processors:
- add_locale: null
- id: httpjson-nginx
streams:
- id: httpjson-nginx.access
data_stream:
dataset: nginx.access
type: logs
config_version: 2
interval: 10s
cursor:
index_earliest:
value: '[[.last_event.result.max_indextime]]'
request.url: 'https://server.example.com:8089/services/search/jobs/export'
request.ssl: null
request.method: POST
request.transforms:
- set:
target: url.params.search
value: >-
search sourcetype=nginx:plus:access | streamstats
max(_indextime) AS max_indextime
- set:
target: url.params.output_mode
value: json
- set:
target: url.params.index_earliest
value: '[[ .cursor.index_earliest ]]'
default: '[[(now (parseDuration "-10s")).Unix]]'
- set:
target: url.params.index_latest
value: '[[(now).Unix]]'
- set:
target: header.Content-Type
value: application/x-www-form-urlencoded
response.decode_as: application/x-ndjson
response.split:
type: string
target: body.result._raw
delimiter: |+
tags:
- forwarded
- nginx-access
publisher_pipeline.disable_host: true
- id: httpjson-nginx.error
data_stream:
dataset: nginx.error
type: logs
config_version: 2
interval: 10s
cursor:
index_earliest:
value: '[[.last_event.result.max_indextime]]'
request.url: 'https://server.example.com:8089/services/search/jobs/export'
request.ssl: null
request.method: POST
request.transforms:
- set:
target: url.params.search
value: >-
search sourcetype=nginx:plus:error | streamstats max(_indextime)
AS max_indextime
- set:
target: url.params.output_mode
value: json
- set:
target: url.params.index_earliest
value: '[[ .cursor.index_earliest ]]'
default: '[[(now (parseDuration "-10s")).Unix]]'
- set:
target: url.params.index_latest
value: '[[(now).Unix]]'
- set:
target: header.Content-Type
value: application/x-www-form-urlencoded
response.decode_as: application/x-ndjson
response.split:
type: string
target: body.result._raw
delimiter: |+
tags:
- forwarded
- nginx-error
publisher_pipeline.disable_host: true
- id: nginx/metrics-nginx
streams:
- id: nginx/metrics-nginx.stubstatus
data_stream:
dataset: nginx.stubstatus
type: metrics
metricsets:
- stubstatus
hosts:
- 'http://127.0.0.1:80'
tags:
- nginx-stubstatus
period: 10s
server_status_path: /nginx_status And this is the inputs section in the generated agent policy: inputs:
- id: logfile-nginx-2a30bd3c-7a6c-469a-8ad3-f8aa11f2392b
name: nginx-2
revision: 1
type: logfile
use_output: default
meta:
package:
name: nginx
version: 1.20.0
data_stream:
namespace: default
package_policy_id: 2a30bd3c-7a6c-469a-8ad3-f8aa11f2392b
streams:
- id: logfile-nginx.access-2a30bd3c-7a6c-469a-8ad3-f8aa11f2392b
data_stream:
dataset: nginx.access
type: logs
ignore_older: 72h
paths:
- /var/log/nginx/access.log*
tags:
- nginx-access
exclude_files:
- .gz$
processors:
- add_locale: null
- id: logfile-nginx.error-2a30bd3c-7a6c-469a-8ad3-f8aa11f2392b
data_stream:
dataset: nginx.error
type: logs
ignore_older: 72h
paths:
- /var/log/nginx/error.log*
tags:
- nginx-error
exclude_files:
- .gz$
multiline:
pattern: '^\d{4}\/\d{2}\/\d{2} '
negate: true
match: after
processors:
- add_locale: null
- id: httpjson-nginx-2a30bd3c-7a6c-469a-8ad3-f8aa11f2392b
name: nginx-2
revision: 1
type: httpjson
use_output: default
meta:
package:
name: nginx
version: 1.20.0
data_stream:
namespace: default
package_policy_id: 2a30bd3c-7a6c-469a-8ad3-f8aa11f2392b
streams:
- id: httpjson-nginx.access-2a30bd3c-7a6c-469a-8ad3-f8aa11f2392b
data_stream:
dataset: nginx.access
type: logs
config_version: 2
interval: 10s
cursor:
index_earliest:
value: '[[.last_event.result.max_indextime]]'
request.url: 'https://server.example.com:8089/services/search/jobs/export'
request.ssl: null
request.method: POST
request.transforms:
- set:
target: url.params.search
value: >-
search sourcetype=nginx:plus:access | streamstats
max(_indextime) AS max_indextime
- set:
target: url.params.output_mode
value: json
- set:
target: url.params.index_earliest
value: '[[ .cursor.index_earliest ]]'
default: '[[(now (parseDuration "-10s")).Unix]]'
- set:
target: url.params.index_latest
value: '[[(now).Unix]]'
- set:
target: header.Content-Type
value: application/x-www-form-urlencoded
response.decode_as: application/x-ndjson
response.split:
type: string
target: body.result._raw
delimiter: |+
tags:
- forwarded
- nginx-access
publisher_pipeline.disable_host: true
- id: httpjson-nginx.error-2a30bd3c-7a6c-469a-8ad3-f8aa11f2392b
data_stream:
dataset: nginx.error
type: logs
config_version: 2
interval: 10s
cursor:
index_earliest:
value: '[[.last_event.result.max_indextime]]'
request.url: 'https://server.example.com:8089/services/search/jobs/export'
request.ssl: null
request.method: POST
request.transforms:
- set:
target: url.params.search
value: >-
search sourcetype=nginx:plus:error | streamstats max(_indextime)
AS max_indextime
- set:
target: url.params.output_mode
value: json
- set:
target: url.params.index_earliest
value: '[[ .cursor.index_earliest ]]'
default: '[[(now (parseDuration "-10s")).Unix]]'
- set:
target: url.params.index_latest
value: '[[(now).Unix]]'
- set:
target: header.Content-Type
value: application/x-www-form-urlencoded
response.decode_as: application/x-ndjson
response.split:
type: string
target: body.result._raw
delimiter: |+
tags:
- forwarded
- nginx-error
publisher_pipeline.disable_host: true
- id: nginx/metrics-nginx-2a30bd3c-7a6c-469a-8ad3-f8aa11f2392b
name: nginx-2
revision: 1
type: nginx/metrics
use_output: default
meta:
package:
name: nginx
version: 1.20.0
data_stream:
namespace: default
package_policy_id: 2a30bd3c-7a6c-469a-8ad3-f8aa11f2392b
streams:
- id: nginx/metrics-nginx.stubstatus-2a30bd3c-7a6c-469a-8ad3-f8aa11f2392b
data_stream:
dataset: nginx.stubstatus
type: metrics
metricsets:
- stubstatus
hosts:
- 'http://127.0.0.1:80'
tags:
- nginx-stubstatus
period: 10s
server_status_path: /nginx_status The original data structure is now preserved, the only difference between the two is that the following parameters are omitted, as they are specific to an installed package policy: |
Thanks for the detailed explanation, @criamico - the results look great to me. 🎉 |
Thanks for taking care of it, @criamico ! |
Fixes #180307 Fix the response format of `api/fleet/epm/templates/${testPkgName}/${testPkgVersion}/inputs` ## Summary The inputs streams returned in the configs tab where flattened at the end and this was preventing the final config from working when used on a standalone agent. - Removed the `flatMap` from [here](https://github.com/elastic/kibana/blob/ef5af172336d76cc553ae72cbcf289327c2ea428/x-pack/plugins/fleet/server/services/epm/packages/get_template_inputs.ts#L115) - Did a small refactor where I'm directly importing the merge utility from `package_policies_to_agent_inputs` to reduce duplication, also improved types and naming See [this comment](#180307 (comment)) for the new format ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Fixes elastic#180307 Fix the response format of `api/fleet/epm/templates/${testPkgName}/${testPkgVersion}/inputs` ## Summary The inputs streams returned in the configs tab where flattened at the end and this was preventing the final config from working when used on a standalone agent. - Removed the `flatMap` from [here](https://github.com/elastic/kibana/blob/ef5af172336d76cc553ae72cbcf289327c2ea428/x-pack/plugins/fleet/server/services/epm/packages/get_template_inputs.ts#L115) - Did a small refactor where I'm directly importing the merge utility from `package_policies_to_agent_inputs` to reduce duplication, also improved types and naming See [this comment](elastic#180307 (comment)) for the new format ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit bcb876f)
# Backport This will backport the following commits from `main` to `8.14`: - [[Fleet] Fix flattened inputs in config tab (#181155)](#181155) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Cristina Amico","email":"criamico@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-04-22T13:56:16Z","message":"[Fleet] Fix flattened inputs in config tab (#181155)\n\nFixes #180307 the response format of\r\n`api/fleet/epm/templates/${testPkgName}/${testPkgVersion}/inputs`\r\n\r\n## Summary\r\nThe inputs streams returned in the configs tab where flattened at the\r\nend and this was preventing the final config from working when used on a\r\nstandalone agent.\r\n- Removed the `flatMap` from\r\n[here](https://github.com/elastic/kibana/blob/ef5af172336d76cc553ae72cbcf289327c2ea428/x-pack/plugins/fleet/server/services/epm/packages/get_template_inputs.ts#L115)\r\n- Did a small refactor where I'm directly importing the merge utility\r\nfrom `package_policies_to_agent_inputs` to reduce duplication, also\r\nimproved types and naming\r\n\r\nSee [this\r\ncomment](#180307 (comment) the new format\r\n\r\n### Checklist\r\n\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"bcb876fbe977860d9d1b2ddfbc916f97735077f4","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Fleet","backport:prev-minor","v8.15.0"],"title":"[Fleet] Fix flattened inputs in config tab","number":181155,"url":"#181155 Fix flattened inputs in config tab (#181155)\n\nFixes #180307 the response format of\r\n`api/fleet/epm/templates/${testPkgName}/${testPkgVersion}/inputs`\r\n\r\n## Summary\r\nThe inputs streams returned in the configs tab where flattened at the\r\nend and this was preventing the final config from working when used on a\r\nstandalone agent.\r\n- Removed the `flatMap` from\r\n[here](https://github.com/elastic/kibana/blob/ef5af172336d76cc553ae72cbcf289327c2ea428/x-pack/plugins/fleet/server/services/epm/packages/get_template_inputs.ts#L115)\r\n- Did a small refactor where I'm directly importing the merge utility\r\nfrom `package_policies_to_agent_inputs` to reduce duplication, also\r\nimproved types and naming\r\n\r\nSee [this\r\ncomment](#180307 (comment) the new format\r\n\r\n### Checklist\r\n\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"bcb876fbe977860d9d1b2ddfbc916f97735077f4"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.15.0","branchLabelMappingKey":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"#181155 Fix flattened inputs in config tab (#181155)\n\nFixes #180307 the response format of\r\n`api/fleet/epm/templates/${testPkgName}/${testPkgVersion}/inputs`\r\n\r\n## Summary\r\nThe inputs streams returned in the configs tab where flattened at the\r\nend and this was preventing the final config from working when used on a\r\nstandalone agent.\r\n- Removed the `flatMap` from\r\n[here](https://github.com/elastic/kibana/blob/ef5af172336d76cc553ae72cbcf289327c2ea428/x-pack/plugins/fleet/server/services/epm/packages/get_template_inputs.ts#L115)\r\n- Did a small refactor where I'm directly importing the merge utility\r\nfrom `package_policies_to_agent_inputs` to reduce duplication, also\r\nimproved types and naming\r\n\r\nSee [this\r\ncomment](#180307 (comment) the new format\r\n\r\n### Checklist\r\n\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"bcb876fbe977860d9d1b2ddfbc916f97735077f4"}}]}] BACKPORT--> Co-authored-by: Cristina Amico <criamico@users.noreply.github.com>
@kpollich @criamico I just realized there is still a problem with the generated config - now it has the streams, but there is no E.g. the example above, it still needs the Is there a way we can test this e2e as it has been proven to be a brittle piece? |
Hi @flash1293, I opened a PR to fix the missing |
No, not really. I think the best thing to do here would probably be a regression test that the QA team can run. @amolnater-qasource what do you think of this as a test case?
@criamico @flash1293 - Does that match how we've been testing this feature manually? It could be interesting to create an E2E test that calls this Fleet API to retrieve the inputs config and tests that a standalone agent ships data as expected with that config, but I think we'd need some help from the agent team to put that together. Elastic Agent has an E2E test suite that runs a live Kibana server we could use for this purpose. @cmacknz do you think it make sense to test this Kibana API in that test suite? The UI & Integrations team could contribute the test if you think it's sensible. |
That test framework could do that, but it'd be running on a schedule or triggered based on changes to agent itself which would make correlating back to problems in Kibana difficult. The agent test framework was developed to test agent, that is it installs the agent directly in isolated VMs across many different OS flavours. That is a bit heavyweight for what should be needed here. Is it feasible to have an agent+fleet server Docker containers in Kibana CI (basically just the agent parts of the elastic-package tooling stack)? That seems like a much nicer way to deal with this, unless there are specific platform dependencies you need to test (Windows for example). |
This might be a possibility - on its face it doesn't seem overly concerning to me, at least. We'd probably want to talk with Kibana CI about it to confirm. We definitely don't need cross-platform testing here, as this is mainly just to test the Fleet config API to confirm it returns usable configuration for standalone agent. |
Related to #180307 ## Summary In #181155 the inputs config for integrations was fixed but there was still a missing field `type` on the top level of the input. This PR adds that field: ![Screenshot 2024-04-29 at 19 09 59](https://github.com/elastic/kibana/assets/16084106/ff0ce78b-8726-416f-ad7a-8f039dd4e10a) ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Related to elastic#180307 ## Summary In elastic#181155 the inputs config for integrations was fixed but there was still a missing field `type` on the top level of the input. This PR adds that field: ![Screenshot 2024-04-29 at 19 09 59](https://github.com/elastic/kibana/assets/16084106/ff0ce78b-8726-416f-ad7a-8f039dd4e10a) ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 13e5965)
…182328) # Backport This will backport the following commits from `main` to `8.14`: - [[Fleet] Add missing field type in input templates (#182016)](#182016) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Cristina Amico","email":"criamico@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-05-02T07:54:05Z","message":"[Fleet] Add missing field type in input templates (#182016)\n\nRelated to #180307 Summary\r\nIn #181155 the inputs config for\r\nintegrations was fixed but there was still a missing field `type` on the\r\ntop level of the input. This PR adds that field:\r\n\r\n![Screenshot 2024-04-29 at 19 09\r\n59](https://github.com/elastic/kibana/assets/16084106/ff0ce78b-8726-416f-ad7a-8f039dd4e10a)\r\n\r\n\r\n### Checklist\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"13e59658b5edeed4f2bd2ed7ee0dee829128a0da","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:prev-minor","v8.15.0"],"title":"[Fleet] Add missing field type in input templates","number":182016,"url":"#182016 Add missing field type in input templates (#182016)\n\nRelated to #180307 Summary\r\nIn #181155 the inputs config for\r\nintegrations was fixed but there was still a missing field `type` on the\r\ntop level of the input. This PR adds that field:\r\n\r\n![Screenshot 2024-04-29 at 19 09\r\n59](https://github.com/elastic/kibana/assets/16084106/ff0ce78b-8726-416f-ad7a-8f039dd4e10a)\r\n\r\n\r\n### Checklist\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"13e59658b5edeed4f2bd2ed7ee0dee829128a0da"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.15.0","branchLabelMappingKey":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"#182016 Add missing field type in input templates (#182016)\n\nRelated to #180307 Summary\r\nIn #181155 the inputs config for\r\nintegrations was fixed but there was still a missing field `type` on the\r\ntop level of the input. This PR adds that field:\r\n\r\n![Screenshot 2024-04-29 at 19 09\r\n59](https://github.com/elastic/kibana/assets/16084106/ff0ce78b-8726-416f-ad7a-8f039dd4e10a)\r\n\r\n\r\n### Checklist\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"13e59658b5edeed4f2bd2ed7ee0dee829128a0da"}}]}] BACKPORT--> Co-authored-by: Cristina Amico <criamico@users.noreply.github.com>
Closing. I'll create a follow up issue to discuss E2E testing for this separately. |
I created an issue to explore E2E testing in the future here. #182507 FYI I designated it as a spacetime project as I think there will be a lot of investigation required to get an Elastic Agent container spun up inside of Kibana CI. |
Related to elastic#180307 ## Summary In elastic#181155 the inputs config for integrations was fixed but there was still a missing field `type` on the top level of the input. This PR adds that field: ![Screenshot 2024-04-29 at 19 09 59](https://github.com/elastic/kibana/assets/16084106/ff0ce78b-8726-416f-ad7a-8f039dd4e10a) ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Kibana version: main
When navigating to the "Configs" tab in the UI, the config should represent the default config and work mostly out of the box when copy/pasted into an
elastic-agent.yml
.However, the "Configs" tab is showing only a flat list of inputs without nested datastreams, e.g. for nginx:
When creating an agent policy for nginx, then selecting the standalone tab in the flyout, it shows the following structure instead:
When using the flat config from the "Configs" tab, the agent doesn't ship any data while the nested config specifying
streams
works just fine.The text was updated successfully, but these errors were encountered: