Skip to main content
kuhbrille
Silver ⭐️⭐️
August 8, 2023
Solved

Ranger API assets/accessAudit set startDate in URL

Hi,

I want to read data from Ranger Rest API ...assets/accessAudit...

Works fine but need to set the startDate like I can do it in the Ranger WebUI in the Audit part.

Is there any docu where to find how to do that?

 

Example: ...server:port/service/assets/accessAudit?startDate=06/02/2023&resourceType=@table&accessType=select&sortBy=eventTime&sortType=descending&excludeServiceUser=false

In this example the startDate does not work, only getting the data from the actual day.

If I use the startDate in the Ranger WebUI it works fine.

 

BR

Roland

jgeert1
jgeert1Answer
Gold ⭐️
September 29, 2023

This works:
---/service/assets/accessAudit?startIndex=0&pageSize=50&sortBy=eventTime&sortType=asc&startDate=09%2F28%2F2023
To get the next records:
---/service/assets/accessAudit?startIndex=50&pageSize=50&sortBy=eventTime&sortType=asc&startDate=09%2F28%2F2023

I would recommend to read more than 50 (pageSize) records at the time and also do some filtering like "&repoName=cm_hive" to reduce the number of records.

9 replies

DianaTorres
Community Manager
Community Manager
August 8, 2023

@kuhbrille Welcome to the Cloudera Community!

To help you get the best possible solution, I have tagged our Ranger experts @Atahar  and @vamsi_redd  who may be able to assist you further.

Please keep us updated on your post, and we hope you find a satisfactory solution to your query.

Translate
Regards, Diana Torres, Senior Community Moderator
steven-matison
Platinum ⭐️⭐️
Platinum ⭐️⭐️
August 8, 2023

@kuhbrille   When i execute this in my ranger and check the call, the date is URL parsed:

 

08%2F08%2F2023

 

https://host.host.a465-9q4k.cloudera.site/se-aw-mdl/cdp-proxy/ranger/service/assets/accessAudit?page=0&pageSize=25&total_pages=57997&totalCount=1449906&startIndex=0&excludeServiceUser=false&startDate=08%2F08%2F2023&accessResult=0&_=1691511837287

 

Does that help get your call to take it the date?

Translate
kuhbrille
kuhbrilleAuthor
Silver ⭐️⭐️
August 8, 2023

Hi, no, did not help... I took out the totalPages and totalCount...

tried it with page=0 and also with pageSize=25...

It always takes the last 200 rows... whatever I do...

.../service/assets/accessAudit?page=0&pageSize=25&startIndex=0&excludeServiceUser=false&startDate=08%2F08%2F2023&accessResult=0

Translate
kuhbrille
kuhbrilleAuthor
Silver ⭐️⭐️
August 8, 2023

in the Ranger WebUI, when I define the filter in the Audit part, I also have the:

sortType=asscending&sortKey=eventTime

I tried that in my URL, but does not work

Translate
kuhbrille
kuhbrilleAuthor
Silver ⭐️⭐️
August 9, 2023

like I can see, the sorting of the result might cause the issue... whatever I do, it is descending... and so I cannot see, if the startDate filter is working or not... 

anybody an idea how to set the sorting in the correct way?

I did it like this: &sortType=ascending&sortBy=eventTime

But that does not work...

 

here another example... I do not see what I am doing wrong:

---/service/assets/accessAudit?startDate=08%2F08%2F2023&sortBy=eventTime&sortType=ascending&excludeServiceUser=false&pageSize=4&startIndex=0

Translate
jgeert1
jgeert1Answer
Gold ⭐️
September 29, 2023

This works:
---/service/assets/accessAudit?startIndex=0&pageSize=50&sortBy=eventTime&sortType=asc&startDate=09%2F28%2F2023
To get the next records:
---/service/assets/accessAudit?startIndex=50&pageSize=50&sortBy=eventTime&sortType=asc&startDate=09%2F28%2F2023

I would recommend to read more than 50 (pageSize) records at the time and also do some filtering like "&repoName=cm_hive" to reduce the number of records.

Translate
Scharan
Gold ⭐️
Gold ⭐️
September 29, 2023

Hello @kuhbrille/Roland

Can you try the below API?

<Ranger host>:<Port No>/service/assets/accessAudit?&sortBy=eventTime&sortType=asc&startIndex=0&startDate=<Date>

Example:

 http://myranger:6080/service/assets/accessAudit?&sortBy=eventTime&sortType=asc&startIndex=0&startDate=09/23/2023

Translate
jgeert1
Gold ⭐️
September 30, 2023

@Scharan Why are you repeating my working solution...? Is it your goal to walk away with my  credits...?

Translate
DianaTorres
Community Manager
Community Manager
October 6, 2023

@kuhbrille Has the reply helped resolve your issue? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future. Thanks.

Translate
Regards, Diana Torres, Senior Community Moderator