Skip to content

Instantly share code, notes, and snippets.

@shaheerxt
Last active December 22, 2021 13:53
Show Gist options
  • Save shaheerxt/a82bae7255ff2d899ce805df0095693f to your computer and use it in GitHub Desktop.
Save shaheerxt/a82bae7255ff2d899ce805df0095693f to your computer and use it in GitHub Desktop.
SAP HANA Auditing
-- Please enable the auditing on database as documented in https://gist.github.com/shaheerxt/2ceda6c2d49e1fd33187428ff9da5a0b
-- Setup Policy as SYSTEM user (On the database - SYSTEMDB or TENANT DB):
CREATE AUDIT POLICY "AUDIT-USER_CONNECT_FAILURES" AUDITING UNSUCCESSFUL CONNECT LEVEL INFO;
-- Query to check if there are failures:
select *
from audit_log
where audit_policy_name = 'AUDIT-USER_CONNECT_FAILURES'
order by timestamp desc
limit 100;
-- You may want to check minutes aggregation if you have an application that often makes unsuccessful connections the database.
select current_database() DB_NAME,
to_char(timestamp, 'YYYY-MM-DD HH24:MI') as MINUTE_OF_DAY,
CLIENT_HOST,
APPLICATION_USER_NAME,
EVENT_STATUS,
count(*)
from audit_log
where audit_policy_name = 'AUDIT-USER_CONNECT_FAILURES'
group by current_database(),
to_char(timestamp, 'YYYY-MM-DD HH24:MI'),
CLIENT_HOST,
APPLICATION_USER_NAME,
EVENT_STATUS
order by 1 desc
limit 100;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment