-
Notifications
You must be signed in to change notification settings - Fork 129
[policy tests] Replace also OTEL ids under service.pipelines #2886
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -190,7 +190,14 @@ var uniqueOtelComponentIDReplace = policyEntryReplace{ | |
| // - endpoints: | ||
| // - https://epr.elastic.co | ||
| // method: GET | ||
| var otelComponentIDsRegexp = regexp.MustCompile(`(?m)^(?:extensions|receivers|processors|connectors|exporters):(?:\s\{\}\n|\n(?:\s{2,}.+\n)+)`) | ||
| // service: | ||
| // pipelines: | ||
| // logs: | ||
| // receivers/6b7f1379-dcb9-4ac7-b253-4df6d088b3ff: | ||
| // - httpcheck/b0f518d6-4e2d-4c5d-bda7-f9808df537b7 | ||
| // | ||
| // The regex captures the whole section, so it can be processed line by line to replace the IDs. | ||
| var otelComponentIDsRegexp = regexp.MustCompile(`(?m)^(?:extensions|receivers|processors|connectors|exporters|service):(?:\s\{\}\n|\n(?:\s{2,}.+\n)+)`) | ||
|
|
||
| // cleanPolicy prepares a policy YAML as returned by the download API to be compared with other | ||
| // policies. This preparation is based on removing contents that are generated, or replace them | ||
|
|
@@ -248,10 +255,7 @@ func replaceOtelComponentIDs(policy []byte) []byte { | |
| // service.extensions | ||
| // service.pipelines.<signal>.(receivers|processors|exporters) | ||
| for original, replacement := range replacementsDone { | ||
| originalArrayItem := fmt.Sprintf("- %s", original) | ||
| replacedArrayItem := fmt.Sprintf("- %s", replacement) | ||
|
|
||
| policy = bytes.ReplaceAll(policy, []byte(originalArrayItem), []byte(replacedArrayItem)) | ||
| policy = bytes.ReplaceAll(policy, []byte(original), []byte(replacement)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| } | ||
| return policy | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -312,18 +312,40 @@ processors: | |
| batch/e6e379c5-6446-4090-af10-a9e5f8fc4640: | ||
| send_batch_size: 10000 | ||
| timeout: 10s | ||
| transform/otelcol-check-9987a1b9-3a12-43e8-a0a2-e83fa9deebfd-otelcol-httpcheck-check-9987a1b9-3a12-43e8-a0a2-e83fa9deebfd-routing: | ||
| metric_statements: | ||
| - context: datapoint | ||
| statements: | ||
| - set(attributes["data_stream.type"], "metrics") | ||
| - set(attributes["data_stream.dataset"], "httpcheck.check") | ||
| - set(attributes["data_stream.namespace"], "ep") | ||
| connectors: | ||
| forward: {} | ||
| receivers: | ||
| httpcheck/4bae34b3-8f66-49c1-b04f-d58af1b5f743: | ||
| collection_interval: 1m | ||
| targets: | ||
| - endpoints: | ||
| - https://epr.elastic.co | ||
| method: GET | ||
| httpcheck/otelcol-check-9987a1b9-3a12-43e8-a0a2-e83fa9deebfd-otelcol-httpcheck-check-9987a1b9-3a12-43e8-a0a2-e83fa9deebfd: | ||
| collection_interval: 2m | ||
| targets: | ||
| - endpoints: | ||
| - https://epr.elastic.co | ||
| method: GET | ||
| secret_references: [] | ||
| service: | ||
| extensions: | ||
| - health_check/31c94f44-214a-4778-8a36-acc2634096f7 | ||
| pipelines: | ||
| metrics/otelcol-check-9987a1b9-3a12-43e8-a0a2-e83fa9deebfd-otelcol-httpcheck-check-9987a1b9-3a12-43e8-a0a2-e83fa9deebfd: | ||
| receivers: | ||
| - >- | ||
| httpcheck/otelcol-check-9987a1b9-3a12-43e8-a0a2-e83fa9deebfd-otelcol-httpcheck-check-9987a1b9-3a12-43e8-a0a2-e83fa9deebfd | ||
| processors: | ||
| - >- | ||
| transform/otelcol-check-9987a1b9-3a12-43e8-a0a2-e83fa9deebfd-otelcol-httpcheck-check-9987a1b9-3a12-43e8-a0a2-e83fa9deebfd-routing | ||
| logs: | ||
| receivers: | ||
| - httpcheck/4bae34b3-8f66-49c1-b04f-d58af1b5f743 | ||
|
|
@@ -357,18 +379,40 @@ processors: | |
| batch/8ec6ee99-2176-4231-9668-908069c77784: | ||
| send_batch_size: 10000 | ||
| timeout: 10s | ||
| transform/otelcol-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77-otelcol-httpcheck-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77-routing: | ||
| metric_statements: | ||
| - context: datapoint | ||
| statements: | ||
| - set(attributes["data_stream.type"], "metrics") | ||
| - set(attributes["data_stream.dataset"], "httpcheck.check") | ||
| - set(attributes["data_stream.namespace"], "ep") | ||
| connectors: | ||
| forward: {} | ||
| receivers: | ||
| httpcheck/b0f518d6-4e2d-4c5d-bda7-f9808df537b7: | ||
| collection_interval: 1m | ||
| targets: | ||
| - endpoints: | ||
| - https://epr.elastic.co | ||
| method: GET | ||
| httpcheck/otelcol-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77-otelcol-httpcheck-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77: | ||
| collection_interval: 2m | ||
| targets: | ||
| - endpoints: | ||
| - https://epr.elastic.co | ||
| method: GET | ||
| secret_references: [] | ||
| service: | ||
| extensions: | ||
| - health_check/4391d954-1ffe-4014-a256-5eda78a71829 | ||
| pipelines: | ||
| metrics/otelcol-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77-otelcol-httpcheck-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77: | ||
| receivers: | ||
| - >- | ||
| httpcheck/otelcol-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77-otelcol-httpcheck-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77 | ||
| processors: | ||
| - >- | ||
| transform/otelcol-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77-otelcol-httpcheck-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77-routing | ||
| logs: | ||
| receivers: | ||
| - httpcheck/b0f518d6-4e2d-4c5d-bda7-f9808df537b7 | ||
|
|
@@ -406,18 +450,40 @@ processors: | |
| batch/componentid-1: | ||
| send_batch_size: 10000 | ||
| timeout: 10s | ||
| transform/componentid-2: | ||
| metric_statements: | ||
| - context: datapoint | ||
| statements: | ||
| - set(attributes["data_stream.type"], "metrics") | ||
| - set(attributes["data_stream.dataset"], "httpcheck.check") | ||
| - set(attributes["data_stream.namespace"], "ep") | ||
| connectors: | ||
| forward: {} | ||
| receivers: | ||
| httpcheck/componentid-0: | ||
| collection_interval: 1m | ||
| targets: | ||
| - endpoints: | ||
| - https://epr.elastic.co | ||
| method: GET | ||
| httpcheck/componentid-1: | ||
| collection_interval: 2m | ||
| targets: | ||
| - endpoints: | ||
| - https://epr.elastic.co | ||
| method: GET | ||
| secret_references: [] | ||
| service: | ||
| extensions: | ||
| - health_check/componentid-0 | ||
| pipelines: | ||
| metrics/componentid-0: | ||
| receivers: | ||
| - >- | ||
| httpcheck/componentid-1 | ||
| processors: | ||
| - >- | ||
| transform/componentid-2 | ||
| logs: | ||
| receivers: | ||
| - httpcheck/componentid-0 | ||
|
|
@@ -451,18 +517,40 @@ processors: | |
| batch/8ec6ee99-2176-4231-9668-908069c77784: | ||
| send_batch_size: 10000 | ||
| timeout: 10s | ||
| transform/otelcol-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77-otelcol-httpcheck-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77-routing: | ||
| metric_statements: | ||
| - context: datapoint | ||
| statements: | ||
| - set(attributes["data_stream.type"], "metrics") | ||
| - set(attributes["data_stream.dataset"], "httpcheck.check") | ||
| - set(attributes["data_stream.namespace"], "ep") | ||
| connectors: | ||
| forward: {} | ||
| receivers: | ||
| httpcheck/b0f518d6-4e2d-4c5d-bda7-f9808df537b7: | ||
| collection_interval: 1m | ||
| targets: | ||
| - endpoints: | ||
| - https://epr.elastic.co | ||
| method: GET | ||
| httpcheck/otelcol-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77-otelcol-httpcheck-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77: | ||
| collection_interval: 2m | ||
| targets: | ||
| - endpoints: | ||
| - https://epr.elastic.co | ||
| method: GET | ||
| secret_references: [] | ||
| service: | ||
| extensions: | ||
| - health_check/4391d954-1ffe-4014-a256-5eda78a71828 | ||
| pipelines: | ||
| metrics/otelcol-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77-otelcol-httpcheck-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added example with a service pipeline containing a suffix in order to be able to define several pipelines of the same signal. |
||
| receivers: | ||
| - >- | ||
| httpcheck/otelcol-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77-otelcol-httpcheck-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77 | ||
|
Comment on lines
+549
to
+550
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added example with the syntax |
||
| processors: | ||
| - >- | ||
| transform/otelcol-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77-otelcol-httpcheck-check-12bd7179-ea83-494b-9f2c-5bf818cd6a77-routing | ||
| logs: | ||
| receivers: | ||
| - httpcheck/b0f518d6-4e2d-4c5d-bda7-f9808df537b7 | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once these PRs are merged:
Testing with the current changes of those branches, this file should be like (it could change): connectors:
forward: {}
exporters:
elasticsearch/componentid-0:
endpoints:
- http://localhost:9200
inputs: []
output_permissions:
default:
_elastic_agent_checks:
cluster:
- monitor
_elastic_agent_monitoring:
indices: []
uuid-for-permissions-on-related-indices:
indices:
- names:
- metrics-*-*
privileges:
- auto_configure
- create_doc
processors:
transform/componentid-0:
metric_statements:
- context: datapoint
statements:
- set(attributes["data_stream.type"], "metrics")
- set(attributes["data_stream.dataset"], "httpcheck.check")
- set(attributes["data_stream.namespace"], "ep")
receivers:
httpcheck/componentid-0:
collection_interval: 1m
targets:
- endpoints:
- https://epr.elastic.co
method: GET
secret_references: []
service:
pipelines:
metrics:
exporters:
- elasticsearch/componentid-0
receivers:
- forward
metrics/componentid-0:
exporters:
- forward
processors:
- transform/componentid-0
receivers:
- httpcheck/componentid-0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Included the
servicemap into this regex in order to take into account these kind of definitions too to find pipelines IDs like (metrics/<some_id>):