-
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] Increase project API payload limit #142140
Conversation
c10c008
to
1b9b2a2
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.
Tested the PR by pushing browser monitors with various payloads. Kibana server did error out when payload exceeded the limit. However, on my machine, Kibana server times out when payload is closer to (but less than) 20 MB.
Based on the above results, it LGTM.
How did I test
Since @elastic/synthetics
also restricts pushing a monitor with > 800KB bundle size (per monitor), I changed the limit to 20 MB when testing a single monitor and 10MB when testing two monitors. I changed here.
I used the following node script to generate a random string payload in MBs
// helpers/generate-payload.js
const fs = require('fs');
const path = require('path');
const size = Number(process.argv[2]);
if(isNaN(size) || size <= 0) {
console.error(`Error: Provide a valid size in MBs e.g. \`node ../generate-payload.js 20\` for 20 MB payload.`);
}
const payload = genPayload(size * 1024 * 1024);
const exportScript = `export const payload = '${payload}';`;
const outputPath = path.resolve(__dirname, `./payload-${size}MB.ts`);
fs.writeFileSync(outputPath, exportScript, { flag: 'w+' });
console.info(`Successfully written payload of ${size}MB to ${outputPath}`);
function genPayload(length) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength = characters.length;
let result = '';
for ( let i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
e.g. Usage
$node <dir-path>/synthetics/examples/push-project-07/helpers/generate-payload.js 9
# Successfully written payload of 9MB to <dir-path>/synthetics/examples/push-project-07/helpers/payload-9MB.ts
The monitor script
// journeys/payload-01.journey.ts
import { journey, step, monitor, expect } from '@elastic/synthetics';
import { payload } from '../helpers/payload-9MB';
journey('Payload Test 01', ({ page, params }) => {
// Only relevant for the push command to create
// monitors in Kibana
monitor.use({
id: 'payload-test-001',
schedule: 10,
});
step('Goto Amazon', async () => {
await page.goto(params.url);
});
step('Search', async () => {
await page.locator('#twotabsearchtextbox').type(payload);
});
});
Pinging @elastic/uptime (Team:uptime) |
@@ -13,6 +13,8 @@ import { API_URLS } from '../../../common/constants'; | |||
import { getAllLocations } from '../../synthetics_service/get_all_locations'; | |||
import { ProjectMonitorFormatter } from '../../synthetics_service/project_monitor/project_monitor_formatter'; | |||
|
|||
const MAX_PAYLOAD_SIZE = 1048576 * 20; // 20MB |
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: this is MiB not MB
x-pack/plugins/synthetics/server/routes/monitor_cruds/add_monitor_project.ts
Outdated
Show resolved
Hide resolved
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.
Did not test locally, code changes make sense. Thanks @shahzad31 !
@@ -20,6 +20,7 @@ import { | |||
} from '@kbn/core/server'; | |||
import { schema } from '@kbn/config-schema'; | |||
import { map$ } from '@kbn/std'; | |||
import { RouteConfigOptions } from '@kbn/core-http-server'; |
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+question: looks like we can combine this type import with @kbn/core/server
?
not actually sure which to use now that there are two sources from which the same types can be imported, I guess we should trend toward using the types from the package @kbn/core-http-server
?
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 will leave it up to the experts on this :)
I guess once everything migrates to packages, this will be auto resolved?
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
History
To update your PR or re-run it, just comment with: cc @shahzad31 |
(cherry picked from commit 6824718)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
(cherry picked from commit 6824718) Co-authored-by: Shahzad <[email protected]>
Summary
Increase synthetics monitors project push API payload limit to 20MB !!