Hello,
I calculate the difference between two date columns but the results are strange.
this is the script:
set serveroutput on
whenever sqlerror exit sql.sqlcode;
set echo off
SET VERIFY OFF
set heading off
SET FEEDBACK OFF
set serveroutput on size unlimited
set linesize 300
alter session set current_schema = my_schema;
-- alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS';
ALTER session SET TIME_ZONE='GMT';
Declare
vv_SchemaName VARCHAR2(15);
BEGIN
vv_SchemaName := Sys_Context('USERENV','CURRENT_SCHEMA');
FOR REVOKED IN (
select a.transaction_id as trans_Id,
e.eventcode,
e.eventtime,
a.time_received,
(e.eventtime - a.time_received) * 86400 as total
from request_history_tbl a
join
eventlog_tbl e
on a.transaction_id = e.transaction_id
where e.eventtime >= current_timestamp - 6/24
and e.eventcode = '51'
order by 3
)
LOOP
dbms_output.put_line('revocation_request_seconds{' || 'transID=' || '"' || REVOKED.trans_Id || '"' || ',instance=' || '"' || vv_schemaname || '"' || '} ' || REVOKED.total );
END LOOP;
END;
/
I would like by this to display some metrics for prometheus like this:
revocation_request_seconds{transID="xxxxx",instance="my_schema"} 0
I have two questions if I may:
is this the best way to add the quotes and curly brackets? and also the schema name?
the date calculation is not rounded up so i am getting this like:
revocation_request_seconds{transID="xxxxx",instance="my_schema"} .9999999999999999999999999999999999999996
how can i make the script display 1 instead of that large array of 9's ?
thank you