Skip to content

#535 Implement Log Consumption API with Pagination, Validation, and Flexible Date Handling

Type of change

  • Bug Fix
  • Feature

Please provide link to gitlab issue or ADR(Architecture Decision Record)

Does this introduce a change in the core logic?

  • [YES]

Does this introduce a change in the cloud provider implementation, if so which cloud?

  • AWS
  • Azure
  • GCP
  • IBM

Does this introduce a breaking change?

  • [NO]

What is the current behavior?

  • The application does not have an API for retrieving logs from different log streams with flexible date range and pagination support. There is no existing mechanism for filtering logs based on keywords, nor any validation of log stream identifiers.

What is the new/expected behavior?

  • Introduced the /gcz/transformer/admin/logs API endpoint for fetching logs based on log stream, date range, and keyword.
    • Added support for both full ISO date-time and simple date format (yyyy-MM-dd).
    • Pagination support added with page size and number parameters.
    • Keyword-based filtering of log messages.
  • Validation of logStream using the LogStream enum to ensure valid stream identifiers.
  • Custom error messages for invalid log stream identifiers and enhanced global exception handling for validation errors.
  • OpenAPI-compliant documentation with the @Tag annotation for LogsController.

Have you added/updated Unit Tests and Integration Tests?

  • Yes:
    • Unit tests were added for:
      • LogsController: Testing date format flexibility, validation of log streams, and pagination logic.
      • LogsService: Ensuring the proper interaction with the repository and correct data retrieval based on filters.
      • MockLogsRepository: Simulating different scenarios like log retrieval based on stream, date range, and keyword filters.
    • Also, validation tests for LogStream enum and exception handling were included.

Any other useful information

  • New classes/interfaces introduced:
    • LogsController: Provides the API for fetching logs and handles input validation.
    • LogsService: Business logic layer responsible for interacting with the repository.
    • LogsRepository (Mock implementation): Simulates log data retrieval, supports testing of pagination and filtering.
    • LogStream: Enum representing different log streams and providing utility methods.
  • A mock data set was added with 4-12 log items per stream for testing pagination and keyword filtering.
  • The new logs functionality allows admins to efficiently query and filter logs based on specific streams and time ranges, enhancing log management.

Swagger examples

image image image

Edited by Rostislav Dublin (EPAM)

Merge request reports

Loading