
Kiro usage analytics on your own Grafana, with Docker Compose, OpenTelemetry and Prometheus
Self-host Kiro’s daily OpenTelemetry usage export with Docker Compose: Caddy TLS, a collector that hashes user IDs, Prometheus and a Grafana dashboard that flags missing days. Includes a simulator, so you can test before the first real export.
Kiro can send your team's usage to an OpenTelemetry endpoint once a day. The data is useful: credits, messages, conversations and the model behind each message, for every user and client type. But the export has no viewer of its own. It sends to an endpoint that you provide, and it has rules about that endpoint. It must be on the public internet, behind a hostname and a certificate from a public authority, and it must accept one bearer token. If something goes wrong, there is no error message and no second try tomorrow.
This article builds that endpoint and a dashboard behind it, with tools you may already run. Caddy terminates TLS. An OpenTelemetry Collector checks the token, removes e-mail addresses, hashes user IDs and converts the counters. Prometheus keeps two years of history. Grafana shows ten panels, including one that tells you when a day of data is missing. All of it runs in one Docker Compose file, and a simulator lets you test every step before Kiro's first real export.

A note on scope. The Kiro facts in this article come from Kiro's documentation, which was current when I wrote this. I did not have a Kiro enterprise export to test against. The Compose file passed
docker compose config , and the collector, Prometheus and Grafana files were checked for syntax only. The simulator ran against a mock receiver that decoded its requests. Run each stage and compare it with the description here. The dashboard images use illustrative data.Already using Amazon CloudWatch? Kiro can send straight to CloudWatch with a bearer API key, and two other posts cover that route and the analysis on top of it: Turn Kiro's usage telemetry into answers, not just numbers on AWS Builder Center, and an export-and-PromQL walkthrough on Classmethod . This article is for the case where you want the data in a store and a Grafana that you control, with the privacy filtering done before storage.
What you need
- A Kiro administrator who can open Settings in the Kiro console. The documentation says an administrator configures the export and users cannot. It does not say which plans include it, so check yours.
- An AWS account with the permissions that Kiro's documentation lists for administrators, and AWS CLI v2.
- A Linux host with Docker Engine and Docker Compose v2.24 or later. I use an Amazon EC2 instance in the walkthrough. Ports 80 and 443 must be open to the internet.
- A DNS name that points to the host.
- About an hour, and the next 02:00 UTC for the first real data.
Everything below lives in one repository. Clone it from github.com/jubins/kiro-usage-observability :
git clone https://github.com/jubins/kiro-usage-observability.gitcd kiro-usage-observabilitykiro-usage-observability/├── docker-compose.yaml├── Caddyfile├── otel-collector.yaml├── prometheus.yml├── .env.example├── grafana/│ ├── provisioning/datasources/prometheus.yaml│ ├── provisioning/dashboards/kiro.yaml│ └── dashboards/kiro-usage.json├── simulator/│ ├── requirements.txt│ └── send_kiro_metrics.py├── aws/│ ├── kms-key-policy.json│ └── secret-resource-policy.json└── scripts/create-kiro-secret.shWhat Kiro sends
Kiro sends daily aggregate metrics for each user. The export runs once a day at 02:00 UTC and sends the previous day's activity. All five metrics are monotonic OTLP counters in the
kiro.daily.* namespace.Metric | Meaning |
|---|---|
kiro.daily.credits | Credits used |
kiro.daily.overage_credits | Overage credits used |
kiro.daily.messages | Total messages |
kiro.daily.conversations | Chat conversations |
kiro.daily.model_messages | Messages per model |
Every datapoint carries attributes. These are the ones that this article uses.
Attribute | Notes |
|---|---|
kiro.user.id | IAM Identity Center user ID. Always present |
kiro.user.email | Present when the directory lookup works |
kiro.client.type | For example KIRO_IDE , KIRO_CLI or PLUGIN |
date | Activity date in UTC |
kiro.model.name | Only on kiro.daily.model_messages |
kiro.subscription.tier , kiro.usage.limit , kiro.overage.enabled , kiro.overage.cap | Present when set |
The resource attributes include
service.name = kiro-enterprise and the profile and account IDs.Four behaviors of the export shape the design. Kiro retries up to three times per activity date and then leaves a gap. It does not backfill and does not send a notification. It does not deduplicate on its side, and the collector must not either, so a re-export can duplicate datapoints. And the documentation does not state whether the counters are delta or cumulative, so the pipeline has to work with both.
The
date attribute deserves a picture, because it breaks the usual way of charting counters.
A normal Prometheus dashboard plots a counter against the time that it was sampled. Here the sample time is the day after the activity, and the series disappears from the collector after a while. The only reliable way to say which day the usage belongs to is the
date label, so every panel in this article groups by it.Design decisions
A collector of your own, not a SaaS endpoint. Kiro lists Honeycomb, Elastic, OpenSearch, Datadog and CloudWatch as examples, and any of them works. A collector you run gives you one place to filter personal data before it is stored, and it costs one small host. The price is that you own the TLS certificate and the uptime of the endpoint, and uptime matters because Kiro does not resend.
HTTP/protobuf behind Caddy, not gRPC. Kiro supports both. HTTP needs no special proxy settings, and Caddy gets and renews a Let's Encrypt certificate by itself, which satisfies the "publicly trusted certificate and hostname" rule. The documentation examples are not consistent about whether the endpoint contains
/v1/metrics , so the Caddyfile accepts a POST on any path and always forwards it to the collector's metrics path. That avoids a silent failure that I cannot test from here.The token is checked by the collector. The secret holds exactly one header,
Authorization=Bearer <token> . The bearertokenauth extension on the receiver rejects everything else. Caddy only handles TLS, so the collector does not need to be reachable from the internet except through it.Privacy filtering before storage. The export includes user IDs and e-mail addresses. The collector deletes the e-mail address and replaces the ID with a short hash. A failed statement drops the data, because storing an unfiltered record is worse than losing one.
Group by
date , take max_over_time . Each series is one user, one client and one date, and it receives one value. max_over_time over the dashboard range returns that value no matter when the series was alive, and tolerates the series disappearing from the collector.Grafana is never public. It binds to
127.0.0.1 and you reach it with an AWS Systems Manager port forward. The host needs no SSH port.Step 1: Run the stack locally
Start with the three containers and the simulator. You do not need Kiro, an AWS account or a domain name for this step.
The Compose file has four services and two profiles. Caddy is in the
edge profile and is started only on the internet-facing host. The simulator is in the test profile.name: kiro-telemetry
services: # Public edge. Terminates TLS with an automatic Let's Encrypt certificate and forwards to the collector. # Start it only on the internet-facing host: docker compose --profile edge up -d caddy: profiles: ["edge"] image: caddy:2 restart: unless-stopped environment: KIRO_OTLP_HOST: ${KIRO_OTLP_HOST:?Set KIRO_OTLP_HOST in .env} ports: - "80:80" - "443:443" volumes: - ./Caddyfile:/etc/caddy/Caddyfile:ro - caddy_data:/data depends_on: - otel-collector
otel-collector: image: ${OTELCOL_IMAGE:-otel/opentelemetry-collector-contrib:latest} restart: unless-stopped command: ["--config=/etc/otelcol/config.yaml"] environment: KIRO_OTLP_TOKEN: ${KIRO_OTLP_TOKEN:?Set KIRO_OTLP_TOKEN in .env} volumes: - ./otel-collector.yaml:/etc/otelcol/config.yaml:ro ports: # Loopback only, for the local simulator. The public path goes through Caddy. - "127.0.0.1:4318:4318"
prometheus: image: prom/prometheus:latest restart: unless-stopped command: - --config.file=/etc/prometheus/prometheus.yml - --storage.tsdb.path=/prometheus - --storage.tsdb.retention.time=730d volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro - prometheus_data:/prometheus ports: - "127.0.0.1:9090:9090" depends_on: - otel-collector
grafana: image: grafana/grafana-oss:latest restart: unless-stopped environment: GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_ADMIN_PASSWORD:?Set GRAFANA_ADMIN_PASSWORD in .env} GF_USERS_ALLOW_SIGN_UP: "false" GF_ANALYTICS_REPORTING_ENABLED: "false" volumes: - ./grafana/provisioning:/etc/grafana/provisioning:ro - ./grafana/dashboards:/var/lib/grafana/dashboards:ro - grafana_data:/var/lib/grafana ports: - "127.0.0.1:3000:3000" depends_on: - prometheus
# Sends synthetic kiro.daily.* metrics so you can test the whole path before Kiro's 02:00 UTC export runs. sender: profiles: ["test"] image: python:3.12-slim environment: OTEL_EXPORTER_OTLP_ENDPOINT: ${SENDER_ENDPOINT:-http://otel-collector:4318} OTEL_EXPORTER_OTLP_HEADERS: Authorization=Bearer ${KIRO_OTLP_TOKEN:?Set KIRO_OTLP_TOKEN in .env} OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: ${SENDER_TEMPORALITY:-delta} SIM_DAYS: ${SIM_DAYS:-7} SIM_USERS: ${SIM_USERS:-6} volumes: - ./simulator:/app:ro command: > sh -c "pip install -q --no-cache-dir -r /app/requirements.txt && python /app/send_kiro_metrics.py" depends_on: - otel-collector
volumes: caddy_data: prometheus_data: grafana_data:The collector configuration is the center of the design.
extensions: # Kiro sends one header from the secret: Authorization=Bearer <token>. # The receiver rejects any request that does not carry it. bearertokenauth/kiro: scheme: Bearer token: ${env:KIRO_OTLP_TOKEN}
receivers: otlp: protocols: http: endpoint: 0.0.0.0:4318 auth: authenticator: bearertokenauth/kiro
processors: memory_limiter: check_interval: 1s limit_mib: 256
# Remove the email address and replace the user ID with a short hash before anything is stored. # error_mode: propagate makes a failed statement drop the data instead of storing it unfiltered. transform/privacy: error_mode: propagate metric_statements: - context: datapoint statements: - delete_key(attributes, "kiro.user.email") - set(attributes["kiro.user.id"], Substring(SHA256(attributes["kiro.user.id"]), 0, 12)) where attributes["kiro.user.id"] != nil
# The Prometheus exporter serves cumulative values only. If Kiro sends delta counters, # this converts them. Each series carries its own "date" attribute, so each one receives one datapoint. deltatocumulative: max_stale: 72h
batch: timeout: 5s
exporters: prometheus: endpoint: 0.0.0.0:8889 # Kiro sends once a day. The default expiration is 5 minutes, which would hide the series almost at once. metric_expiration: 72h
debug: verbosity: detailed
service: extensions: [bearertokenauth/kiro] pipelines: metrics: receivers: [otlp] processors: [memory_limiter, transform/privacy, deltatocumulative, batch] exporters: [prometheus, debug]Three lines in it come from problems I would otherwise have hit on the first day:
-
metric_expiration: 72hon the Prometheus exporter. The default is five minutes. Kiro sends once a day, so with the default the series would be gone before Prometheus could scrape it a few times.
-
deltatocumulativewithmax_stale: 72h. The Prometheus exporter serves cumulative values only. If Kiro sends deltas, the processor adds them up. Each series has its owndateattribute and receives one datapoint, so the sums stay correct. A re-export of the same day would double a delta series. That is the one case that this pipeline does not protect against, and the dashboard's "Days with data" panel helps you notice it.
-
error_mode: propagatein the privacy transform, which I described above.
Prometheus needs one scrape target. Its two-year retention is set by a flag in the Compose file.
global: scrape_interval: 60s
scrape_configs: - job_name: otel-collector static_configs: - targets: ["otel-collector:8889"]Create the environment file and start the stack.
cp .env.example .env# Set KIRO_OTLP_TOKEN (openssl rand -hex 32) and GRAFANA_ADMIN_PASSWORD in .env
docker compose up -dThe simulator sends seven days of fake activity for several users, with the names and attributes from the documentation. Its fake e-mail addresses end in
example.com .docker compose --profile test run --rm senderVerify. Check that the containers run, that the metrics arrived and that the privacy filter worked.
docker compose pscurl -s 'http://localhost:9090/api/v1/label/__name__/values' | grep -o 'kiro_[a-z_]*'docker compose logs otel-collector | grep -i -E 'temporality|kiro.user' | headThe second command should list
kiro_daily_credits_total , kiro_daily_messages_total and the other counters. I expect the _total suffix because the exporter adds it to monotonic sums, but I have not seen it with this stack. If your names differ, change them in grafana/dashboards/kiro-usage.json before you go on. The third command should show the temporality that the simulator used, and the user IDs should be 12-character hashes, not fake-user-000 . No kiro.user.email should appear in the stored data. Then run the simulator again with SENDER_TEMPORALITY=cumulative and check that the same panels work.

Step 2: Read the dashboard
Grafana reads its configuration from files, so the dashboard exists as soon as the container starts. The data source file points at Prometheus and the provider file loads
grafana/dashboards/kiro-usage.json into a Kiro folder.apiVersion: 1datasources: - name: Prometheus uid: prometheus type: prometheus access: proxy url: http://prometheus:9090 isDefault: trueapiVersion: 1providers: - name: Kiro folder: Kiro type: file disableDeletion: true allowUiUpdates: false options: path: /var/lib/grafana/dashboardsThe dashboard has ten panels. Each one is a short PromQL expression, and every one of them uses
max_over_time over $__range .Panel | PromQL |
|---|---|
Credits in range | sum(max_over_time(kiro_daily_credits_total[$__range])) |
Messages in range | sum(max_over_time(kiro_daily_messages_total[$__range])) |
Active users | count(count by (kiro_user_id) (max_over_time(kiro_daily_messages_total[$__range]))) |
Credits per message | credits divided by messages, both as above |
Days with data | count(count by (date) (max_over_time(kiro_daily_messages_total[$__range]))) |
Users with overage | count(sum by (kiro_user_id) (max_over_time(kiro_daily_overage_credits_total[$__range])) > 0) |
Credits per activity day | sum by (date) (max_over_time(kiro_daily_credits_total[$__range])) |
Credits by client type | sum by (kiro_client_type) (max_over_time(kiro_daily_credits_total[$__range])) |
Messages by model | sum by (kiro_model_name) (max_over_time(kiro_daily_model_messages_total[$__range])) |
Top 10 users by credits | topk(10, sum by (kiro_user_id) (max_over_time(kiro_daily_credits_total[$__range]))) |
"Days with data" is the panel that I would not do without. Kiro leaves a gap when all three attempts fail, and nothing else tells you. If the range is 14 days and the panel says 13, one day is missing.
Verify. Open
http://localhost:3000 , sign in as admin with your password and open the Kiro folder. After the simulator ran, the stat panels and the bar charts should show values, and the table should list hashed user IDs. Set the time range to a period that is longer than the simulator's days, and "Days with data" should still show the number of days that you sent.

