Get all possible filters from backend
This commit is contained in:
@@ -32,6 +32,12 @@ async function run() {
|
||||
changeStream = collection.watch(pipeline, options);
|
||||
console.log("Started watching changes in database");
|
||||
|
||||
const filterOptions = {
|
||||
'kubernetes.namespace': await collection.distinct('kubernetes.namespace'),
|
||||
'kubernetes.pod.name': await collection.distinct('kubernetes.pod.name'),
|
||||
'kubernetes.container.name': await collection.distinct('kubernetes.container.name')
|
||||
}
|
||||
|
||||
const writeMessage = (response, blob) => {
|
||||
const id = blob._id || null
|
||||
const message = `id: ${id}\nevent: message\ndata: ${JSON.stringify(blob)}\n\n`
|
||||
@@ -45,6 +51,9 @@ async function run() {
|
||||
const header = { 'Content-Type': 'text/event-stream', 'Connection': 'keep-alive' };
|
||||
response.writeHead(200, "OK", header);
|
||||
|
||||
const message = `id: 1\nevent: filters\ndata: ${JSON.stringify(filterOptions)}\n\n`
|
||||
response.write(message)
|
||||
|
||||
const historyCursor = collection.find()
|
||||
.sort({$natural:-1})
|
||||
.limit(historyNumber).toArray().then((res) => {
|
||||
|
Reference in New Issue
Block a user