33 nlohmann::json configJson = nlohmann::json::parse(configFile.
contents());
36 catch(
const std::exception& e) {
37 std::cerr <<
"Error while parsing configuration file: invalid JSON contents." <<std::endl;
38 std::cerr <<
"Internal error: " << e.what() << std::endl;
54 e.metrics.push_back(std::move(m));
68 c.files.push_back(std::move(f));
81 c.commands.push_back(std::move(p));
static constexpr std::string_view expressionsKey
static constexpr std::string_view programKey
static constexpr std::string_view argumentsKey
Config(const std::string &path) noexcept
Parses the specified config file into a Config object.
static constexpr std::string_view filesKey
static constexpr std::string_view unitKey
static constexpr std::string_view metricsKey
bool update() noexcept
Updates the source (read the file or execute command) and store the results.
computeRateType computeRate
static constexpr std::string_view convertToUnitsPerSecondKey
Class used to represent a source (file or command output) from which metrics can be matched...
Struct used to represent the JSON configuration file.
static constexpr std::string_view nameKey
static constexpr std::string_view tagsKey
static constexpr std::string_view expressionsKey
static constexpr std::string_view computeRateKey
const std::string_view & contents() const noexcept
Returns the stored contents (file contents or command output)
static constexpr std::string_view pathsKey
static constexpr std::string_view commandsKey
std::vector< Config::expression > expressions
void from_json(const nlohmann::json &je, Config::expression &e) noexcept
static constexpr std::string_view valueKey
std::vector< Config::expression > expressions
static constexpr std::string_view regexKey
convertToUnitsPerSecondType convertToUnitsPerSecond