Search in sources :

Example 1 with FilebeatConfigProvider

use of com.yahoo.vespa.hosted.node.admin.logging.FilebeatConfigProvider in project vespa by vespa-engine.

the class StorageMaintainer method writeFilebeatConfig.

public void writeFilebeatConfig(ContainerName containerName, ContainerNodeSpec nodeSpec) {
    PrefixLogger logger = PrefixLogger.getNodeAgentLogger(StorageMaintainer.class, containerName);
    try {
        FilebeatConfigProvider filebeatConfigProvider = new FilebeatConfigProvider(environment);
        Optional<String> config = filebeatConfigProvider.getConfig(nodeSpec);
        if (!config.isPresent()) {
            logger.error("Was not able to generate a config for filebeat, ignoring filebeat file creation." + nodeSpec.toString());
            return;
        }
        Path filebeatPath = environment.pathInNodeAdminFromPathInNode(containerName, Paths.get("/etc/filebeat/filebeat.yml"));
        Files.write(filebeatPath, config.get().getBytes());
        logger.info("Wrote filebeat config.");
    } catch (Throwable t) {
        logger.error("Failed writing filebeat config; " + nodeSpec, t);
    }
}
Also used : Path(java.nio.file.Path) FilebeatConfigProvider(com.yahoo.vespa.hosted.node.admin.logging.FilebeatConfigProvider) PrefixLogger(com.yahoo.vespa.hosted.node.admin.util.PrefixLogger)

Aggregations

FilebeatConfigProvider (com.yahoo.vespa.hosted.node.admin.logging.FilebeatConfigProvider)1 PrefixLogger (com.yahoo.vespa.hosted.node.admin.util.PrefixLogger)1 Path (java.nio.file.Path)1