-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Add lightweight params support #148634
Conversation
fc8419b
to
ab7b42d
Compare
x-pack/plugins/synthetics/common/formatters/formatting_utils.ts
Outdated
Show resolved
Hide resolved
Pinging @elastic/uptime (Team:uptime) |
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.
My first basic test didn't seem to work for me.
I tried created an UI HTTP monitor.
I started out with setting the url to ${url:https://google.com}
, before setting any params.
This worked as expected, as it fell back to https://google.com
.
However, after adding a url
param, the monitor did not update to use the param.
Upon further inspection, I noticed that the url param did not seem to be added at all. I removed the default and just used ${url}. When inspecting the config sent to the service, I noticed that the url is empty.
As a side note, we may want to prevent monitors before being saved with a configuration that results in an empty string for required values, such as url, hosts, and name for http, tcp, and icmp monitors. Otherwise, it could cause issues on the service side.
You can see my monitor config here.
… lightweight-params
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.
It is being addressed in this PR. |
x-pack/plugins/synthetics/common/formatters/lightweight_param_formatter.ts
Outdated
Show resolved
Hide resolved
}); | ||
it('plain string', () => { | ||
const expected: ParsedVars = [{ content: 'string', type: 'nonvar' }]; | ||
const formatter = variableParser.parse('string', params); |
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.
I don't understand why params
is being passed to variableParser.parse
.
I took a look at the defining for that function, it seems it takes input
and an options
object, but options doesn't seem to have anything to do with params.
Can you explain this for me?
I see params being used down below in replaceVarsWithParams(formatter, params)
which makes perfect sense to me.
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.
this was just a leftover. i will clean it
|
||
return replaceVarsWithParams(parsedVars, params); | ||
} catch (e) { | ||
logger?.info(`error parsing vars for value ${JSON.stringify(value)}`); |
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.
I think this should maybe be logger?.warn
and also I wonder if we want to log the actual error too. Since I ran into issues with my params, that would be helpful.
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.
When creating UI or project monitors in a non-default space, the "All spaces" params do not work. All spaces params do appear to work in the default space.
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. The issue with all the non-default space is being handled in a separate PR.
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
Summary
Fixes #147467
Users will be able to specify params in following format in project monitors or UI