# Fluent Bit

**Status:** the Fluent Bit HTTP output below is not yet available on Epok's hosted service. On the hosted service, use Fluent Bit's Elasticsearch output.

## Hosted service: Elasticsearch output

Fluent Bit's `es` output sends Elasticsearch bulk requests, which the hosted service accepts. Authenticate with basic auth: your ingest key as the user and any password. Set `EPOK_INGEST_KEY` in the Fluent Bit environment. The line text Fluent Bit's tail input puts in `log` is stored as the message.

```
[OUTPUT]
    Name               es
    Match              *
    Host               ingest.epok.cloud
    Port               443
    tls                On
    HTTP_User          ${EPOK_INGEST_KEY}
    HTTP_Passwd        x
    Suppress_Type_Name On
    Retry_Limit        False
```

Fluent Bit sends logs to `POST /api/v1/fluent` as JSON. Use an Epok ingest key in the `X-API-Key` header. The key determines the workspace and project; the optional `tag` query parameter supplies a service name.

## Local log configuration

```
[SERVICE]
    Flush 1
[INPUT]
    Name tail
    Path /var/log/my-app.log
    Tag app.logs
[OUTPUT]
    Name http
    Match app.logs
    Host localhost
    Port 3100
    URI /api/v1/fluent?tag=my-app
    Format json
    Compress gzip
    Json_Date_Key date
    Json_Date_Format double
    Header X-API-Key EPOK_INGEST_KEY
    Retry_Limit false
```

Use your Epok ingest host with port 443 and `Tls On` outside local development. Keep `Format json`: the default MessagePack format is not accepted. Log text, timestamps, levels and supported Kubernetes metadata follow the existing Fluent Bit ingest path.

## Metrics

Metrics use `POST /api/v1/write` on the metrics gateway (local port 8080). Pair a metrics input such as`prometheus_scrape` with this output. A log input does not produce metric samples.

```
[OUTPUT]
    Name prometheus_remote_write
    Match app.metrics
    Host localhost
    Port 8080
    URI /api/v1/write
    Header X-API-Key EPOK_INGEST_KEY
    Retry_Limit false
```
