fly-log-shipper

February 22, 2022 ยท View on GitHub

Ship logs from fly to other providers using NATS and Vector

Here we have some vector configs and a nats client (`fly-logs`), along side a wrapper script to run it all, that will subscribe to a log stream of your organisations logs, and ship it to various providers.

Configuration

Create a new Fly app based on this Dockerfile and configure using the following secrets:

fly-logs configuration

SecretDescription
ORGOrganisation slug
ACCESS_TOKENFly personal access token
SUBJECTSubject to subscribe to. See [[NATS]] below (defaults to logs.>)
QUEUEArbitrary queue name if you want to run multiple log processes for HA and avoid duplicate messages being shipped

Provider configuration

AWS S3

SecretDescription
AWS_ACCESS_KEY_IDAWS Access key with access to the log bucket
AWS_SECRET_ACCESS_KEYAWS secret access key
AWS_BUCKETAWS S3 bucket to store logs in
AWS_REGIONRegion for the bucket

Datadog

SecretDescription
DATADOG_API_KEYAPI key for your Datadog account

Honeycomb

SecretDescription
HONEYCOMB_API_KEYHoneycomb API key
HONEYCOMB_DATASETHoneycomb dataset

Humio

SecretDescription
HUMIO_TOKENHumio token

Logdna

SecretDescription
LOGDNA_API_KEYLogDNA API key

Logflare

SecretDescription
LOGFLARE_API_KEYLogflare ingest API key
LOGFLARE_SOURCE_TOKENLogflare source token (uuid on your Logflare dashboard)

Logtail

SecretDescription
LOGTAIL_TOKENLogtail auth token

Loki

SecretDescription
LOKI_URLLoki Endpoint
LOKI_USERNAMELoki Username
LOKI_PASSWORDLoki 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/)

SecretDescription
NEW_RELIC_INSERT_KEY(optional) New Relic Insert key
NEW_RELIC_LICENSE_KEY(optional) New Relic License key

Papertrail

SecretDescription
PAPERTRAIL_ENDPOINTPapertrail endpoint

Sematext

SecretDescription
SEMATEXT_REGIONSematext region
SEMATEXT_TOKENSematext token

Uptrace

SecretDescription
UPTRACE_API_KEYUptrace API key
UPTRACE_PROJECTUptrace project ID

EraSearch

SecretDescription
ERASEARCH_URLEraSearch Endpoint
ERASEARCH_AUTHEraSearch User
ERASEARCH_INDEXEraSearch Index you want to use

NATS

The log stream is provided through the NATS protocol and is limited to subscriptions to logs in your organisations. The fly-logs app is simply a Go NATS client that takes some Fly specific environment variables to connect to the stream, but any NATS client can connect to fdaa::3 on port 4223 in a Fly vm, with an organisation slug as the username and a Fly Personal Access Token as the password.

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.

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 fly-logs application sends logs to a unix socket which is created by Vector. 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.