epok
View as Markdown

Send logs & metrics from AWS to Epok

Updated Nov 22, 2026 · today

One CloudFormation stack in your account (epok-logs) connects CloudWatch Logs to Epok. A subscription filter on each log group you choose sends log events to an Amazon Data Firehose stream. Firehose delivers them to Epok over HTTPS. A second stack, epok-metrics, adds a CloudWatch metric stream for your AWS metrics. This covers every service that writes to CloudWatch Logs: Lambda, ECS, EKS, EC2, API Gateway and RDS.

  • Epok runs no code in your account.
  • The Epok key is a NoEcho stack parameter. It is passed on stdin, never on the command line, and never goes into a URL. CloudFormation does not show it in the console or in API output.
  • Scope is one region. Firehose and metric streams are regional, so run setup once per region, or use one StackSet for several regions or accounts.
  • Firehose retries failed deliveries and writes what it still cannot deliver to an encrypted S3 bucket in your account. Epok drops duplicate records when Firehose retries.

On this page: Before you startRead-only roleOne commandSeveral regions or accountsCheck data arrivedMetricsTroubleshootingRemoveAI agentsTracesHost files and containers

Before you start

  1. The aws CLI and curl, logged in as someone with these permissions: cloudformation:CreateStack, cloudformation:DescribeStacks, cloudformation:DescribeStackEvents, cloudformation:DeleteStack, firehose:CreateDeliveryStream, firehose:DeleteDeliveryStream, firehose:DescribeDeliveryStream, iam:CreateRole, iam:PutRolePolicy, iam:PassRole, iam:DeleteRole, iam:DeleteRolePolicy, s3:CreateBucket, s3:PutBucket*, s3:DeleteBucket, s3:DeleteObject, s3:ListBucket, logs:CreateLogGroup, logs:DeleteLogGroup and logs:PutRetentionPolicy. AdministratorAccess covers all of them.
  2. An ingest-scope API key dedicated to this integration: app.epok.cloud and open Settings, then API Keys, then New key (scope: ingest, name: aws-firehose-<account>-<region>).
  3. The log groups to send. List them with aws logs describe-log-groups --query 'logGroups[].logGroupName' --output text.
bash
export AWS_REGION="eu-central-1"
export EPOK_LOG_GROUPS="/aws/lambda/checkout,/ecs/api"
export EPOK_API_KEY="<ingest-scope key from Settings → API Keys>"

Cost

Firehose bills about $0.029/GB ingested, with a 5 KB minimum per record. CloudWatch batches many log events into one record, so the minimum rarely applies. CloudWatch Logs still bills its own charges for the log groups. Failed deliveries in the S3 bucket expire after 14 days. Epok bills the decoded log bytes per your plan. The log groups you list decide volume: check their stored bytes per day before you add a busy group. A metric stream adds CloudWatch's charge of about $0.003 per 1,000 metric updates.

Inventory and change events: Launch stack

For accounts with the AWS role integration enabled, Epok provides a Launch stack link with your integration's External ID and trusted principal filled in. This separate stack creates a read-only IAM role under /epok/ for inventory and CloudTrail change events. Review the permissions, create the stack, then copy its RoleArn output back to Epok to verify the connection.

Launch stack in Epok when AWS role setup is enabled for your account. Epok supplies your External ID; the example below contains placeholders only.

text
https://console.aws.amazon.com/cloudformation/home?region=<region>#/stacks/quickcreate?templateURL=<regional-readonly-template-url>&stackName=EpokReadOnly&param_ExternalId=<app-generated-id>&param_EpokPrincipalAccountId=<app-principal-account>&param_EpokPrincipalArn=<app-principal-arn>&param_EnableChangeEvents=true&param_RoleNameSuffix=i<integration-id>

Set up with one command (AWS CLI)

Download the script, read it, then run it. Do not pipe it into bash. It is idempotent: a complete Epok stack that already exists is left as it is. The API key is never printed.

bash
curl -fsSLo aws-logs.sh https://epok.cloud/setup/aws/aws-logs.sh
less aws-logs.sh          # read it first
bash aws-logs.sh --dry-run  # optional: print every command, change nothing
bash aws-logs.sh

It creates one stack, epok-logs by default (EPOK_STACK_NAME), tagged managed-by=epok. The stack holds:

  • A Firehose stream with an Epok HTTP endpoint destination. It sends gzip-compressed batches with a 1 MB buffer and retries a failed delivery for up to an hour.
  • An S3 bucket for failed deliveries: encrypted, public access blocked, TLS only, objects expire after 14 days.
  • The log group /aws/kinesisfirehose/epok-logs, where Firehose records delivery errors.
  • IAM roles for Firehose and CloudWatch Logs. Each role is scoped to the stack's own stream, bucket and log group.
  • One subscription filter on each log group in EPOK_LOG_GROUPS.

Optional inputs: EPOK_LOG_FILTER_PATTERN (a CloudWatch filter pattern; empty sends every event), EPOK_BUFFER_INTERVAL_SECONDS (0–900, default 60; lower means lower latency and more requests), EPOK_STACK_NAME and EPOK_STACK_TAGS. The script prints progress to stderr. The last line on stdout is a JSON report: "seen_at" is set once a canary log reached Epok. Exit codes: 0 ok, 1 a step failed, 2 the data check timed out, 3 an input is missing or invalid.

To deploy the stack yourself, use the template at https://epok.cloud/setup/aws/epok-integration.yaml with CAPABILITY_IAM and CAPABILITY_AUTO_EXPAND, and enter the key in the EpokApiKey field. For several regions or accounts, use the StackSet template below.

Several regions or accounts: one StackSet

One CloudFormation StackSet deploys the same resources to every region you list, and optionally to every account in AWS Organizations units. You choose log groups by service and metrics by namespace, so the same inputs work in every region.

bash
read -rsp 'Epok ingest key: ' EPOK_API_KEY; echo; export EPOK_API_KEY
export EPOK_REGIONS="eu-central-1,us-east-1"       # every region to connect
export EPOK_SERVICES="lambda,ecs,rds,apigateway"   # also: vpcflow,waf
export EPOK_METRICS=true                           # optional: Metric Streams
curl -fsSLo aws-stackset.sh https://epok.cloud/setup/aws/aws-stackset.sh
less aws-stackset.sh          # read it first
bash aws-stackset.sh --dry-run  # optional: print every command, change nothing
bash aws-stackset.sh

Services

Service (EPOK_SERVICES)Log groupsDefault
Lambda/aws/lambda/on
ECS/aws/ecs/ and /ecs/on
RDS and Aurora/aws/rds/on
API Gateway execution logsAPI-Gateway-Execution-Logs_ and /aws/apigateway/on
VPC Flow Logs (to CloudWatch Logs)found with ec2:DescribeFlowLogsoff
AWS WAFaws-waf-logs-off
  • EPOK_EXTRA_PREFIXES: up to 5 more log group name prefixes. EPOK_LOG_SELECTION=all-log-groups uses one account-level subscription policy per region instead (CloudWatch allows one per account and region).
  • EPOK_METRIC_NAMESPACES: up to 12 namespaces, or ALL. Keep EpokCanary. CloudWatch bills about $0.003 per 1,000 metric updates.
  • In each region a small function (Python, inline in the template) adds the subscription filter to every matching log group: at create, every 15 minutes for new groups, and it removes them all on delete. It cannot read log data and never receives the Epok key. The output SubscriptionSummary counts the groups it subscribed, skipped (a log group allows 2 subscription filters) and failed. Details are in the log group /epok/<stack>/subscriber.
  • The key is a NoEcho StackSet parameter: shown as **** on the StackSet and on every stack instance, passed on stdin, and in no output, tag or function setting.

Permissions: self-managed or service-managed

Self-managed (the default) works without AWS Organizations. The script creates two IAM roles in this account: EpokStackSetAdministration, which can only assume the execution role, and EpokStackSetExecution, which can only create the resources of a StackSet whose name starts with epok (not the AdministratorAccess of the AWS sample role). Every role it creates must carry the permissions boundary EpokStackSetBoundary, so it cannot create a role with more access than the integration needs. For another target account, deploy https://epok.cloud/setup/aws/epok-stackset-execution-role.yaml there with AdministratorAccountId set to this account, then list it in EPOK_ACCOUNTS.

Service-managed deploys to organizational units and to accounts that join them later. Run it in the management account or a delegated administrator account:

bash
# In the management account (or a delegated administrator: EPOK_CALL_AS=DELEGATED_ADMIN)
export EPOK_PERMISSION_MODEL=service-managed
export EPOK_OU_IDS="ou-abcd-11112222,ou-abcd-33334444"
bash aws-stackset.sh

With service-managed permissions, AWS creates its own execution role in each member account, and that role has AdministratorAccess. Use self-managed if you need the least-privilege role. The management account itself gets no instance; use the one-region setup there. Epok tested self-managed in two regions of a real account (2026-11-20). Epok has not run service-managed in a real organization.

Remove with bash aws-stackset.sh --uninstall (same EPOK_REGIONS). It deletes every stack instance, the StackSet and the backup buckets the instances retained. EPOK_REMOVE_ROLES=1 also deletes the two role stacks the script created.

Check that data arrived

Setup ends with this check. Run it on its own at any time:

bash
bash aws-logs.sh --verify-only

It writes a canary event that carries a one-time token to the first log group you listed, then asks Epok whether that token arrived. It asks every 15 seconds for up to 15 minutes, because Firehose holds events until its buffer interval ends. Success is a non-null seen_at. To run the same check by hand:

bash
NONCE=$(openssl rand -hex 12)
G="${EPOK_LOG_GROUPS%%,*}"
aws logs create-log-stream --region "$AWS_REGION" --log-group-name "$G" --log-stream-name "epok-canary-$NONCE"
aws logs put-log-events --region "$AWS_REGION" --log-group-name "$G" --log-stream-name "epok-canary-$NONCE" \
  --log-events "timestamp=$(($(date +%s) * 1000)),message=epok canary epok_canary=$NONCE"
curl -fsS -H "X-API-Key: $EPOK_API_KEY" \
  "https://ingest.epok.cloud/api/v1/integrations/status?source=aws_firehose_logs&nonce=$NONCE"

The response also counts requests and records accepted or rejected in the last 24 hours, plus the last error reason. Then open app.epok.cloud and go to Live Tail to watch your log groups.

Metrics: CloudWatch metric streams

A second stack, epok-metrics, sends CloudWatch metrics to Epok through a metric stream and its own Firehose stream, in OpenTelemetry format. Nothing polls your account. It takes the same inputs as the logs stack (AWS_REGION, EPOK_API_KEY) and is installed and removed on its own:

bash
curl -fsSLo aws-metrics.sh https://epok.cloud/setup/aws/aws-metrics.sh
less aws-metrics.sh
bash aws-metrics.sh               # stack epok-metrics: a metric stream + its Firehose stream
bash aws-metrics.sh --verify-only # a fresh metric stream can take 3 to 15 minutes to deliver
bash aws-metrics.sh --uninstall   # when you no longer want it

The default namespaces are AWS/EC2, AWS/RDS, AWS/ApplicationELB, AWS/Lambda, AWS/SQS, AWS/DynamoDB, AWS/ECS and AWS/ElastiCache. Stream every namespace with EPOK_METRIC_NAMESPACES=all; check the metric-update cost above first. The metric stream gets its own IAM role, scoped to its own Firehose stream. Confirm on the Metrics page in Epok.

Troubleshooting

Commands assume the default stack name epok-logs.

1. Access denied: the caller lacks a permission

Seen as
A step fails with AccessDenied, "is not authorized to perform", or a CAPABILITY error. Nothing after that step ran.
Check
aws sts get-caller-identity --query Arn --output text
Fix
Ask an account admin to grant the missing permission from the list above. Never grant IAM permissions to yourself.

2. A stack with the same name already exists

Seen as
"refusing: a stack named … already exists", AlreadyExistsException, or the stack is in ROLLBACK_COMPLETE or DELETE_FAILED.
Check
aws cloudformation describe-stacks --region "$AWS_REGION" --stack-name epok-logs --query 'Stacks[0].StackStatus' --output text
Fix
Setup only reuses a complete stack tagged managed-by=epok. Set EPOK_STACK_NAME to another name, or ask the owner of the existing stack. Never delete a stack you did not create.

3. A log group already has 2 subscription filters

Seen as
The stack fails with "Resource limit exceeded" on an EpokFilter resource.
Check
aws logs describe-subscription-filters --region "$AWS_REGION" --log-group-name <group>
Fix
CloudWatch allows 2 subscription filters per log group. Remove one you no longer need, or leave that group out of EPOK_LOG_GROUPS.

4. No data: Firehose cannot deliver to Epok

Seen as
seen_at stays null and requests_24h is 0.
Check
aws logs filter-log-events --region "$AWS_REGION" --log-group-name /aws/kinesisfirehose/epok-logs --limit 5 --query 'events[].message' --output text
Fix
The delivery-error log shows Epok's error message as sent. 401 or 403: the key is wrong or lacks the ingest scope; create a new key and update the EpokApiKey stack parameter. 413: set the Firehose buffer to 4 MB or less.

