• Stars
    star
    277
  • Rank 148,875 (Top 3 %)
  • Language
    Shell
  • Created over 3 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ship logs from fly to other providers

fly-log-shipper

Ship logs from fly to other providers using NATS and Vector

In this repo you will find various Vector Sinks along with the required fly config. The end result is a Fly.IO application that automatically reads your organisation logs and sends them to external providers.

Quick start

  1. Create a new fly logger app based on our docker image
fly launch --image ghcr.io/superfly/fly-log-shipper:latest
  1. Set NATS source secrets for your new app
  2. Set your desired provider from below

Thats it - no need to setup NATs clients within your apps, as fly apps are already sending monitoring information back to fly which we can read.

However for advanced uses you can still configure a NATs client in your apps to talk to this NATs server. See NATS

NATS source configuration

Secret Description
ORG Organisation slug (default to personal)
ACCESS_TOKEN Fly personal access token (required; set with fly secrets set ACCESS_TOKEN=$(fly auth token))
SUBJECT Subject to subscribe to. See [[NATS]] below (defaults to logs.>)
QUEUE Arbitrary queue name if you want to run multiple log processes for HA and avoid duplicate messages being shipped

After generating your fly.toml, remember to update the internal port to match the vector internal port defined in vector-configs/vector.toml. Not doing so will result in health checks failing on deployment.

[[services]]
  http_checks = []
  internal_port = 8686

Set the secrets below associated with your desired log destination

Provider configuration

AppSignal

Secret Description
APPSIGNAL_PUSH_API_KEY AppSignal push API key

AWS S3

Secret Description
AWS_ACCESS_KEY_ID AWS Access key with access to the log bucket
AWS_SECRET_ACCESS_KEY AWS secret access key
AWS_BUCKET AWS S3 bucket to store logs in
AWS_REGION Region for the bucket
S3_ENDPOINT (optional) Endpoint URL for S3 compatible object stores such as Cloudflare R2 or Wasabi

Axiom

Secret Description
AXIOM_TOKEN Axiom token
AXIOM_DATASET Axiom dataset

Better Stack Logs (formerly Logtail)

Secret Description
BETTER_STACK_SOURCE_TOKEN Better Stack Logs source token

Datadog

Secret Description
DATADOG_API_KEY API key for your Datadog account
DATADOG_SITE (optional) The Datadog site. ie: datadoghq.eu

Highlight

Secret Description
HIGHLIGHT_PROJECT_ID Highlight Project ID

Honeycomb

Secret Description
HONEYCOMB_API_KEY Honeycomb API key
HONEYCOMB_DATASET Honeycomb dataset

Humio

Secret Description
HUMIO_TOKEN Humio token
HUMIO_ENDPOINT (optional) Endpoint URL to send logs to

HyperDX

Secret Description
HYPERDX_API_KEY HyperDX API key

Logdna

Secret Description
LOGDNA_API_KEY LogDNA API key

Logflare

Secret Description
LOGFLARE_API_KEY Logflare ingest API key
LOGFLARE_SOURCE_TOKEN Logflare source token (uuid on your Logflare dashboard)

Loki

Secret Description
LOKI_URL Loki Endpoint
LOKI_USERNAME Loki Username
LOKI_PASSWORD Loki Password

New Relic

