Log API Requests #274
Labels
API
discuss
Share your constructive thoughts on how to make progress with this issue
enhancement
New feature or enhancement of existing functionality
MVP
priority-2
Second highest priority, should be worked on as soon as the Priority-1 issues are finished
technical
A technical issue that requires understanding of the code, infrastructure or dependencies
With the creation of the API #273 and our goal of making it easy for anyone to request their @dwyl App data via JSON/WebSockets, we need to have the means of logging requests in place quite soon ... π β³
Story
As a
developer
building an App with an API,I want to have logging of all API requests
So that we can detect anomalous usage patterns and guarantee service levels.
Todo
logs
Schema/Table (_for MVP we will store the logs in the same DB, we can split them out into a separate service later or use a 3rd Party Service like Timber.io, Logstash, etc.email
- encrypted email of the person the login attempt was made for. This allows us to keep track of how many attempts were made for a given account in a set time frame. If not set, leavenull
person_id
- if the request is authenticated, log theperson_id
otherwise just theemail
so that we can later analyse the failed login attempts. (e.g: typos)apikey_id
- theAUTH_API_KEY
used for the request.ip_address
- so we can rate limit byperson_id
andip_address
and so that we can inform people when their account has been accessed from an unrecognised IP.see: https://github.com/dwyl/hits/blob/cd9a8e15c6e598281b7bc6b037963dab6ac515f8/lib/hits_web/controllers/hit_controller.ex#L32-L33
user_agent_id
- same as in Hits, we will have auser_agents
schema where we store the full User Agent string then we reference it in the log rather than duplicating it.See: https://github.com/dwyl/hits/blob/cd9a8e15c6e598281b7bc6b037963dab6ac515f8/lib/hits.ex#L48-L58
timstamps
(default in all Ecto/Phoenix schemas)This is related to: Logging "Login" Attempts: dwyl/auth#67 (
P2
)and Logging in General: dwyl/learn-devops#60
The text was updated successfully, but these errors were encountered: