Skip to content

Commit

Permalink
feat: wip - working tags and fields
Browse files Browse the repository at this point in the history
  • Loading branch information
amunchet committed Sep 18, 2023
1 parent 1b0556e commit 9a4f3fb
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
8 changes: 7 additions & 1 deletion backend/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,13 @@ def find_service(name):
watcher.send_alert(alert_name, metric_name, host_name, summary=summary)
rc.set(key_name, time.time())

service_results[service] = {"name": service, "state": result}

service_results[service] = {
"name": service,
"state": result,
"found_service" : found_service,
"latest_metric" : latest_metric
}
for item in service_results:
host["services"] = [service_results[x] for x in service_results]

Expand Down
41 changes: 39 additions & 2 deletions frontend/labyrinth/src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -407,20 +407,57 @@ export default {
});
},
checkHostFilter(host, searches) {
console.log("Host:", host);
console.log("Searches:", searches);
let retval = false;
searches.forEach((search) => {
// Services Search
if (
host.services
.map((x) => (x ? x.name.toLowerCase() : ""))
.indexOf(search.service.toLowerCase()) != -1
) {
retval = true;
}
// Open Ports Search
if (host.open_ports.indexOf(parseInt(search.port)) != -1) {
retval = true;
}
// Tags Search
try{
search.tag.forEach(tag=>{
host.services.map(x=>x.latest_metric).forEach(field=>{
if (field["tags"] != undefined && [tag["tag"]] != undefined && String(field.tags[tag["tag"]]) == String(tag["value"])){
retval = true
}
})
})
}catch(e){
console.log("Tags parse failed")
console.log(e)
}
// Fields Search
try{
search.field.forEach(search_field=>{
host.services.map(x=>x.latest_metric).forEach(field=>{
if (field["fields"] != undefined && [search_field["fields"]] != undefined && String(field.fields[search_field["field"]]) == String(search_field["value"])){
retval = true
}
})
})
}catch(e){
console.log("Fields parse failed")
console.log(e)
}
// Other search
const names = ["ip", "group", "host"]
names.forEach(found_name => {
if(host[found_name] == search[found_name]){
retval = true
}
})
});
return retval;
},
Expand Down

0 comments on commit 9a4f3fb

Please sign in to comment.