summaryrefslogtreecommitdiff
path: root/docs/guides/csv-format-flexibility.md
blob: 180dc28fc88862e6d152bb974856e2bdbfdcfd9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# CSV Format Flexibility

Watch mode works with **any tabular CSV**. You do not need a fixed schema; Epimetheus infers metric names and labels from column headers and value types.

## How It Works

- **First row:** Column headers (automatically sanitized for Prometheus label/metric names).
- **Numeric columns:** Treated as metric values. Each gets a metric name derived from the base metric name and the column header.
- **String columns:** Treated as labels. Each row’s value becomes the label value for that series.
- **Metric name:** Set with `-metric-name` (e.g. `web`, `food`, `network`). It is used as a prefix for all numeric columns.

Column names can contain characters that are invalid in Prometheus (e.g. parentheses, spaces). They are sanitized: for example `min(potatoes)` becomes a valid metric suffix like `min_potatoes`.

## Examples

### Web metrics

```csv
avg(response_time),p99(latency),endpoint,method
45.2,120.5,/api/users,GET
52.1,135.8,/api/orders,POST
```

With `-metric-name=web` this produces series such as:

- `web_avg_response_time{endpoint="/api/users",method="GET"} 45.2`
- `web_p99_latency{endpoint="/api/users",method="GET"} 120.5`
- `web_avg_response_time{endpoint="/api/orders",method="POST"} 52.1`
- `web_p99_latency{endpoint="/api/orders",method="POST"} 135.8`

### Food / business metrics

```csv
min(potatoes),last(coke),avg(price),country,store_type
5.2,10.5,12.99,USA,grocery
3.8,8.2,9.99,Canada,convenience
```

With `-metric-name=food` this produces series such as:

- `food_min_potatoes{country="USA",store_type="grocery"} 5.2`
- `food_last_coke{country="USA",store_type="grocery"} 10.5`
- `food_avg_price{country="USA",store_type="grocery"} 12.99`
- and the same metrics with `country="Canada",store_type="convenience"`.

### Summary

- Each **row** becomes one or more samples (one per numeric column).
- **Numeric columns** → different metrics (same labels for that row).
- **String columns** → labels shared by all those metrics for that row.

For the standard Epimetheus CSV format (explicit metric name, labels, value, timestamp) see [Data Formats](data-formats.md). For modes and watch options see [Operating Modes](modes.md).