Skip to content

Instantly share code, notes, and snippets.

@chasers
chasers / logflare_cloudflare_log_event_example.json
Created April 13, 2021 13:41
What the log event for the Logflare Cloudflare app looks like.
{
"logflare_worker": {
"version": "1.0.2",
"worker_id": "RXJD9X",
"worker_started": "2021-04-13T13:36:18.848Z"
},
"request": {
"cf": {
"asn": 15169,
"clientAcceptEncoding": "gzip,deflate,br",
@chasers
chasers / logflare_event_ingest_batch_curl
Last active June 27, 2021 14:51
logflare_event_ingest_batch_curl
curl -X "POST" "https://api.logflare.app/logs?source=YOUR_SOURCE_UUID" \
-H 'Content-Type: application/json' \
-H 'X-Api-Key: YOUR_INGEST_KEY' \
-d $'{
"batch": [
{
"message": "This is another log message.",
"metadata": {
"ip_address": "100.100.100.100",
"request_method": "POST",
@chasers
chasers / simpleCloudflareLogflareWorker.js
Created March 10, 2021 13:38
Simple Logflare Cloudflare worker
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 => {
@chasers
chasers / logflare_event_ingest_with_message
Last active April 2, 2021 13:39
logflare_log_event_ingest_with_message
curl -X "POST" "https://api.logflare.app/logs?source=2fd57445-1da3-4f3b-aa29-73da06ed7e67" \
-H 'Content-Type: application/json' \
-H 'X-API-KEY: YOUR_KEY' \
-d $'{
"message": "This is another log message.",
"metadata": {
"ip_address": "100.100.100.100",
"request_method": "POST",
"custom_user_data": {
"vip": true,
@chasers
chasers / logflare_curl_json_body
Created February 26, 2021 20:47
logflare_curl_json_body
curl -X "POST" "https://api.logflare.app/logs/json?source=2fd57445-1da3-4f3b-aa29-73da06ed7e67" \
-H 'Content-Type: application/json; charset=utf-8' \
-H 'X-API-KEY: YOUR_KEY' \
-d $'[
{
"yellow": true,
"tags": [
"popular, tropical, organic"
],
"store": {
@chasers
chasers / custom-ds-query.sql
Last active September 11, 2020 21:27
Query BigQuery Logflare managed ingest time partitioned table with Data Studio
SELECT * FROM `logflare-232118.[ID]_prod.[SOURCE_UUID_UNDERSCORE]`
WHERE DATE(_PARTITIONTIME)
BETWEEN PARSE_DATE('%Y%m%d', @DS_START_DATE)
AND PARSE_DATE('%Y%m%d', @DS_END_DATE)
OR _PARTITIONTIME IS null
@chasers
chasers / logflare-vercel-message.json
Created July 23, 2020 19:30
Example Vercel Logflare Message
{
"deploymentId": "dpl_8zVeEFAnYTXLoBT8XYMgLVbc1Rpi",
"host": "pino-logflare-nextjs-vercel-example-7duieexku.vercel.app",
"id": "1595492268532915653954269765",
"message": "START RequestId: 4148955a-4bf6-4ae9-8736-95826ac8a414 Version: $LATEST\n{\"metadata\":{\"env\":\"production\",\"request\":{\"headers\":{\"host\":\"pino-logflare-nextjs-vercel-example.now.sh\",\"x_forwarded_host\":\"pino-logflare-nextjs-vercel-example.now.sh\",\"accept\":\"*/*\",\"x_vercel_deployment_url\":\"pino-logflare-nextjs-vercel-example-7duieexku.vercel.app\",\"x_forwarded_proto\":\"https\",\"x_real_ip\":\"54.36.148.90\",\"accept_encoding\":\"deflate, gzip, br\",\"user_agent\":\"Mozilla/5.0 (compatible; AhrefsBot/6.1; +http://ahrefs.com/robot/)\",\"x_vercel_forwarded_for\":\"54.36.148.90\",\"x_forwarded_for\":\"54.36.148.90\",\"x_nextjs_page\":\"/index\",\"x_vercel_id\":\"lhr1::95xl7-1595492267523-aebd6fdc73fb\",\"connection\":\"close\"},\"url\":\"/\",\"method\":\"GET\"},\"response\":{\"statusCode\":200},\"context\":{},\"level
@chasers
chasers / logflare-fluent-bit-config.conf
Last active September 4, 2020 14:41
Logflare Fluent Bit Config
[INPUT]
Name tail
Path /var/log/system.log
[OUTPUT]
Name http
Match *
tls On
tls.verify Off
Host api.logflare.app
def event(conn, params) do
user_token = params["authentications"]["account"]["token"]["token"]
response =
build_response(conn, user_token)
|> Jason.encode!()
conn
|> put_resp_content_type("application/json")
|> send_resp(200, response)
%{
"install" => %{
"active" => true,
"amount" => 0,
"appId" => "local",
"created" => nil,
"deactivatedAt" => nil,
"deleted" => false,
"id" => "FJj9ri2UtwIv",
"installerUserId" => "",