Skip to main content

Accessing search logs of asset

Search logs provide valuable insights for analysts to monitor the popularity of assets within Atlan, including details such as the most visited assets, user interactions, and emerging search patterns. Accessing the search log of an asset is a flexible operation, which may seem more intricate compared to other operations. To harness the complete flexibility of Atlan's search, the SDK introduces a dedicated SearchLogRequest object.

Similar but not identical to searching in general

Atlan's search log, which contains the search logs of an asset, utilizes Elasticsearch. This makes the approach to accessing search logs similar to searching. However, there are differences, as the search log uses a distinct index from the broader search. If you're feeling adventurous, feel free to experiment with the more complex search mechanisms outlined in the searching section. Nevertheless, this should be sufficient to help you get started with accessing asset search logs.

Most recent viewers of asset

To retrieve the most recent viewers of an asset:

Retrieve the most recent viewers of an asset
List<UserViews> viewers = SearchLog.mostRecentViewers( // (1)
client, "955c455d-cfea-4c9c-844d-e226edf8b6da", 20, List.of("atlansupport")
);

for (UserViews viewer: viewers)
  1. You must provide GUID of the asset and specify the maximum number of recent users to be considered for the search log request.

    • Optionally, you may provide a list of usernames to be excluded from the search log results.

    Because this operation will directly look up the asset's views in Atlan, you must provide it an AtlanClient through which to connect to the tenant.

  2. You can then iterate through each recent viewers.

  3. Name of the user who viewed the asset.

  4. Number of times the user viewed the asset.

  5. When the user most recently viewed the asset (epoch-style), in milliseconds.

Most viewed assets

To retrieve the most viewed assets by its total views:

Retrieve the most viewed assets by its total views

List<AssetViews> topAssetsByViews = SearchLog.mostViewedAssets(
client, 10, false, List.of("atlansupport") // (1)
);

for (AssetViews detail: topAssetsByViews)
  1. To retrieve the most viewed assets, specify the maximum number of assets you want to retrieve. Then specify whether you want the most-viewed based on total number of views, irrespective of distinct users (false); or based on the most distinct users, irrespective of total views (true).

    • Optionally, you may provide a list of usernames to be excluded from the search log results.

Because this operation will directly look up the asset's views in Atlan, you must provide it an AtlanClient through which to connect to the tenant.

  1. You can then iterate through each asset's views.
  2. GUID of the asset that was viewed.
  3. Number of times the asset has been viewed (in total).
  4. Number of distinct users that have viewed the asset.

Detailed search log entries

To retrieve detailed search log entries (paged via lazy fetching):

To retrieve detailed search log entries

SearchLog.viewsByGuid(
client,
"955c455d-cfea-4c9c-844d-e226edf8b6da",
List.of("atlansupport")
) // (1)
.stream() // (2)
.limit(100) // (3)
.forEach(entry -> { // (4)
logger.info(entry.getUserName() + " from " + entry.getIpAddress());
});
  1. You must provide the GUID of the asset for which you are seeking the detailed search log entries.

    • Optionally, you may provide a list of usernames to be excluded from the search log results.

    Because this operation will directly look up the asset's views in Atlan, you must provide it an AtlanClient through which to connect to the tenant.

  2. The search will only run when you call the stream() method, which will then lazily-load each page of results into a stream

  3. With streaming, you can apply your own limits to the maximum number of results you want to process.

    Independent of page size

Note that this is independent of page size. You could page through results 50 at a time, but only process a maximum of 100 total results this way. Since the results are lazily-loaded when streaming, only the first two pages of results would be retrieved in such a scenario. ::: 4. You can then iterate through each log entry to retrieve details such as the username and IP address of the search logs.

Was this page helpful?