GlideAggregate API access to v_cluster_transactions for monitoring
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2024 01:46 AM
Hello,
we want to monitor the active cluster transactions to identify easily long running or stuck jobs. Because it is a v_table and requires a manual refresh at least on UI, we were not able to use GlideAggregate so far.
Is there a trick to still get it there or do you know any other options how to have a get a lightweight API access to this table?
Thank you in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2024 06:42 AM
Hey @Anton42
I think you might be able to do it all in one REST call since the UI Page as it is today does the entire transaction of refreshing the table and then holding until the progress worker completes. If you use the code in the UI Page, then it should all work the same via a REST call. There is nothing special about the UI Page other than it calls the logic that updates the table and then shows you a progress worker while the table is refreshed
As for how long the data stays in the table, I am unsure, but I would guess it stays there indefinitely until the table is refreshed again. You'd have to do some testing to confirm that though.
Hope this helps!
~Nick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2025 02:58 AM
Hi,
we now solved that by having a scripted Rest API with a sleep to wait for the calculation and a Aggregate function to just show some information to the endpoint
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var vct = new VClusterTransaction('v_cluster_transaction');
vct.deleteTransactions();
var id = vct.informOtherNodes();
vct.refreshTransactions(GlideSession.get().getSessionID());
gs.sleep(25000); // wait to fetch all active transactions
if (id == null) {
response.setStatus(400);
response.setBody({ error: "Cannot retrieve transactions from other nodes. Check permissions." });
return;
}
// Aggregate query to count transactions older than 1 hour
var transactions = new GlideAggregate('v_cluster_transaction');
transactions.addQuery("age", ">=", gs.getDurationDate('0 1:0:0'));
transactions.addAggregate("COUNT");
transactions.query();
var count = 0;
if (transactions.next()) {
count = transactions.getAggregate("COUNT");
}
response.setStatus(200);
response.setBody({ count });
})(request, response);