2024-02-15 22:47:56 +00:00
|
|
|
{{define "settings"}}
|
2024-02-23 11:18:02 +00:00
|
|
|
<section class="p-5">
|
|
|
|
<form action="/settings/healthchecks/create" method="post">
|
|
|
|
<label for="name">Name</label>
|
|
|
|
<input type="name" name="name" id="name" placeholder="Github.com">
|
|
|
|
<p> Name of the healthcheck can be anything.</p>
|
|
|
|
<label for="workergroups">Worker Groups</label>
|
|
|
|
<input type="text" name="workergroups" id="workergroups" placeholder="NA EU"/>
|
|
|
|
<p> Worker groups are used to distribute the healthcheck to specific workers.</p>
|
|
|
|
<label for="schedule">Schedule</label>
|
|
|
|
<input type="text" name="schedule" id="schedule" placeholder="* * * * *"/>
|
|
|
|
<p> Schedule is a cron expression that defines when the healthcheck should be executed.</p>
|
|
|
|
<label for="script">Script</label>
|
|
|
|
<input required type="hidden" id="script" name="script">
|
|
|
|
<div id="editor" class="block w-full h-96 rounded-lg border border-gray-300 overflow-hidden"></div>
|
|
|
|
<p>
|
|
|
|
Script is what determines the status of a service.
|
2024-02-23 13:56:00 +00:00
|
|
|
You can read more about it on <a target="_blank" href="https://k6.io/docs/using-k6/http-requests/">k6 documentation</a>.
|
2024-02-23 11:18:02 +00:00
|
|
|
</p>
|
2024-02-23 13:42:24 +00:00
|
|
|
<button type="submit" onclick="save()">Create</button>
|
2024-02-21 22:15:21 +00:00
|
|
|
</form>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
<script src="/static/monaco/vs/loader.js"></script>
|
|
|
|
<script>
|
|
|
|
function save() {
|
|
|
|
const script = window.editor.getValue();
|
|
|
|
document.getElementById('script').value = script;
|
|
|
|
}
|
|
|
|
|
|
|
|
script = `import http from 'k6/http';
|
2024-02-21 09:06:54 +00:00
|
|
|
|
|
|
|
export const options = {
|
2024-02-21 22:15:21 +00:00
|
|
|
thresholds: {
|
|
|
|
// http errors should be less than 1%
|
|
|
|
http_req_failed: ['rate<0.01'],
|
2024-02-22 19:20:34 +00:00
|
|
|
},
|
2024-02-21 22:15:21 +00:00
|
|
|
vus: 10,
|
|
|
|
duration: '5s',
|
2024-02-21 09:06:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function () {
|
2024-02-21 22:15:21 +00:00
|
|
|
http.get('https://example.com');
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
require.config({ paths: { vs: '/static/monaco/vs' } });
|
|
|
|
require(['vs/editor/editor.main'], function () {
|
|
|
|
window.editor = monaco.editor.create(document.getElementById('editor'), {
|
|
|
|
value: script,
|
|
|
|
language: 'javascript',
|
|
|
|
minimap: { enabled: false },
|
2024-02-22 16:29:17 +00:00
|
|
|
codeLens: false,
|
|
|
|
contextmenu: false,
|
2024-02-21 22:15:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const divElem = document.getElementById('editor');
|
|
|
|
const resizeObserver = new ResizeObserver(entries => {
|
|
|
|
window.editor.layout();
|
|
|
|
});
|
|
|
|
resizeObserver.observe(divElem);
|
|
|
|
});
|
|
|
|
</script>
|
2024-02-15 22:47:56 +00:00
|
|
|
{{end}}
|