Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.costory.io/llms.txt

Use this file to discover all available pages before exploring further.

Connect Tsuga usage metrics to Costory when you want to divide cloud cost by requests, errors, latency, or another telemetry signal. Costory imports Tsuga metrics, log aggregations, and trace aggregations so you can build reports from the same data you use for observability.
Before you begin, make sure you have:
  • A Tsuga account with at least one metric, log stream, or trace
  • Permissions to create Operation API Keys in your Tsuga workspace

What You Provide

Operation API Key

A Bearer token scoped to read metrics and run aggregations.

Metric or Query Config

The metric names and aggregation you want to import.

Setup Steps

1

Create an Operation API Key in Tsuga

Go to Settings > API Keys in the Tsuga app and create a new key with the Operation type. Copy the key. It is only shown once.
2

Add Tsuga as a data source in Costory

Navigate to Settings > Data Sources > Add New and select Tsuga.
3

Enter your API key

Paste your Operation API Key. Costory uses it as a Bearer token against https://api.tsuga.com.
4

Browse available metrics

Costory calls GET /v1/metrics to list all metrics in your workspace. Select the metrics you want to import.
5

Configure your aggregation

For each metric, choose an aggregation type: sum, average, max, min, count, or percentile. You can also add an optional group-by field, such as service or env.
6

Set the import schedule

Choose how often Costory should pull updated data. Daily imports are recommended for cost correlation.

How Costory Queries Tsuga

Costory uses two Tsuga endpoints depending on the chart type:
Use caseEndpoint
Single aggregated value over a periodPOST /v1/aggregation/multi-query/scalar
Time series for trend chartsPOST /v1/aggregation/multi-query/timeseries
Both endpoints support metrics, logs, and traces as data sources. You can import raw metrics or aggregations derived from logs and traces, such as HTTP errors per minute from logs or p99 latency from traces.

Example: query API call count as a time series

POST https://api.tsuga.com/v1/aggregation/multi-query/timeseries
Authorization: Bearer <your-operation-api-key>

{
  "dataSource": "metrics",
  "timeRange": { "from": 1704067200, "to": 1706745600 },
  "aggregationWindow": "1h",
  "queries": [
    {
      "aggregate": { "type": "sum", "metric": "http.request.count" }
    }
  ],
  "groupBy": [
    { "fields": ["service"], "limit": 20 }
  ]
}

Supported Data Sources

Metrics

Standard time series metrics, including counters, gauges, and histograms.

Logs

Aggregations computed from log streams, such as error rate.

Traces

Aggregations computed from distributed traces, such as p99 latency.

FAQ

Tsuga has two key types: Ingestion keys are write-only and send data to Tsuga. Operation keys are read-only and query data. Costory needs an Operation key to call the public API.
Yes. The aggregation endpoints support "dataSource": "logs" and "dataSource": "traces". You can define any aggregation Tsuga supports, and Costory treats the result as a usage metric.
Yes. Use the filter field in the query body with Tsuga’s query syntax, such as service:my-service AND env:production, to scope the metric to part of your infrastructure.
Tsuga’s GET /v1/metrics endpoint returns all metric names with their metadata. You can also browse the API reference at app.tsuga.com/swagger.
You typically see data within a few minutes of the first successful sync. Historical backfill depends on the retention configured in your Tsuga workspace.

Next Steps

Build Unit Economics

Divide cloud costs by Tsuga metrics to track cost per request, cost per user, and other per-unit metrics.

Connect Events

Add deploys and incidents to correlate with metric changes.
Last modified on May 12, 2026