# Send logs over HTTP

Post logs as JSON from any script, language or tool that can make an HTTPS request.

When nothing else fits (a shell script, a batch job, a device, a tool with webhooks), post logs straight to Flowhawk. One endpoint takes a JSON object, a JSON array or newline-delimited JSON.

## What you get

- Your logs in [Logs](https://flowhawk.dev/docs/signals#logs), next to your traces and metrics, searchable with the same query language (`severity>=WARN service=checkout "timeout"`), grouped into patterns or followed live.
- A log line that names a request path joins the [business flow](https://flowhawk.dev/docs/flows) of that route, so a failing checkout shows these logs on the checkout flow's page.
- A line that carries a trace id opens its trace.
- Alert on any search with **Alert on this**, and let the agent read these logs when it investigates an incident.

## Send a log

First create an ingest key: in the app, open **Settings > API keys** and pick **Services**. In the examples below, `KEY` stands for that key. Keep it out of your repository, like any other secret.

```
curl -X POST "https://api.flowhawk.dev/v1/logs/json?service=billing-job" \
  -H "Authorization: Bearer KEY" \
  -d '{"message":"payment declined","level":"error","path":"/api/checkout","trace_id":"4bf92f3577b34da6a3ce929d0e0e4736"}'
```

Several at once, as an array or one object per line:

```
[{"message":"run started","level":"info"},{"message":"3 rows skipped","level":"warn","rows":3}]
```

### From Python

```
import os, requests
requests.post(
    "https://api.flowhawk.dev/v1/logs/json?service=billing-job",
    json=[{"message": "run finished", "level": "info", "rows": 1204}],
    headers={"Authorization": f"Bearer {os.environ['FLOWHAWK_KEY']}"},
    timeout=10,
).raise_for_status()
```

### From Node.js

```
await fetch("https://api.flowhawk.dev/v1/logs/json?service=billing-job", {
  method: "POST",
  headers: { "content-type": "application/json", authorization: `Bearer ${process.env.FLOWHAWK_KEY}` },
  body: JSON.stringify([{ message: "run finished", level: "info", rows: 1204 }]),
});
```

## How fields are read

- The log line: `message`, `msg`, `log` or `body`.
- Its severity: `level`, `severity` or `lvl`. Names like `warning` and pino's numbers both work.
- Its time: `timestamp`, `time`, `ts`, `@timestamp` or `date`, as a date string or as seconds, milliseconds or nanoseconds since 1970.
- The service: `service`, `service.name`, `app`, `kubernetes.container_name` or `container_name`, unless `?service=` names it.
- A link to its trace: `trace_id` or `traceparent`.
- The business flow and step: a request path in `path`, `url.path` or `http.route`, with `method`.
- Anything else becomes an attribute you can search and filter on.

## Limits

- Up to 10,000 records and 5 MB per request. A gzipped body is accepted.
- The key goes in the `Authorization` header. Flowhawk does not accept a key in the address, because addresses end up in logs.

## Check it arrived

Open **Logs** in the app and filter on the service. If nothing shows after a minute, [Help and troubleshooting](https://flowhawk.dev/docs/help) says why data can be refused (a wrong key, an empty balance) and how to see it.

## Common questions

### Should I use this from my app?

For a service, an OpenTelemetry SDK or a Flowhawk SDK is better: it sends logs with their trace and flow, batches and retries for you ([language guides](https://flowhawk.dev/docs/languages)). This endpoint is for everything else.

### Can I tell Flowhawk a job ran?

For "did the nightly job run", use a [heartbeat check](https://flowhawk.dev/integrations/cron-job-monitoring) instead: it pages you when the ping doesn't come.

## Related

[**Cron job monitoring**Know when a nightly job, a worker or a data pipeline stops running. Each job calls a ping URL when it finishes, and Flowhawk opens an incident when the ping doesn't come.](https://flowhawk.dev/integrations/cron-job-monitoring) [**Fluent Bit**Send the logs Fluent Bit already collects to Flowhawk with one http output.](https://flowhawk.dev/integrations/fluent-bit) [**Vector**Send any log Vector can read to Flowhawk with one http sink.](https://flowhawk.dev/integrations/vector-logs)

[Try it free for 14 days](https://app.flowhawk.dev/signup?trial=1) [Read the getting started guide](https://flowhawk.dev/docs/getting-started)

---

URL: https://flowhawk.dev/integrations/http-logs-api