One of these is required for New Relic logs. New Relic recommend the license key be used (ref: https://docs.newrelic.com/docs/logs/enable-log-management-new-relic/enable-log-monitoring-new-relic/vector-output-sink-log-forwarding/)

Secret Description
NEW_RELIC_INSERT_KEY (optional) New Relic Insert key
NEW_RELIC_LICENSE_KEY (optional) New Relic License key
NEW_RELIC_REGION (optional) eu or us (default us)
NEW_RELIC_ACCOUNT_ID New Relic Account Id

Papertrail

Secret Description
PAPERTRAIL_ENDPOINT Papertrail endpoint
PAPERTRAIL_ENCODING_CODEC Papertrail codec (default is "json")

Sematext

Secret Description
SEMATEXT_REGION Sematext region
SEMATEXT_TOKEN Sematext token

Uptrace

Secret Description
UPTRACE_API_KEY Uptrace API key
UPTRACE_PROJECT Uptrace project ID
UPTRACE_SINK_INPUT "log_json", etc.
UPTRACE_SINK_ENCODING "json", etc.

For UPTRACE_SINK_ENCODING Vector expects one of avro, gelf, json, logfmt, native, native_json, raw_message, text for key sinks.uptrace.

EraSearch

Secret Description
ERASEARCH_URL EraSearch Endpoint
ERASEARCH_AUTH EraSearch User
ERASEARCH_INDEX EraSearch Index you want to use

HTTP

Secret Description
HTTP_URL HTTP/HTTPS Endpoint
HTTP_TOKEN HTTP Bearer auth token

Slack ( experimental )

HTTP sink that can be used for sending log alerts to Slack.

Secret Description
SLACK_WEBHOOK_URL Slack WebHook URL
SLACK_ALERT_KEYWORDS Keywords to alert on

Example for setting keywords fly secrets set SLACK_ALERT_KEYWORDS="[r'SIGTERM', r'reboot']"


NATS

The log stream is provided through the NATS protocol and is limited to subscriptions to logs in your organisations.

Connecting

Note: You do not have to manually connect a NAT Client, see Quick Start

If you want to add custom behaviours or modify the subject sent from your app, then you can connect your app to the NATs server manually.

Any fly app can connect to the NATs server on nats://[fdaa::3]:4223 (IPV6).

Note: you will need to supply a user / password.

User: is your Fly organisation slug, which you can obtain from fly orgs list > Password: is your fly token, which you can obtain from fly auth token

Example using the NATs client

Launch a nats client based on the nats-server image

fly launch --image="synadia/nats-server:nightly" --name="nats-client"

SSH into the new app

fly -a nats-client ssh console
nats context add nats --server [fdaa::3]:4223 --description "NATS Demo" --select \
  --user <YOUR FLY ORG SLUG> \
  --password <YOUR PAT>
nats pub "logs.test" "hello world"

Subject

The subject schema is logs.<app_name>.<region>.<instance_id> and the standard NATS wildcards can be used. In this app, the SUBJECT secret can be used to set the subject and limit the scope of the logs streamed.

Queue

If you would like to run multiple vm's for high availability, the NATS endpoint supports subscription queues to ensure messages are only sent to one subscriber of the named queue. The QUEUE secret can be set to configure a queue name for the client.


Vector

The nats source component sends logs to other downstream transforms and sinks in the Vector config. This processes the log lines and sends them to various providers. The config is generated from a shell wrapper script which uses conditionals on environment variables to decide which Vector sinks to configure in the final config.

More Repositories

1

litefs

FUSE-based file system for replicating SQLite databases across a cluster of machines
Go
4,017
star
2

flyctl

Command line tools for fly.io services
Go
1,352
star
3

fly

Deploy app servers close to your users. Package your app as a Docker image, and launch it in 17 cities with one simple CLI.
981
star
4

corrosion

Gossip-based service discovery (and more) for large distributed systems.
Rust
673
star
5

flyctl-actions

:octocat: GitHub Action that wraps the flyctl
TypeScript
266
star
6

init-snapshot

Fly
Rust
259
star
7

ltx

Go library for the LTX file format
Go
197
star
8

tokenizer

HTTP proxy that injects 3rd party credentials into requests
Go
185
star
9

fly-pr-review-apps

Github Action for PR Review Apps on Fly.io
Shell
182
star
10

wormhole

Fly.io secure tunnel
Go
181
star
11

edge

A set of useful libraries for Edge Apps. Run locally, write tests, and integrate it into your deployment process. Move fast and maybe don't break things? Because, gosh darnit, you're an adult.
TypeScript
144
star
12

docs

HTML
101
star
13

fly_postgres_elixir

Library for working with local read-replica postgres databases and performing writes through RPC calls to other nodes in the primary Fly.io region.
Elixir
100
star
14

fly-ruby

Ruby gem for handling requests within a Fly.io multiregion database setup
Ruby
86
star
15

ssokenizer

Go
84
star
16

litefs-example

An example of deploying LiteFS on Fly.io.
Go
74
star
17

macaroon

Fly.io macaroon implementation
Go
70
star
18

fly_rpc_elixir

Makes it easier to build distributed Elixir applications on the Fly.io platform. Adds region awareness to an app and makes it easy to perform RPC calls in other Fly.io regions.
Elixir
52
star
19

litevfs

LiteFS VFS SQLite extension for serverless environments
Rust
46
star
20

rchab

Fly.io Remote Builder (Remote Controlled Hot Air Balloon)
Go
43
star
21

fly.rs

Fly Edge Application runtime.
Rust
40
star
22

elixir-hiring-project

This is a sample project we use to assess Elixir/Phoenix/LiveView skills, and also simulate an idea of the type of work a dev advocate could end up doing at Fly.io.
Elixir
35
star
23

dropspy

Go implementation of the venerable dropwatch utility
Go
34
star
24

fly-node

Node.js Express-compatible middleware for enhancing apps deployed on Fly.io
TypeScript
34
star
25

tired-proxy

An http proxy that's just too tired and eventually shuts down
Go
33
star
26

fly-autoscaler

A metrics-based autoscaler for Fly.io
Go
28
star
27

fly-go

Go client for the Fly.io API
Go
21
star
28

bfaas

Bash functions-as-a-service
TypeScript
21
star
29

onehostname

A Fly Edge Application for combining a bunch of different backends under one hostname
TypeScript
17
star
30

stimulus-live-elements

Live Element support for Rails via Stimulus
JavaScript
17
star
31

gravitas

Ruby
17
star
32

fly-checks

Basic health-check framework
Go
15
star
33

machine-proxy

PoC HTTP proxy for scale-to-zero apps via the Fly machines API
Go
15
star
34

burn

HTTP load testing tool
Go
13
star
35

fly-rails

Rails support for Fly-io
Ruby
13
star
36

image-processing

TypeScript
13
star
37

multi-cloud-haproxy

Awk
12
star
38

doh-proxy

Docker image: DNS over HTTPS proxy
Dockerfile
11
star
39

recco

Gain information about applications to inform deployments
Go
11
star
40

litefs-go

Go library for interacting with LiteFS.
Go
11
star
41

sqlite3-restore

Utility for performing an online restore of a SQLite database.
Go
9
star
42

flyjs

The Fly JavaScript runtime (archived)
TypeScript
9
star
43

dashboards

Collection of dashboards for visualizing Fly.io app data
9
star
44

dns-help

Instructions for pointing a domain at your Fly edge application
JavaScript
8
star
45

glitch-domains

JavaScript
8
star
46

anti-roadmap

This is the opposite of a roadmap. A place where we track things we're probably not going to do.
8
star
47

rant2outline

Convert those rants to meetup talk outlines with the power of AI!
TypeScript
8
star
48

fly-builders

CNB Buildpacks for Fly - supporting (so far) Deno
Shell
7
star
49

fly.cr

Crystal HTTP middleware to handle fly.io multi-region postgres replays.
Crystal
7
star
50

wordpress-image-optimizer

JavaScript
7
star
51

pixelfly

An HTTP image service
TypeScript
6
star
52

ghost-accelerator

JavaScript
6
star
53

ltx-rs

Rust library for the LTX file format
Rust
6
star
54

shout

Shouting is an effective way of communicating between hot air balloons
Go
5
star
55

load-balancer

Fly application load balancer.
TypeScript
5
star
56

anycable-rails

Run Anycable with Rails on Fly
Ruby
5
star
57

llm-describer

A simple image describer service using Ollama and PocketBase
Go
5
star
58

embedding-v8-talk

A talk about embedding v8
TypeScript
4
star
59

flygit

https://rawgit.com on Fly
JavaScript
4
star
60

fly-heroku-buildpack

Heroku buildpack that automatically connects apps to Fly.io
Shell
4
star
61

homebrew-tap

Ruby
4
star
62

litefs-node

A Node.js library for interacting with LiteFS.
C++
4
star
63

cee-dee-en

A basic CDN example using a Fly Edge App
JavaScript
3
star
64

glitch-custom-hostnames

Run any glitch app with a custom hostname
JavaScript
3
star
65

litefs-ruby

Ruby library for interacting with LiteFS.
Makefile
3
star
66

talks

Various talks we've given
TypeScript
3
star
67

tokenizer-elixir

Elixir
3
star
68

macaroon-elixir

Elixir library for attenuating Fly.io macaroons
Elixir
3
star
69

rust-templates

Rust
3
star
70

aws-lambda-express-example

A light-weight example of AWS Lambda, using Express.js and Claudia.js.
JavaScript
2
star
71

fileserver

Simple and dockerized fasthttp-based fileserver
Go
2
star
72

domain-reseller-guide

2
star
73

fly-openapi-sdk

Generated API clients for the Fly machines API
Python
2
star
74

flu

Start of a utility command line tool
Go
2
star
75

lfsc-go

Go client for LiteFS Cloud
Go
2
star
76

csharp-example

Deploy an example c# app to Fly
C#
2
star
77

fly-docker-example

Demonstrates horizontal scaling with Docker/Nginx and Docker/Fly.
JavaScript
2
star
78

cookiebot

Example macaroon discharge service
Go
2
star
79

redis-cache-example

Go
1
star
80

api-versioning

JavaScript
1
star
81

actioncable_redis-reconnect

A patch for ActionCable Redis that reconnects after it disconnects
Ruby
1
star
82

ruby-example

Deploy an example Ruby app to Fly
Ruby
1
star
83

fly-on-deno

TypeScript
1
star
84

pushpin-example

Pushpin on Fly
Dockerfile
1
star
85

ab-test-example-app

JavaScript
1
star
86

tipe-react-edge

Rendering Tipe API responses with React on the edge
JavaScript
1
star
87

responsive-images

Make images on any app responsive
JavaScript
1
star
88

go-example

Deploy an example Go app to Fly
Dockerfile
1
star
89

gpu-burn-app

A Fly app to stress GPU cards
Dockerfile
1
star
90

fsmap

Go module to list free block ranges on Linux filesystems by calling the `GETFSMAP` ioctl.
Go
1
star
91

fly-rust-axum-starter

Dockerfile
1
star