Step 3: Create the secret that Kiro reads
Kiro stores only the ARN of a Secrets Manager secret. At each export it reads the endpoint and the header from that secret. The documentation requires three things: a customer managed KMS key (the default
aws/secretsmanager key does not work), a key policy that lets Kiro decrypt through Secrets Manager, and a resource policy on the secret that lets Kiro read it. The key, the secret and your Kiro profile must be in the same Region.The two policy templates have placeholders for your account and Region.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "EnableIAMPolicies", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::__ACCOUNT_ID__:root" }, "Action": "kms:*", "Resource": "*" }, { "Sid": "AllowKiroDecryptViaSecretsManager", "Effect": "Allow", "Principal": { "Service": "q.amazonaws.com" }, "Action": ["kms:Decrypt", "kms:DescribeKey"], "Resource": "*", "Condition": { "StringEquals": { "kms:ViaService": "secretsmanager.__REGION__.amazonaws.com" } } } ]}{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowKiroGetSecretValue", "Effect": "Allow", "Principal": { "Service": "q.amazonaws.com" }, "Action": "secretsmanager:GetSecretValue", "Resource": "*" } ]}The script creates the key, applies the policy, creates the secret and attaches the resource policy.
put-key-policy replaces the whole policy, which is why the template keeps the account root statement. Without it you can lock yourself out of the key.export AWS_REGION=us-east-1export KIRO_OTLP_HOST=otel.example.comexport KIRO_OTLP_TOKEN=$(grep ^KIRO_OTLP_TOKEN .env | cut -d= -f2)
./scripts/create-kiro-secret.shThe script prints the secret ARN. The secret value is written to a file with mode 600 for the call and then deleted.
Now enable the export. In the AWS console open the Kiro console, choose Settings, then under Kiro user activity reports choose Edit. Select the OpenTelemetry (OTel) format, enter the secret ARN, select HTTP/protobuf and choose Enable. Saving does not send anything. The first export runs at the next 02:00 UTC. Choosing the wrong protocol for an endpoint prevents delivery silently, so check that you chose HTTP/protobuf.
Step 4: Put the stack on the internet
Use a small Linux host that can reach the internet. The steps I used on Amazon EC2:
- Launch an Amazon Linux 2023 instance with an Elastic IP address. Give it an instance profile with the
AmazonSSMManagedInstanceCoremanaged policy.
- Open ports 80 and 443 to the internet in the security group. Do not open port 22. Kiro does not publish source addresses that I could find, so you cannot restrict these ports to them, and the bearer token is the control.
- Create an A record for
KIRO_OTLP_HOSTthat points to the Elastic IP address. Caddy needs the record in place to get a certificate.
- Connect with Session Manager, then install Docker and the Compose plugin.
sudo dnf install -y docker gitsudo systemctl enable --now dockersudo mkdir -p /usr/local/lib/docker/cli-pluginssudo curl -SL https://github.com/docker/compose/releases/latest/download/docker-compose-linux-aarch64 \ -o /usr/local/lib/docker/cli-plugins/docker-composesudo chmod +x /usr/local/lib/docker/cli-plugins/docker-composeUse
x86_64 in the file name on an Intel instance. Then clone the repository, create .env with the same token that is in the secret, set KIRO_OTLP_HOST , and start the stack with the edge profile.docker compose --profile edge up -dThe Caddyfile is short. The
rewrite line is the one that makes the endpoint path in the secret irrelevant.# Kiro posts OTLP/HTTP metrics to the endpoint stored in the Secrets Manager secret.# The documentation examples for some destinations include /v1/metrics in the endpoint and others do not,# so this route accepts a POST on any path and always forwards it to the collector's metrics path.{$KIRO_OTLP_HOST} { @export method POST handle @export { rewrite * /v1/metrics reverse_proxy otel-collector:4318 } handle { respond "not found" 404 }}Verify. Test the endpoint from your laptop with and without the token. The first request should be refused and the second one accepted. An empty body is a valid, empty OTLP request.
curl -s -o /dev/null -w '%{http_code}\n' -X POST "https://$KIRO_OTLP_HOST/v1/metrics"curl -s -o /dev/null -w '%{http_code}\n' -X POST "https://$KIRO_OTLP_HOST/v1/metrics" \ -H "Authorization: Bearer $KIRO_OTLP_TOKEN" -H 'Content-Type: application/x-protobuf' --data-binary ''Then send the simulator through the real path, from the host or from your laptop, to prove that TLS, the token and the rewrite all work together.
SENDER_ENDPOINT=https://$KIRO_OTLP_HOST:443 docker compose --profile test run --rm senderReach Grafana with a port forward, not with a public port.
aws ssm start-session --target <instance-id> --document-name AWS-StartPortForwardingSession \ --parameters '{"portNumber":["3000"],"localPortNumber":["3000"]}'Step 5: Wait for the first real export
The first export runs at the next 02:00 UTC after you enabled it, and it carries the previous day. Before then, delete the simulator's data so that fake users do not mix with real ones:
docker compose down -vdocker compose --profile edge up -dAfter 02:00 UTC, check the collector log and the dashboard.
docker compose logs otel-collector --since 3h | grep -E 'kiro.daily|Resource attributes' | headYou should see
service.name: kiro-enterprise and datapoints with your users' hashed IDs. If nothing arrived, use this table before you suspect the pipeline.Symptom | First thing to check |
|---|---|
Nothing in the log | The key, the secret and the Kiro profile are in one Region. q.amazonaws.com has secretsmanager:GetSecretValue on the secret and kms:Decrypt and kms:DescribeKey on the key |
Nothing, and no error anywhere | The protocol in the console matches the endpoint, the certificate is publicly trusted, and the endpoint is a hostname |
401 in the Caddy or collector log | The token in the secret and in .env are identical |
Data arrives, panels are empty | The metric names in Prometheus match the dashboard JSON |
One day is missing | Kiro tried three times and does not backfill. Nothing to fix |
Production considerations
Security. The endpoint is public by requirement, so the token is the only control. Generate it with
openssl rand -hex 32 , keep it in .env and in the secret, and rotate it by changing both. Kiro reads the secret at each export, so a rotation takes effect at the next 02:00 UTC, and the old token should stay valid in the collector until then. The collector never stores the e-mail address, and the ID is hashed. For a small team a hash does not hide who is who, so also limit who can open the dashboard.Privacy. Datapoints can contain user IDs and e-mail addresses. Decide how long to keep them. The Compose file keeps 730 days. Lower
--storage.tsdb.retention.time if your policy asks for less.Cardinality. Each series is one user, client type and date, and a new set appears every day. For 200 users with an average of 1.5 client types, the four per-user metrics create about 200 × 1.5 × 4 = 1,200 series per day, and
kiro.daily.model_messages adds one per model. With five models that is another 1,500, so about 2,700 new series per day and roughly one million per year. That is a small Prometheus, and each series holds a single value, but plan for it before you add labels.Cost. The stack runs on one small instance. I have not measured it, so check the current EC2, Elastic IP and data transfer prices for your Region. Secrets Manager and KMS charges are small and fixed.
Reliability. The endpoint must be up at 02:00 UTC, because there is no backfill. Run Compose with
restart: unless-stopped (set in the file), use an Elastic IP so the address survives a stop, and alert on "Days with data". A second host would need a way to share the same Prometheus, which this article does not cover.Clean up
docker compose --profile edge --profile test down -vDisable the export in the Kiro console first, so that Kiro stops sending to a host that no longer exists. Then delete the secret and schedule the key for deletion, release the Elastic IP, terminate the instance and delete the DNS record.
aws secretsmanager delete-secret --secret-id kiro/otel-export --region $AWS_REGIONaws kms schedule-key-deletion --key-id <key-id> --pending-window-in-days 7 --region $AWS_REGIONCheck the Billing dashboard afterwards.
Limits
This is a daily, per-user report. It cannot tell you what a session did, how long a task took or which spec was involved, and it cannot show anything from today. The export is an administrator feature, so individual developers cannot use it. The Compose stack is one host with no high availability. The metric names, the OTTL statements and the Kiro-side behavior were not run against a real export in the version of the stack that this article describes.
Where this leaves you
You have an endpoint that Kiro can send to, a filter that keeps personal data out of storage, two years of history and a dashboard that says when it is missing a day. The next step is a real export: enable it, wait for 02:00 UTC and check the first day against the Kiro console.
References
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article