[Ingest] Use agent.yml template when creating a datasource stream from a package#62631
Conversation
|
Pinging @elastic/ingest-management (Team:Ingest Management) |
cfca8e1 to
fdf8741
Compare
fdf8741 to
8a3d9b1
Compare
|
@paul-tavares this is changing a little the comportment of the create Datasource endpoint if you are using a package, maybe worth to check it |
jfsiii
left a comment
There was a problem hiding this comment.
On my phone, so I didn't get to run this. My main request is to avoid using Registry types/fetchers and only use EPM ones. Registry types are a last resort. Ideally they are never used outside EPM.
x-pack/plugins/ingest_manager/server/routes/datasource/handlers.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/ingest_manager/server/routes/datasource/handlers.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/ingest_manager/server/services/datasource.test.ts
Outdated
Show resolved
Hide resolved
| packageInfo, | ||
| config.id, | ||
| defaultOutput.id, | ||
| undefined, |
There was a problem hiding this comment.
Can we update this signature to an object? Five parameters is a lot. Especially if some are optional.
There was a problem hiding this comment.
I did not modify this function here, just some prettier, and if you are good with I found this PR already containing a lot of change and keep it for another PR.
x-pack/plugins/ingest_manager/server/services/epm/packages/assets.ts
Outdated
Show resolved
Hide resolved
…gentyml-template-for-stream
|
Thanks @nchaulet for pinging me. I think we're ok. We are only currently using the |
|
@paul-tavares yes this change is only concerning |
jen-huang
left a comment
There was a problem hiding this comment.
the yaml view when you create a datasource is not accurate anymore but it's going to be removed
Will the agent config YAML tab be accurate?
x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.ts
Outdated
Show resolved
Hide resolved
@jen-huang Yes it will contains the same thing that is returned to the agent |
…gentyml-template-for-stream
There was a problem hiding this comment.
References to pkg_stream and "package stream" confuses me as it's not clear that these are config values coming from the stream template. What do you think of renaming to template_config (and referring to them as template config or template vars)?
I also tested a nginx metrics case and the results were not what I expected. My data source configuration:
Resulting YAML:
Based on the template definition here:
https://epr-staging.elastic.co/package/nginx/1.2.0/dataset/stubstatus/agent/stream/stream.yml
I would expect:
hosts,username, andpasswordto appear at the stream level, not the input level
@ruflin Based on some discussion a while ago, before we consumed the templates, we decided that input-level vars would not get copied into each stream inside it (work done in #60594). This nginx metrics stream template conflicts with that decision as it expects vars from the input level.
@ph Maybe you can help weigh in on this from the agent side. For nginx datasource that only collects metrics, would you expect the agent config to look like this:
id: nginx-1
namespace: default
enabled: true
use_output: default
package:
name: nginx
version: 1.2.0
inputs:
- type: nginx/metrics
enabled: true
hosts:
- jen-test
- jen-test2
username: test-username
password: test-password
streams:
- id: nginx/metrics-nginx.stubstatus
enabled: true
dataset: nginx.stubstatus
period: 365d
or like this?:
id: nginx-1
namespace: default
enabled: true
use_output: default
package:
name: nginx
version: 1.2.0
inputs:
- type: nginx/metrics
enabled: true
streams:
- id: nginx/metrics-nginx.stubstatus
enabled: true
dataset: nginx.stubstatus
period: 365d
hosts:
- jen-test
- jen-test2
username: test-username
password: test-password
|
@jen-huang good catch I am currently not using the input level variable to populate the stream template. In my opinion the generated config should be the second one, but that means we remove config from the input too, and only rely on the template to send data. |
|
@jen-huang I understand the confusion, but the way @ruflin and I were thinking about key inheritance was that keys defined in the input would be applied to all the streams node. The driving force behind that opinion was linked to the standalone agent mode to reduce the number of fields a user needs to configure when configuring a data source and reduce duplication of fields/source of errors. But, I think I should describe what are the rules in the agent in that context.
But because of the above rules, this actually means that the agent would support both configurations you are describing. (@michalpristas this is correct right?). I would prefer if we have a single way to define it, where values are defined at the input level, so its consistent with the user. But maybe the later is easier for code generation. |
|
@jen-huang I understand the confusion here but I think what @ph describes is correct. Even though we define it on the input level in the end, the config we create is all on the stream level and very verbose as it is easiest to generate. Also not sure how otherwise we could have single stream template. |
|
Updated my PR to use agent config variable when building the agent stream from template it's generate this input for nginx (disabling log error as the template is currently broken) - id: nginx-1
package:
name: nginx
version: 1.2.0
namespace: default
enabled: true
use_output: default
inputs:
- type: nginx/metrics
enabled: true
streams:
- enabled: true
dataset: nginx.stubstatus
input: nginx/metrics
metricsets:
- stubstatus
period: 10s
hosts:
- 'http://127.0.0.1'
username: nicolas
password: mypassword
id: nginx/metrics-nginx.stubstatus
- type: logs
enabled: true
streams:
- enabled: true
dataset: nginx.access
input: log
paths:
- /var/log/nginx/access.log*
exclude_files:
- .gz$
processors:
- add_locale: null
id: logs-nginx.access
|
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
|
I pulled this down and looked at it in the UI. LGTM so far. One thing I stumbled over is: But in the stream.yml it is actually @ph I wonder if |
|
Yes |
jfsiii
left a comment
There was a problem hiding this comment.
Thanks for making the registry-related changes I mentioned. LGTM but I realize you're iterating with other people.
| pkgVersion: pkg.version, | ||
| }, | ||
| inputs | ||
| )) as TypeOf<typeof CreateDatasourceRequestSchema.body>['inputs']; |
There was a problem hiding this comment.
I'd like to avoid the as entirely, but if it's required can we use the TS type (which does the TypeOf<typeof) instead of the kbn-config schema?
Happy for this to happen in a follow up PR.
Edit: oh this is an input, so perhaps we don't have a type?


Description
Resolves #62330
We were not using the yaml template (
agent/stream.yml) from the package manager to create datasource stream from a package.I fixed that by using the template in the POST and PUT datasources API.
Change
pkg_streamthat contains variable from the package.pkg_stream