From ebcf6a1c6200dbd90f0d30dfffb54c48416aa2c0 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Thu, 2 Feb 2023 17:03:11 +0000 Subject: [PATCH] FullStack: Add metrics API Signed-off-by: Fred Boniface --- src/services/list.services.js | 7 +++++-- static/js/stat.js | 20 ++++++++++++++++++++ static/stat.html | 18 ++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 static/js/stat.js create mode 100644 static/stat.html diff --git a/src/services/list.services.js b/src/services/list.services.js index 6665689..f26722a 100644 --- a/src/services/list.services.js +++ b/src/services/list.services.js @@ -1,6 +1,6 @@ const log = require('../utils/log.utils'); // Log Helper const db = require('../services/dbAccess.services') -const corpus = require('../services/corpus.services'); +const os = require('os') async function getStations(){ var out = await db.query("stations") @@ -15,8 +15,11 @@ async function getCorpus(){ } async function hits(){ - var out = await db.query("meta"); + var dat = await db.query("meta", {target: "ext_api"}); log.out(`listServices.meta: fetched server meta`) + let out = {} + out.host = os.hostname() + out.dat = dat return out; } diff --git a/static/js/stat.js b/static/js/stat.js new file mode 100644 index 0000000..1f13bfc --- /dev/null +++ b/static/js/stat.js @@ -0,0 +1,20 @@ +init(); + +async function init() { + display(await get()) +} + +async function get() { + var url = `${window.location.origin}/api/v1/list/hits`; + var resp = await fetch(url); + return await resp.json(); +} + +async function display(data) { + document.getElementById('server_host').textContent = `HOST: ${data.host}`; + let dat = data.dat[0] + console.log(JSON.stringify(dat)) + document.getElementById('time').textContent = `COUNTER START TIME: ${dat.since}`; + document.getElementById('ldbws').textContent = dat.ldbws || "0"; + document.getElementById('ldbsvws').textContent = dat.ldbsvws || "0"; +} \ No newline at end of file diff --git a/static/stat.html b/static/stat.html new file mode 100644 index 0000000..4efacee --- /dev/null +++ b/static/stat.html @@ -0,0 +1,18 @@ + + + + OwlBoard - STATS + + + +

OwlBoard Server Stats

+

+

+

LDBWS API Hits:

+

LDBSVWS API Hits:

+

+

Multiple servers can be attached to one database. All servers sharing this servers DB are represented in these statistics, + responses that do not lead to an upstream API hit are not counted. +

+ + \ No newline at end of file