Send Logs to this Source
Source ID
You'll need this source ID for some integrations or libraries.
5c4949b3-aa03-48a6-8268-fa631779de05
If you're hosted on Vercel setup our Vercel integration!
Install the Vercel integrationGigalixir
Install the Gigalixir command line tool, and navigate to your project directory.
gigalixir drains:add "http://localhost:4000/logs/logplex?api_key=zrlDD-vErBG7&source=5c4949b3-aa03-48a6-8268-fa631779de05"
Cloudflare App
Already on Cloudflare? Install the Cloudflare app and start sending logs now.
Heroku
Add our log drain with a simple command.
heroku drains:add "http://localhost:4000/logs/logplex?api_key=zrlDD-vErBG7&source=5c4949b3-aa03-48a6-8268-fa631779de05"
Elixir Logger
Using Elixir? Use our Logger backend to send your structured logs.
Setup the Logger backendElixir Agent
Watch log files on a server with our Elixir agent.
Install the agentJavascript
Use our official Pino transport to send log events from your Javascript project.
Setup the Pino transportGithub Webhook
Set your Github webhook to this Logflare endpoint and we'll ingest Github webhooks for you. This endpoint drops all keys ending in _url
so it keeps your Github payloads in check.
http://localhost:4000/logs/github?api_key=zrlDD-vErBG7&source=5c4949b3-aa03-48a6-8268-fa631779de05
Github Action
Use our Github Action (thanks @gr2m) to easily log events coming from your repositories.
Setup the Github ActionFluent Bit
Watch log files on a server with this Fluent Bit output config.
[INPUT]
Name tail
Path /var/log/syslog
[OUTPUT]
Name http
Match *
tls On
Host api.logflare.app
Port 443
URI /logs/json?api_key=zrlDD-vErBG7&source=5c4949b3-aa03-48a6-8268-fa631779de05
Format json
Retry_Limit 5
json_date_format iso8601
json_date_key timestamp
Generic Webhook
Use the generic JSON ingest endpoint to generate log events from an external webhook.
e.g. you can set a Github webhook to send events to:
http://localhost:4000/logs/json?api_key=zrlDD-vErBG7&source=5c4949b3-aa03-48a6-8268-fa631779de05
Or send generic JSON events yourself.
curl -X "POST" "http://localhost:4000/logs/json?source=5c4949b3-aa03-48a6-8268-fa631779de05" \
-H 'Content-Type: application/json; charset=utf-8' \
-H 'X-API-KEY: zrlDD-vErBG7' \
-d $'[
{
"yellow": true,
"tags": [
"popular, tropical, organic"
],
"store": {
"state": "AZ",
"city": "Phoenix",
"zip": 85016,
"address": "123 W Main St"
},
"type": "fruit",
"name": "banana",
"qty": 12
}
]'
Custom API Request
Send logs via an HTTP request. This request body payload lets you send over a human readable event message in
the message
field.
curl -X "POST" "http://localhost:4000/api/logs?source=5c4949b3-aa03-48a6-8268-fa631779de05" \
-H 'Content-Type: application/json' \
-H 'X-API-KEY: zrlDD-vErBG7' \
-d $'{
"event_message": "This is another log message.",
"metadata": {
"ip_address": "100.100.100.100",
"request_method": "POST",
"custom_user_data": {
"vip": true,
"id": 38,
"login_count": 154,
"company": "Apple",
"address": {
"zip": "11111",
"st": "NY",
"street": "123 W Main St",
"city": "New York"
}
},
"datacenter": "aws",
"request_headers": {
"connection": "close",
"user_agent": "chrome"
}
}
}'
Custom Cloudflare Worker
Customize the Cloudflare worker using the template below.
const makeid = length => {
let text = ""
const possible = "ABCDEFGHIJKLMNPQRSTUVWXYZ0123456789"
for (let i = 0; i < length; i += 1) {
text += possible.charAt(Math.floor(Math.random() * possible.length))
}
return text
}
const buildMetadataFromHeaders = headers => {
const responseMetadata = {}
Array.from(headers).forEach(([key, value]) => {
responseMetadata[key.replace(/-/g, "_")] = value
})
return responseMetadata
}
const WORKER_ID = makeid(6)
async function handleRequest(event) {
const {
request
} = event;
const rMeth = request.method
const rUrl = request.url
const uAgent = request.headers.get("user-agent")
const rHost = request.headers.get("host")
const cfRay = request.headers.get("cf-ray")
const cIP = request.headers.get("cf-connecting-ip")
const rCf = request.cf
const requestMetadata = buildMetadataFromHeaders(request.headers)
const sourceKey = "5c4949b3-aa03-48a6-8268-fa631779de05"
const apiKey = "zrlDD-vErBG7"
const t1 = Date.now()
const response = await fetch(request)
const originTimeMs = Date.now() - t1
const statusCode = response.status
const responseMetadata = buildMetadataFromHeaders(response.headers)
const logEntry = `${rMeth} | ${statusCode} | ${cIP} | ${cfRay} | ${rUrl} | ${uAgent}`
const logflareEventBody = {
source: sourceKey,
log_entry: logEntry,
metadata: {
response: {
headers: responseMetadata,
origin_time: originTimeMs,
status_code: response.status,
},
request: {
url: rUrl,
method: rMeth,
headers: requestMetadata,
cf: rCf,
},
logflare_worker: {
worker_id: WORKER_ID,
},
},
}
const init = {
method: "POST",
headers: {
"X-API-KEY": apiKey,
"Content-Type": "application/json",
"User-Agent": `Cloudflare Worker via ${rHost}`
},
body: JSON.stringify(logflareEventBody),
}
event.waitUntil(fetch("http://localhost:4000/api/logs", init))
return response
}
addEventListener("fetch", event => {
event.passThroughOnException()
event.respondWith(handleRequest(event))
})