Auditing API calls

Hi all, we have a .NET API and want to introduce audit logs, which includes two logs per HTTP call: one for request with payload, the other one for response with payload. We have our API running in ECS. What could be the go-to? Is utilizing logging middleware in application to capture requests/responses and sending them to CloudWatch sink a good idea or is there a better approach?


Related discussions:

B2C linking to an AWS App
AWS Inventory on a single HTML page
Migrating to AWS ECS Fargate in Production
ECS Java App reporting high memory usage
Massive unexpected AWS Bill
CloudFormation custom resource allows anyone to invoke any Lambda function?
Use Cloudwatch logs agent even if sending to sumologic/splunk?
Daemon services now available on ECS
CI/CD with OWASP ZAP on AWS
Question about AWS Config
Noob help for pushing to ECR and spinning it up
Cloudwatch agents necessary for memory reporting?
Cloudwatch Insights
Centralized logging with CloudWatch
Getting started with the AWS Cloud Development Kit for Amazon ECS
Had a strange case with Cloudwatch Logs Stream to ElasticSearch today... AWS says it's a bug on their end?
Private Endpoints are now showing up for ECS and ECR
Cloud System Admin Or Devops Scenario Based questions
Best App/Solution for reading CloudTrail Logs? How do you do it?
AWS ECS (ec2) best practices ?
How to set up multiple proxies for egress traffic, each with unique IPs?
LB health checks interfering with our autoscale - What is the proper way to handle this?
Detect and alert on PII in CloudWatch logs
Tracking responses to CW alarms?
ECS Services How to Upgrade Without Killing All Tasks
New Cloudwatch "ServiceLens" product
Sending logs to cloudwatch
Ideal setup of ECS cluster with Traefik and ALB
Tracking environmental impact of AWS usage?
Target group for ecs service?
Automating your ECS container architecture deployments with ECS ComposeX | Amazon Web Services
Improving visual effects studio workflow - which Amazon AWS service?
Serverless - 0 logs in CloudWatch, but full logs when debugging
Can't Adjust my ECS Task Scaling
Did CloudWatch just fall over for anyone else?
ECS - our server response time has dropped from 0.3s to 2.5s
Cloud Formation blue/green deployment
Can I replace NLB with ECS Service Discovery?
AWS CDK for AWS Budget with notification and CF deploy stack
Public Preview – AWS Distro for OpenTelemetry
A CI/CD geek's message to Jeff Bezos
How do you simulate a Cloudwatch outage?
AWS Native Services or 3rd party SIEM
Does ECS try to replace tasks on unreachable EC2, if health check is configured without ELB?
Need to figure out how to bring down cloudwatch cost
Running ECS on CIS Hardened Amazon Linux
How to send AWS and non-AWS logs from S3 bucket to Splunk
Can Log streams be moved from one Log Group to another?
AWS health dashboard on 60” tv in the IT office showing a dashboard of AWS connections, throughput, and any active alarms I have on my CloudWatch. If I leave a web session open, it times-out after some time. Can anyone suggest a better way to have a
#AWS GameDay events are hands-on learning opportunities recommended for system administrators, architects, DevOps, developers and other technical roles of all skill levels
Question: How to you handle errors in your lambda ?
Best practices/recs for not hardcoding credentials
Scheduling Lambda Execution
ECS Fargate Technical Question — what happens if a client's session is bound (via LB cookies) to a container/task that "scales in"? How do you prevent these errors?
Announcing Amazon ECS Task Scale-in protection
Amazon CloudWatch launches Metrics Insights alarms (using SQL queries)
Confused with ECS and how it deploys
Comparison between ARM64 and X86_X64 on ECS Fargate (Node.js)
How is the AWS managed Airflow?
Upcoming changes in IP charges
Properly using Lambda functions in a pipeline
Deploy FastAPI + PyTorch model
ECS spot interruption statistics
When using CDK to deploy CodePipeline, do you also use CodePipeline to run `cdk deploy`?
Best Practices Scaling Services in ECS on Business Hours
Reduce Code Pipeline Deployment Time
Is Cloudwatch agent only for servers?
In what use case would you use ECW ECS over Fargate?
ECS capacity not decreasing
AWS Bedrock limits for SonnetV2 are crap and support is oblivious
ECS or Lambda for STFP File transfer every 30 minutes
Introducing Cloud Snitch, a 100% open source visualization for AWS activity, inspired by Little Snitch
Is it worth migrating from AWS to Vercel or Render?
Can you migrate from ECS blue/green to rolling?
Amazon CloudWatch launches Cross-Account and Cross-Region Log Centralization
AgentCore "memory leak"
In ECS Fargate Spot, How to detect if SIGTERM is triggered by spot interruption vs user termination?
API Gateway Questions
Another I passed the DevOps Pro today post!
Forwarding port ranges with ELB
Cloudwatch cost breakdown?

If you’re using ECS you can just send the logs to STDOUT and they’ll be in CloudWatch just like the other container events

I wouldn’t log sensitive payloads to CloudWatch. It’s a money pit and ACLs are porous. Pipe to Kinesis Firehose then encrypted S3. Middleware will tank your latency anyway.

Whats the volume of data? Do you have cost constraints? Do you have architectural complexity constraints? How do you intend to use the data?

So many reasons not to log full payloads: security/privacy risk, performance, storage cost, logging noise, retention liability for legal discovery etc. If you really must do this then consider redacting sensitive content.

Guys I was able to get access to this AWS account and I need to log all the info going in and out of an appliance /s

Hi, sorry for late reply.

  1. It is about 100,000 requests per day.

  2. There is no real costs constraints, but it would be great to optimize costs (enterprise company money). From what I have gathered, for large number of logs CloudWatch isn’t a go-to solution, maybe add a 90-days retention period and then store it to S3. Other solution as per u/Adrienne-Fadel would be to set up a pipe to Kinesis Firehose and then encrypted S3. Then the only question remains how to query those logs but I can investigate that.

  3. The service sits in an isolated PCI-DSS environment with limited AWS services capabilities, although the main services like ECS, S3, EC2, RDS etc. are whitelisted, so it should not be an issue. If needed, there could be a case raised to an IT department.

  4. Data should be used for audit purposes, however, we would still need to access the logs for daily troubleshooting if issues arise.

Hopefully I have answered all of the questions. The requirements are getting refined every day so it’s difficult to give concrete details.

That helps. I’d look into sending the logs to OpenSearch instead of S3. Obviously it’ll be more expensive but the improvement in DevEx for auditing/daily troubleshooting will more than make up for it.