Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I flush everything to Splunk? #262

Open
johncurrier opened this issue Oct 19, 2022 · 1 comment
Open

How do I flush everything to Splunk? #262

johncurrier opened this issue Oct 19, 2022 · 1 comment

Comments

@johncurrier
Copy link

When writing an AWS Lambda I need to know that all of my logs have been persisted to Splunk before exiting the Lambda. The Lambdas that I'm working on aren't customer-facing, so their performance isn't time critical.

I'm currently setting batch_size_count to 1. My understanding is that any value higher than that could result in a batch never being persisted to Splunk.

At the end of my Lambda I don't seem to have a way of knowing that all of my log entries have been persisted since they seem to be done asynchronously. How do I know that everything has been flushed so I can return control of the Lambda back to AWS? Note that shutdown hooks don't seem to be applicable in the AWS Lambda world.

@sleepo581
Copy link

sleepo581 commented Jan 7, 2024

I use the following work-around with Logback (assuming there is logger called root and appender called SPLUNK_HEC):

private static void flushLogs() {
        LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
        HttpEventCollectorLogbackAppender<?> appender = (HttpEventCollectorLogbackAppender<?>) loggerContext.getLogger("root").getAppender("SPLUNK_HEC");
        if (appender != null) {
            appender.flush();
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants