You'll need this source ID for some integrations or libraries.
fb629761-4c10-485d-8454-c884a2f851f4
If you're hosted on Vercel setup our Vercel integration!
Install the Vercel integration
Install the Gigalixir command line tool, and navigate to your project directory.
gigalixir drains:add "http://localhost:4000/logs/logplex?api_key=dDxA9Cpr4TUD&source=fb629761-4c10-485d-8454-c884a2f851f4"
Already on Cloudflare? Install the Cloudflare app and start sending logs now.
Add our log drain with a simple command.
heroku drains:add "http://localhost:4000/logs/logplex?api_key=dDxA9Cpr4TUD&source=fb629761-4c10-485d-8454-c884a2f851f4"
Using Elixir? Use our Logger backend to send your structured logs.
Setup the Logger backend
Watch log files on a server with our Elixir agent.
Install the agent
Use our official Pino transport to send log events from your Javascript project.
Setup the Pino transport
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=dDxA9Cpr4TUD&source=fb629761-4c10-485d-8454-c884a2f851f4
Use our Github Action (thanks @gr2m ) to easily log events coming from your repositories.
Setup the Github Action
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=dDxA9Cpr4TUD&source=fb629761-4c10-485d-8454-c884a2f851f4
Format json
Retry_Limit 5
json_date_format iso8601
json_date_key timestamp
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=dDxA9Cpr4TUD&source=fb629761-4c10-485d-8454-c884a2f851f4
Or send generic JSON events yourself.
curl -X "POST" "http://localhost:4000/logs/json?source=fb629761-4c10-485d-8454-c884a2f851f4" \
-H 'Content-Type: application/json; charset=utf-8' \
-H 'X-API-KEY: dDxA9Cpr4TUD' \
-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
}
]'
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/logs?source=fb629761-4c10-485d-8454-c884a2f851f4" \
-H 'Content-Type: application/json' \
-H 'X-API-KEY: dDxA9Cpr4TUD' \
-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"
}
}
}'
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 = "fb629761-4c10-485d-8454-c884a2f851f4"
const apiKey = "dDxA9Cpr4TUD"
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/logs", init))
return response
}
addEventListener("fetch", event => {
event.passThroughOnException()
event.respondWith(handleRequest(event))
})