summaryrefslogtreecommitdiff
path: root/docs/guides/dtail-metrics-example.md
blob: 5416726a0e1d9c2f11ebce846224c3099ba6b797 (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
# Dtail Metrics Example

This page walks through using Epimetheus watch mode with a CSV that could come from a tool like [Dtail](https://dtail.dev/) or any similar log/aggregation export.

## Scenario

You have a CSV file (e.g. `dtail.csv`) with columns that mix numeric stats and identifiers (host, service, etc.). You want to turn those into Prometheus metrics so you can graph them in Grafana.

## Steps

1. **Ensure the CSV has a header row**  
   First line = column names. Epimetheus will sanitize them for use as metric names and labels.

2. **Identify numeric vs string columns**  
   - Numeric columns (e.g. `count`, `avg_latency_ms`, `p99`) become metric values.
   - String columns (e.g. `host`, `service`, `region`) become labels.

3. **Run watch mode** with a base metric name and your Prometheus (or Prometheus-compatible) write URL:

   ```bash
   ./epimetheus -mode=watch \
       -file=dtail.csv \
       -metric-name=dtail \
       -prometheus=http://localhost:9090/api/v1/write
   ```

4. **Optional: resolve IPs to hostnames**  
   If one of your label columns contains IPs (e.g. `host` or `ip`), you can resolve them:

   ```bash
   ./epimetheus -mode=watch \
       -file=dtail.csv \
       -metric-name=dtail \
       -prometheus=http://localhost:9090/api/v1/write \
       -resolve-ip-labels=host
   ```

5. **Query in Prometheus / Grafana**  
   Metrics will appear as `dtail_<column_name>` with your string columns as labels, e.g.:

   ```promql
   dtail_avg_latency_ms{service="api", region="eu"}
   ```

## References

- [CSV Format Flexibility](csv-format-flexibility.md) – how column types and names are interpreted.
- [DNS Resolution](dns-resolution.md) – IP-to-hostname resolution.
- [Operating Modes](modes.md) – all watch mode options.