Skip to content

Instantly share code, notes, and snippets.

@mhr3
mhr3 / ingest.sh
Created June 30, 2023 11:49
Ingesting AWS ALB logs into Axiom
# this command ingests ALB logs into Axiom without any pre-processing, the file should be the *.log.gz as stored in S3
curl "https://api.axiom.co/v1/datasets/$DATASET/ingest?timestamp-field=time&csv-delimiter=%20" \
-H "Authorization: Bearer $AXIOM_INGEST_TOKEN" \
-H 'Content-Type: text/csv' \
-H 'Content-Encoding: gzip' \
-H 'x-axiom-csv-fields: type,time,elb,client_port,target_port,request_processing_time,target_processing_time,response_processing_time,elb_status_code,target_status_code,received_bytes,sent_bytes,request,user_agent,ssl_cipher,ssl_protocol,target_group_arn,trace_id,domain_name,chosen_cert_arn,matched_rule_priority,request_creation_time,actions_executed,redirect_url,error_reason,target_port_list,target_status_code_list,classification,classification_reason' \
--data-binary @file.log.gz

Benchmark results for mhr3/gozstd/use-go-slices:

CPU time
name                                          old time/op    new time/op    delta
DecompressDict/blockSize_1/level_3-8            21.3ns ± 2%    25.5ns ± 2%    +19.57%  (p=0.016 n=4+5)
DecompressDict/blockSize_1/level_5-8            21.0ns ± 2%    25.2ns ± 2%    +20.02%  (p=0.016 n=4+5)
DecompressDict/blockSize_1/level_10-8           21.3ns ± 5%    25.4ns ± 3%    +19.18%  (p=0.016 n=4+5)
@mhr3
mhr3 / grafana-cloudflare-access-auth.md
Last active May 2, 2024 06:28
Authenticate to Grafana using Cloudflare Access

Grafana supports JWT based authentication, so it needs to be enabled:

snippet of grafana.ini:

[users]
allow_sign_up = false
auto_assign_org = true

[auth.jwt]
enabled = true
package hash_test
import (
"fmt"
"strings"
"testing"
"unsafe"
"github.com/segmentio/fasthash/fnv1a"
)