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
[Synthetics] Allow Synthetics global params to include dashes #178054
[Synthetics] Allow Synthetics global params to include dashes #178054
Conversation
Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services) |
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
/oblt-deploy |
@@ -51,7 +51,7 @@ export const replaceStringWithParams = ( | |||
}; | |||
|
|||
export const hasNoParams = (strVal: string) => { | |||
const shellParamsRegex = /\$\{[a-zA-Z_][a-zA-Z0-9_]*\}/g; | |||
const shellParamsRegex = /\$\{[a-zA-Z_][a-zA-Z0-9_-]*\}/g; |
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.
nit: why not keep it simple as \w+|[-_]
?
Are we missing any other substution other than _ and - for parameters. Are dots used in beats config? There seems to be :, .
used as well - https://www.elastic.co/guide/en/beats/libbeat/current/config-gile-format-refs.html
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.
@vigneshshanmugam looking at the docs it appears that ?
is also possible.
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.
@vigneshshanmugam the :
case is already covered by what we have today, you can see a a unit test to this effect in the same file.
Regarding the ?
, it pertains to giving a custom error message for beats to output. I don't know if this is a feature we support or not, but doesn't seem super important here.
\w+|[-_]
is not a drop-in fix, several of our covered usages fail whereas what I already added works for all of them. Frankly, I do not enjoy fiddling with regex so I am inclined to keep it as it is, to my eye it doesn't really reduce the overall complexity of the code much. I'm happy to put in something cleaner if all the tests keep passing though 😃.
I did add a \.
to the character class to indicate the intention that we will support the .
character per the case you linked above; I also included a new unit test. LMK if you have any further thoughts, thanks for the feedback 👍.
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.
case is already covered by what we have today,
That is for substituion I beleieve, what if we set the key to test:param
in the global params? If it works all good.
I am not sure if params would end up including any characters other than - and _
. Just wanted to call out. I am fine with either way. Thanks for taking a look.
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.
That is for substituion I beleieve, what if we set the key to test:param in the global params?
I'll investigate this a bit more 👍. Although, if you choose that as your param name.. I also feel like that is a bad naming strategy.
57837c3
to
a78a8a5
Compare
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.
LGTM
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.
LGTM
...s/observability_solution/synthetics/server/synthetics_service/formatters/formatting_utils.ts
Outdated
Show resolved
Hide resolved
a78a8a5
to
2a02e32
Compare
@@ -50,9 +50,10 @@ export const replaceStringWithParams = ( | |||
return value as string | null; | |||
}; | |||
|
|||
export const SHELL_PARAMS_REGEX = /\$\{[a-zA-Z_][a-zA-Z0-9\._\-?:]*\}/g; |
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.
Why did you export it?
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.
In the moment thinking of unit testing use case where someone writing a test would want to import it.. but now that I'm typing it I agree it's not needed, as it's encapsulated in the function.
2a02e32
to
8992a7a
Compare
8992a7a
to
ac0f551
Compare
💚 Build Succeeded
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
…c#178054) ## Summary Resolves elastic#178053. Includes `-` in the regex to filter param names. ## Testing ### Repro instructions Testing this is straightforward. You can verify the issue in `main` or on a cloud instance. If you spin up an ESS that is the most straightforward way. 1. In Synthetics UI, go to Settings > Global Parameters. <img width="831" alt="image" src="https://github.com/elastic/kibana/assets/18429259/f6dc78f6-6e0c-4b84-a114-9e88266327e9"> 2. Create a param with some dashes in the key, i.e. `TEST-PARAMS`. 3. After saving, create an HTTP monitor. In the create form, you can scroll down and expand `Advanced options`. Include a check for `Request headers`, specify a header name and for the value, reference your global param using [Beats env syntax](https://www.elastic.co/guide/en/beats/libbeat/current/config-file-format-env-vars.html#_examples). <img width="831" alt="image" src="https://github.com/elastic/kibana/assets/18429259/bcf3c495-1db8-499c-a394-781564744679"> You can either use Test Now or wait for it to fail, and you'll see issues get logged similar to what is documented in the attached issue. ### Testing the fix I will create an ESS deployment from this PR that will allow you to follow the same steps above. You should be able to see your monitor either succeed (if the response headers you check for are actually there), or fail for legitimate reasons. But you should not see the error documented in the attached issue, with a message like `io:job could not be initialized...`. (cherry picked from commit d69045b)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…178054) (#178268) # Backport This will backport the following commits from `main` to `8.13`: - [[Synthetics] Allow Synthetics global params to include dashes (#178054)](#178054) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Justin Kambic","email":"jk@elastic.co"},"sourceCommit":{"committedDate":"2024-03-07T23:11:59Z","message":"[Synthetics] Allow Synthetics global params to include dashes (#178054)\n\n## Summary\r\n\r\nResolves #178053.\r\n\r\nIncludes `-` in the regex to filter param names.\r\n\r\n## Testing\r\n\r\n### Repro instructions\r\n\r\nTesting this is straightforward. You can verify the issue in `main` or\r\non a cloud instance. If you spin up an ESS that is the most\r\nstraightforward way.\r\n\r\n1. In Synthetics UI, go to Settings > Global Parameters.\r\n<img width=\"831\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/18429259/f6dc78f6-6e0c-4b84-a114-9e88266327e9\">\r\n\r\n2. Create a param with some dashes in the key, i.e. `TEST-PARAMS`.\r\n\r\n3. After saving, create an HTTP monitor. In the create form, you can\r\nscroll down and expand `Advanced options`. Include a check for `Request\r\nheaders`, specify a header name and for the value, reference your global\r\nparam using [Beats env\r\nsyntax](https://www.elastic.co/guide/en/beats/libbeat/current/config-file-format-env-vars.html#_examples).\r\n<img width=\"831\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/18429259/bcf3c495-1db8-499c-a394-781564744679\">\r\n\r\nYou can either use Test Now or wait for it to fail, and you'll see\r\nissues get logged similar to what is documented in the attached issue.\r\n\r\n### Testing the fix\r\n\r\nI will create an ESS deployment from this PR that will allow you to\r\nfollow the same steps above. You should be able to see your monitor\r\neither succeed (if the response headers you check for are actually\r\nthere), or fail for legitimate reasons. But you should not see the error\r\ndocumented in the attached issue, with a message like `io:job could not\r\nbe initialized...`.","sha":"d69045bd4d1b013cf92daf4992c836ea623a4968","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:obs-ux-infra_services","v8.13.0","v8.14.0"],"title":"[Synthetics] Allow Synthetics global params to include dashes","number":178054,"url":"#178054 Allow Synthetics global params to include dashes (#178054)\n\n## Summary\r\n\r\nResolves #178053.\r\n\r\nIncludes `-` in the regex to filter param names.\r\n\r\n## Testing\r\n\r\n### Repro instructions\r\n\r\nTesting this is straightforward. You can verify the issue in `main` or\r\non a cloud instance. If you spin up an ESS that is the most\r\nstraightforward way.\r\n\r\n1. In Synthetics UI, go to Settings > Global Parameters.\r\n<img width=\"831\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/18429259/f6dc78f6-6e0c-4b84-a114-9e88266327e9\">\r\n\r\n2. Create a param with some dashes in the key, i.e. `TEST-PARAMS`.\r\n\r\n3. After saving, create an HTTP monitor. In the create form, you can\r\nscroll down and expand `Advanced options`. Include a check for `Request\r\nheaders`, specify a header name and for the value, reference your global\r\nparam using [Beats env\r\nsyntax](https://www.elastic.co/guide/en/beats/libbeat/current/config-file-format-env-vars.html#_examples).\r\n<img width=\"831\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/18429259/bcf3c495-1db8-499c-a394-781564744679\">\r\n\r\nYou can either use Test Now or wait for it to fail, and you'll see\r\nissues get logged similar to what is documented in the attached issue.\r\n\r\n### Testing the fix\r\n\r\nI will create an ESS deployment from this PR that will allow you to\r\nfollow the same steps above. You should be able to see your monitor\r\neither succeed (if the response headers you check for are actually\r\nthere), or fail for legitimate reasons. But you should not see the error\r\ndocumented in the attached issue, with a message like `io:job could not\r\nbe initialized...`.","sha":"d69045bd4d1b013cf92daf4992c836ea623a4968"}},"sourceBranch":"main","suggestedTargetBranches":["8.13"],"targetPullRequestStates":[{"branch":"8.13","label":"v8.13.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"#178054 Allow Synthetics global params to include dashes (#178054)\n\n## Summary\r\n\r\nResolves #178053.\r\n\r\nIncludes `-` in the regex to filter param names.\r\n\r\n## Testing\r\n\r\n### Repro instructions\r\n\r\nTesting this is straightforward. You can verify the issue in `main` or\r\non a cloud instance. If you spin up an ESS that is the most\r\nstraightforward way.\r\n\r\n1. In Synthetics UI, go to Settings > Global Parameters.\r\n<img width=\"831\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/18429259/f6dc78f6-6e0c-4b84-a114-9e88266327e9\">\r\n\r\n2. Create a param with some dashes in the key, i.e. `TEST-PARAMS`.\r\n\r\n3. After saving, create an HTTP monitor. In the create form, you can\r\nscroll down and expand `Advanced options`. Include a check for `Request\r\nheaders`, specify a header name and for the value, reference your global\r\nparam using [Beats env\r\nsyntax](https://www.elastic.co/guide/en/beats/libbeat/current/config-file-format-env-vars.html#_examples).\r\n<img width=\"831\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/18429259/bcf3c495-1db8-499c-a394-781564744679\">\r\n\r\nYou can either use Test Now or wait for it to fail, and you'll see\r\nissues get logged similar to what is documented in the attached issue.\r\n\r\n### Testing the fix\r\n\r\nI will create an ESS deployment from this PR that will allow you to\r\nfollow the same steps above. You should be able to see your monitor\r\neither succeed (if the response headers you check for are actually\r\nthere), or fail for legitimate reasons. But you should not see the error\r\ndocumented in the attached issue, with a message like `io:job could not\r\nbe initialized...`.","sha":"d69045bd4d1b013cf92daf4992c836ea623a4968"}}]}] BACKPORT--> Co-authored-by: Justin Kambic <jk@elastic.co>
…c#178054) ## Summary Resolves elastic#178053. Includes `-` in the regex to filter param names. ## Testing ### Repro instructions Testing this is straightforward. You can verify the issue in `main` or on a cloud instance. If you spin up an ESS that is the most straightforward way. 1. In Synthetics UI, go to Settings > Global Parameters. <img width="831" alt="image" src="https://github.com/elastic/kibana/assets/18429259/f6dc78f6-6e0c-4b84-a114-9e88266327e9"> 2. Create a param with some dashes in the key, i.e. `TEST-PARAMS`. 3. After saving, create an HTTP monitor. In the create form, you can scroll down and expand `Advanced options`. Include a check for `Request headers`, specify a header name and for the value, reference your global param using [Beats env syntax](https://www.elastic.co/guide/en/beats/libbeat/current/config-file-format-env-vars.html#_examples). <img width="831" alt="image" src="https://github.com/elastic/kibana/assets/18429259/bcf3c495-1db8-499c-a394-781564744679"> You can either use Test Now or wait for it to fail, and you'll see issues get logged similar to what is documented in the attached issue. ### Testing the fix I will create an ESS deployment from this PR that will allow you to follow the same steps above. You should be able to see your monitor either succeed (if the response headers you check for are actually there), or fail for legitimate reasons. But you should not see the error documented in the attached issue, with a message like `io:job could not be initialized...`.
Summary
Resolves #178053.
Includes
-
in the regex to filter param names.Testing
Repro instructions
Testing this is straightforward. You can verify the issue in
main
or on a cloud instance. If you spin up an ESS that is the most straightforward way.Create a param with some dashes in the key, i.e.
TEST-PARAMS
.After saving, create an HTTP monitor. In the create form, you can scroll down and expand
Advanced options
. Include a check forRequest headers
, specify a header name and for the value, reference your global param using Beats env syntax.You can either use Test Now or wait for it to fail, and you'll see issues get logged similar to what is documented in the attached issue.
Testing the fix
I will create an ESS deployment from this PR that will allow you to follow the same steps above. You should be able to see your monitor either succeed (if the response headers you check for are actually there), or fail for legitimate reasons. But you should not see the error documented in the attached issue, with a message like
io:job could not be initialized...
.