Restart vector if it stops receiving logs from sources#50
Open
Restart vector if it stops receiving logs from sources#50
Conversation
added 2 commits
October 26, 2023 13:19
…an interval and restarts if not
|
It seems like my log shipper app is getting stuck and this might be a way to fix it. @jsierles is it possible for me to deploy this update before it gets merged? Is there a docker image I can refer to now, or would I need to build it myself? |
Contributor
Author
|
You'd need to build it yourself at the moment. |
|
This is very silly, but it took me a while to realize that this log shipper is simply connecting to nats and therefore can be easily implemented in user land. I struggled with setting up this repo, but I got it it work with basic TypeScript. Here is a good start: import { connect } from 'nats';
const connectToNATS = async () => {
console.log('Connecting to NATS');
try {
const nc = await connect({
name: 'Fly logs stream',
pass: process.env.ACCESS_TOKEN,
servers: [`nats://[fdaa:0:0::3]:4223`],
user: process.env.ORG,
});
console.log('Connected to NATS');
return nc;
} catch (error) {
console.error('Failed to connect to NATS:', error);
throw error;
}
};
const main = async () => {
const nc = await connectToNATS();
const subscription = nc.subscribe('logs.>');
for await (const message of subscription) {
console.log(message);
}
};
await main(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a small monitoring service that queries vector at a configurable interval. It checks whether vector has processed any new events. If it hasn't we can assume that its NATS subscription is 'stuck' and needs to be restarted.