2024-02-29 11:15:15 +00:00
|
|
|
{{ define "settings" }}
|
|
|
|
<section class="p-5">
|
|
|
|
<form action="/settings/monitors/create" method="post">
|
|
|
|
<label for="name">Name</label>
|
|
|
|
<input type="name" name="name" id="name" placeholder="Github.com" />
|
|
|
|
<p>Name of the monitor 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 monitor to specific workers.
|
|
|
|
</p>
|
|
|
|
<label for="schedule">Schedule</label>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
name="schedule"
|
|
|
|
id="schedule"
|
|
|
|
placeholder="@every 1m"
|
|
|
|
value="@every 1m"
|
|
|
|
/>
|
|
|
|
<p>
|
|
|
|
Schedule is a cron expression that defines when the monitor should be
|
|
|
|
executed.
|
|
|
|
<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>
|
|
|
|
<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. You can read more
|
|
|
|
about it on
|
|
|
|
<a target="_blank" href="https://k6.io/docs/using-k6/http-requests/"
|
|
|
|
>k6 documentation</a
|
|
|
|
>.
|
|
|
|
</p>
|
|
|
|
<button type="submit" onclick="save()">Create</button>
|
|
|
|
</form>
|
|
|
|
</section>
|
2024-02-21 22:15:21 +00:00
|
|
|
|
2024-02-29 11:15:15 +00:00
|
|
|
<script src="/static/monaco/vs/loader.js"></script>
|
|
|
|
<script>
|
|
|
|
function save() {
|
|
|
|
const script = window.editor.getValue();
|
|
|
|
document.getElementById("script").value = script;
|
|
|
|
}
|
2024-02-21 22:15:21 +00:00
|
|
|
|
2024-02-29 11:15:15 +00:00
|
|
|
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 09:06:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function () {
|
2024-02-21 22:15:21 +00:00
|
|
|
http.get('https://example.com');
|
|
|
|
}
|
2024-02-29 11:15:15 +00:00
|
|
|
`;
|
2024-02-21 22:15:21 +00:00
|
|
|
|
2024-02-29 11:15:15 +00:00
|
|
|
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 },
|
|
|
|
codeLens: false,
|
|
|
|
contextmenu: false,
|
|
|
|
});
|
2024-02-21 22:15:21 +00:00
|
|
|
|
2024-02-29 11:15:15 +00:00
|
|
|
const divElem = document.getElementById("editor");
|
|
|
|
const resizeObserver = new ResizeObserver((entries) => {
|
2024-02-21 22:15:21 +00:00
|
|
|
window.editor.layout();
|
2024-02-29 11:15:15 +00:00
|
|
|
});
|
|
|
|
resizeObserver.observe(divElem);
|
2024-02-21 22:15:21 +00:00
|
|
|
});
|
2024-02-29 11:15:15 +00:00
|
|
|
</script>
|
|
|
|
{{ end }}
|