defenseunicorns / leapfrogai

Production-ready Generative AI for local, cloud native, airgap, and edge deployments.
https://leapfrog.ai
Apache License 2.0
253 stars 29 forks source link

chore(api): Review API Code for Improved Logging and Debugging Support #688

Open CollectiveUnicorn opened 3 months ago

CollectiveUnicorn commented 3 months ago

Describe what should be investigated or refactored

We need to review our API code to determine if our current logging practices are sufficient for effective debugging. Specifically, we should:

  1. Assess the current logging coverage.
  2. Identify areas where additional logging could provide valuable insights during troubleshooting.
  3. Evaluate the level of detail in existing log messages and determine if they provide enough context for debugging.
  4. Check if we're using appropriate log levels (INFO, DEBUG, WARNING, ERROR) consistently throughout the codebase.
  5. Consider implementing structured logging for better log parsing and analysis.

Additional context

justinthelaw commented 3 weeks ago

Gerred's comments:

an track and monitor API interactions for compliance and debugging purposes

Acceptance Criteria:

  • [ ] Implement a configuration option to enable or disable audit logging
  • [ ] When audit logging is enabled, generate a unique ID for every API interaction
  • [ ] Capture the following information for each API interaction:

    • [ ] Unique ID
    • [ ] Timestamp
    • [ ] User or client making the request
    • [ ] Endpoint or API method invoked
    • [ ] Request payload (including input data, parameters, and headers)
    • [ ] Response payload (including output data, status code, and headers)
  • [ ] Store the captured audit logs in a secure and tamper-proof storage system
  • [ ] Ensure the audit logging mechanism has minimal impact on the performance of the inferencing pipeline
  • [ ] Provide a way to retrieve and query the audit logs based on different criteria (e.g., time range, user, endpoint)
  • [ ] Implement proper access controls and authentication mechanisms to restrict access to the audit logs
  • [ ] Ensure the audit logging system can handle high volumes of requests without causing performance degradation
  • [ ] Provide documentation on how to enable and configure audit logging, as well as how to access and interpret the logged data
  • [ ] Conduct thorough testing to verify the accuracy and completeness of the captured audit logs
  • [ ] Ensure the audit logging system complies with relevant security and privacy regulations
  • [ ] Set up automated monitoring and alerting for any anomalies or suspicious activities detected in the audit logs
  • [ ] Regularly review and analyze the audit logs to identify potential issues, optimize performance, and improve the system