mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-08 18:33:54 +00:00
70 lines
1.7 KiB
C
70 lines
1.7 KiB
C
|
/*
|
||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||
|
* All rights reserved.
|
||
|
*
|
||
|
* This source code is licensed under the BSD-style license found in the
|
||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
#pragma once
|
||
|
|
||
|
#include <chrono>
|
||
|
#include <memory>
|
||
|
#include <vector>
|
||
|
|
||
|
#include <aws/kinesis/KinesisClient.h>
|
||
|
|
||
|
#include <osquery/core.h>
|
||
|
#include <osquery/dispatcher.h>
|
||
|
#include <osquery/logger.h>
|
||
|
|
||
|
#include "osquery/core/test_util.h"
|
||
|
#include "osquery/logger/plugins/buffered.h"
|
||
|
|
||
|
namespace osquery {
|
||
|
|
||
|
DECLARE_uint64(aws_kinesis_period);
|
||
|
|
||
|
class KinesisLogForwarder : public BufferedLogForwarder {
|
||
|
private:
|
||
|
static const size_t kKinesisMaxLogBytes;
|
||
|
static const size_t kKinesisMaxRecords;
|
||
|
|
||
|
public:
|
||
|
KinesisLogForwarder()
|
||
|
: BufferedLogForwarder("kinesis",
|
||
|
std::chrono::seconds(FLAGS_aws_kinesis_period),
|
||
|
kKinesisMaxRecords) {}
|
||
|
Status setUp() override;
|
||
|
|
||
|
protected:
|
||
|
Status send(std::vector<std::string>& log_data,
|
||
|
const std::string& log_type) override;
|
||
|
|
||
|
private:
|
||
|
std::string shard_id_;
|
||
|
std::shared_ptr<Aws::Kinesis::KinesisClient> client_{nullptr};
|
||
|
|
||
|
FRIEND_TEST(KinesisTests, test_send);
|
||
|
};
|
||
|
|
||
|
class KinesisLoggerPlugin : public LoggerPlugin {
|
||
|
public:
|
||
|
KinesisLoggerPlugin() : LoggerPlugin() {}
|
||
|
|
||
|
Status setUp() override;
|
||
|
|
||
|
Status init(const std::string& name,
|
||
|
const std::vector<StatusLogLine>& log) override {
|
||
|
return Status(1, "Does not support status logs");
|
||
|
}
|
||
|
|
||
|
Status logString(const std::string& s) override;
|
||
|
|
||
|
private:
|
||
|
std::shared_ptr<KinesisLogForwarder> forwarder_{nullptr};
|
||
|
};
|
||
|
}
|