/src/osquery/plugins/config/parsers/prometheus_targets.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /** |
2 | | * Copyright (c) 2014-present, The osquery authors |
3 | | * |
4 | | * This source code is licensed as defined by the LICENSE file found in the |
5 | | * root directory of this source tree. |
6 | | * |
7 | | * SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only) |
8 | | */ |
9 | | |
10 | | #include <iostream> |
11 | | |
12 | | #include <osquery/config/config.h> |
13 | | #include <osquery/logger/logger.h> |
14 | | #include <osquery/registry/registry_factory.h> |
15 | | #include <plugins/config/parsers/prometheus_targets.h> |
16 | | |
17 | | namespace osquery { |
18 | | |
19 | | const std::string kPrometheusParserRootKey("prometheus_targets"); |
20 | | |
21 | 0 | std::vector<std::string> PrometheusMetricsConfigParserPlugin::keys() const { |
22 | 0 | return {kPrometheusParserRootKey}; |
23 | 0 | } |
24 | | |
25 | | Status PrometheusMetricsConfigParserPlugin::update(const std::string& source, |
26 | 0 | const ParserConfig& config) { |
27 | 0 | auto prometheus_targets = config.find(kPrometheusParserRootKey); |
28 | 0 | if (prometheus_targets != config.end()) { |
29 | 0 | auto doc = JSON::newObject(); |
30 | 0 | auto obj = doc.getObject(); |
31 | 0 | doc.copyFrom(prometheus_targets->second.doc(), obj); |
32 | 0 | doc.add(kPrometheusParserRootKey, obj); |
33 | 0 | data_ = std::move(doc); |
34 | 0 | } |
35 | |
|
36 | 0 | return Status(); |
37 | 0 | } |
38 | | |
39 | | REGISTER_INTERNAL(PrometheusMetricsConfigParserPlugin, |
40 | | "config_parser", |
41 | | "prometheus_targets"); |
42 | | } |