You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Create a new fly logger app based on our docker image
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 tokens create readonly personal))
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
NETWORK
6PN network, if you want to run log-shipper through a WireGuard connection (defaults to fdaa:0:0)
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.
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 tokens create readonly personal
Example using the NATs client
Launch a nats client based on the nats-server image
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.