5. Slow: delivery works but the canary has not arrived yet

Seen as
seen_at stays null and requests_24h is above 0.
Check
curl -fsS -H "X-API-Key: $EPOK_API_KEY" "https://ingest.epok.cloud/api/v1/integrations/status?source=aws_firehose_logs"
Fix
The canary is still in the Firehose buffer. Wait one more buffer interval, then run bash aws-logs.sh --verify-only.

If Epok is briefly unable to accept a delivery, Firehose retries it and then keeps it in the S3 bucket, so no data is lost.

Remove

bash
bash aws-logs.sh --uninstall

This deletes the stack only if it is tagged managed-by=epok. CloudFormation removes the subscription filters and the metric stream before the Firehose streams, so nothing is left sending to a deleted stream. Then the script empties and removes the S3 bucket the stack retained. Undelivered data in that bucket is deleted. Revoke the API key in Settings, then API Keys when you no longer need it.

For AI agents

The setup is published as a machine-readable manifest with every step, its idempotency check, the data check, the failure modes and the uninstall: https://epok.cloud/setup/aws/aws-logs-firehose-cfn.json. The same steps as an Agent Skill: https://epok.cloud/setup/aws/aws-logs-firehose-cfn/SKILL.md. Rules for unattended setup and the final report format: https://epok.cloud/setup/AGENT-GUIDE.md. The script above is generated from the same manifest. An agent running it must:

  • Ask a human for EPOK_API_KEY. Never create, guess, print, or write the key to a file or a commit.
  • Stop and ask on AccessDenied. Never grant IAM permissions to itself.
  • Stop and ask when a stack with the same name exists. Never delete or reuse a stack it did not create.
  • Stop and ask before an account-level subscription policy (every log group), every metric namespace, more than one region, or an estimated cost above $5/day.
  • Stop and ask when a log group already has 2 subscription filters.
  • Run the uninstall only when the user asked for removal.

Traces: use OpenTelemetry

Send traces from Lambda, ECS, EKS or EC2 with OpenTelemetry over OTLP, not through Firehose. See Send traces.

Logs that are not in CloudWatch

For log files on an EC2 or ECS host, run Vector and point it at Epok. Set EPOK_API_KEY in /etc/default/vector, then systemctl enable --now vector. Vector runs as the vector user and needs read access to the files.

yaml
# /etc/vector/vector.yaml: EC2 host files to Epok
sources:
  app:
    type: file
    include: ["/var/log/syslog", "/var/log/nginx/*.log", "/var/log/myapp/*.log"]

transforms:
  add_host:
    type: remap
    inputs: [app]
    source: |
      .host = get_hostname!()

sinks:
  epok:
    type: elasticsearch
    inputs: [add_host]
    endpoints: ["https://ingest.epok.cloud"]
    bulk:
      index: logs
    api_version: v8        # required: do not let Vector sniff the version
    healthcheck:
      enabled: false
    auth:
      strategy: basic
      user: ${EPOK_API_KEY}
      password: x

Because the health check is off, Vector starts cleanly with a wrong key. A rejected key shows up only as sink errors in journalctl -u vector -f.

For container logs, add the aws-for-fluent-bit image as an ECS sidecar or an EKS DaemonSet. Set Log_Level debugto see Epok's response if delivery fails.

ini
# fluent-bit.conf: ECS / EKS container logs to Epok
[INPUT]
    Name              tail
    Path              /var/log/containers/*.log
    Parser            cri
    Tag               kube.*

[OUTPUT]
    Name              loki
    Match             *
    Host              ingest.epok.cloud
    Port              443
    TLS               On
    HTTP_User         ${EPOK_API_KEY}
    HTTP_Passwd       x
    Labels            cluster=${ECS_CLUSTER}, task=${ECS_TASK_FAMILY}
    drop_single_key   on

Both send the key as HTTP Basic with the key as the username. A 403 means the key was read and refused (wrong, expired, or no ingest scope); a 401 means no key was read. See authentication.

Next

  • Kubernetes: for EKS node and pod metrics with a DaemonSet.
  • Search syntax: query the logs you just routed.
  • Detectors: what starts watching these logs automatically.
  • Notification channels (Settings, then Notifications), so your alert rules can notify you when something breaks.