zdravko/web/templates/pages/settings_monitors_create.tmpl

69 lines
2.3 KiB
Cheetah
Raw Normal View History

{{define "settings"}}
2024-02-23 11:18:02 +00:00
<section class="p-5">
<form action="/settings/monitors/create" method="post">
2024-02-23 11:18:02 +00:00
<label for="name">Name</label>
<input type="name" name="name" id="name" placeholder="Github.com">
<p>Name of the monitor can be anything.</p>
2024-02-23 11:18:02 +00:00
<label for="workergroups">Worker Groups</label>
<input type="text" name="workergroups" id="workergroups" placeholder="NA EU"/>
<p>Worker groups are used to distribute the monitor to specific workers.</p>
2024-02-23 11:18:02 +00:00
<label for="schedule">Schedule</label>
<input type="text" name="schedule" id="schedule" placeholder="@every 1m" value="@every 1m"/>
2024-02-23 14:16:51 +00:00
<p>
Schedule is a cron expression that defines when the monitor should be executed.
2024-02-23 14:16:51 +00:00
</br>
You can also use <code>@every [interval]</code> where interval is a duration like 5m, 1h, 60s.
Or use <code>@hourly</code>, <code>@daily</code>, <code>@weekly</code>, <code>@monthly</code>, <code>@yearly</code>.
</p>
2024-02-23 11:18:02 +00:00
<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>
<button type="submit" onclick="save()">Create</button>
</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';
export const options = {
thresholds: {
// http errors should be less than 1%
http_req_failed: ['rate<0.01'],
2024-02-22 19:20:34 +00:00
},
};
export default function () {
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,
});
const divElem = document.getElementById('editor');
const resizeObserver = new ResizeObserver(entries => {
window.editor.layout();
});
resizeObserver.observe(divElem);
});
</script>
{{end}}