I'm doing Grafana Loki HTTP API queries, specifically query_range
ones which produce stream responses. The parameters listed for such queries are:
query
limit
start
end
since
direction
I've got 5 of the 6 working:
const url = new URL('http://localhost:3100/loki/api/v1/query_range');
/* query */
url.searchParams.set('query', '{job="bob_job", branch="master"}');
/* limit */
url.searchParams.set('limit', '500');
/* start */
let start = new Date();
start.setHours(start.getHours() - 4);
url.searchParams.set('start', start.toISOString());
/* end */
let end = new Date();
end.setHours(end.getHours() - 2);
url.searchParams.set('end', end.toISOString());
/* since */
// url.searchParams.set('since', '5m');
/* direction */
url.searchParams.set('direction', 'forward');
console.log(url.toString());
fetch(url.toString(), {
method: 'POST',
})
.then((response) => response.json())
.then((obj) => {
console.log(obj);
})
.catch(console.error);
But since
doesn't work. (Even if I comment out start
and end
.) I add it, and there's no error message. There's just no effect.
Moreover, I'm hard-pressed to find examples of other people's queries using the since
parameter. What's up with it?