Integrating Esadax Log Drains with Any Backend

Author:Mikkel Haldorsen
Updated:Jun 22, 2025

To receive and handle logs from Esadax using Log Drains, follow the framework-agnostic steps below. These apply to any backend that supports HTTP routing and environment configuration.


1. Set Up an Endpoint

Create an HTTP endpoint (e.g., /esadax/logs) in your application that accepts POST requests. This endpoint will receive log data from Esadax.

  • Ensure it supports JSON payloads.
  • Only accept POST requests for security and consistency.

Example (pseudocode):

POST /esadax/logs
Content-Type: application/json
Body: { logs: [...] }

2. Secure with Signature Verification

Esadax sends a signature header (x-esadax-signature) with each log payload.

  • Set an INTEGRATION_SECRET in your environment (from your Esadax dashboard).
  • Use this secret to verify the signature and ensure the request is from Esadax.

Signature Verification Example (Node.js-style pseudocode):

const crypto = require('crypto');

function verifySignature(secret, body, signature) {
  const hmac = crypto.createHmac('sha256', secret);
  hmac.update(body);
  const expectedSig = hmac.digest('hex');
  return expectedSig === signature;
}

3. Log Drain Configuration on Esadax

In the Esadax dashboard:

  • Define Sources: Choose log sources (e.g., lambda, edge, or static).
  • Select Environments: Target only relevant environments (like production or staging).
  • Set Sampling Rate: Optionally limit log volume (e.g., 50% sample rate).

4. Secure the Communication

  • Use HTTPS: Your log endpoint must be served over HTTPS to protect data in transit.
  • Validate Headers and IPs (optional): If you want extra protection, restrict incoming requests to Esadax IPs or validate User-Agent.

5. Handle and Store Logs

Once verified, parse the payload and forward it to your preferred log storage or analytics tool (e.g., Datadog, Loki, Sentry, Elasticsearch).

Example log handling flow:

  • Validate → Parse → Filter (optional) → Store or alert

6. Respond Appropriately

Always respond to Esadax with the right HTTP status code:

  • 200 OK: Successfully received and verified the payload
  • 400 Bad Request: Malformed or missing data
  • 403 Forbidden: Invalid signature

7. Test Your Setup

Before going live:

  • Use curl or Postman to send simulated payloads.
  • Test with both valid and invalid signatures to verify your logic.
  • Check logs and observability tools to ensure logs are being captured and stored properly.

Example curl Test (Replace with your secret logic)

curl -X POST https://yourdomain.com/esadax/logs \
  -H "Content-Type: application/json" \
  -H "x-esadax-signature: <calculated_signature>" \
  -d '{ "logs": [...] }'

Summary

Step Description
1 Create a secure log endpoint
2 Implement signature verification
3 Configure log drains in Esadax
4 Use HTTPS and optional IP validation
5 Process and route log data
6 Send proper HTTP responses
7 Test the setup with valid/invalid payloads