Search in sources :

Example 1 with Metric

use of org.platformlayer.ops.model.metrics.Metric in project platformlayer by platformlayer.

the class MetricCollector method populateMetricInfo.

static void populateMetricInfo(MetricInfoCollection metricInfoCollection, String prefix, MetricConfig metrics) {
    if (metrics.metric != null) {
        for (Metric metric : metrics.metric) {
            MetricInfo metricInfo = new MetricInfo();
            metricInfo.key = (prefix + metric.key);
            metricInfoCollection.metricInfoList.add(metricInfo);
        }
    }
    if (metrics.metrics != null) {
        for (MetricConfig subtree : metrics.metrics) {
            String childPrefix = prefix + subtree.key + "/";
            populateMetricInfo(metricInfoCollection, childPrefix, subtree);
        }
    }
}
Also used : MetricConfig(org.platformlayer.ops.model.metrics.MetricConfig) MetricInfo(org.platformlayer.metrics.model.MetricInfo) Metric(org.platformlayer.ops.model.metrics.Metric)

Example 2 with Metric

use of org.platformlayer.ops.model.metrics.Metric in project platformlayer by platformlayer.

the class CollectdMetricFetcher method getMetricConfig.

private Metric getMetricConfig(MetricConfig metricConfig, String metricKey) throws OpsException {
    String[] components = metricKey.split("\\.");
    if (components.length == 0) {
        throw new IllegalArgumentException();
    }
    int position = 0;
    while (true) {
        String component = components[position];
        if ((position + 1) == components.length) {
            if (metricConfig.metric != null) {
                for (Metric metric : metricConfig.metric) {
                    if (Objects.equal(metric.key, component)) {
                        return metric;
                    }
                }
            }
        } else {
            boolean found = false;
            if (metricConfig.metrics != null) {
                for (MetricConfig tree : metricConfig.metrics) {
                    if (Objects.equal(tree.key, component)) {
                        position++;
                        metricConfig = tree;
                        found = true;
                        break;
                    }
                }
            }
            if (found) {
                continue;
            }
        }
        return null;
    }
}
Also used : MetricConfig(org.platformlayer.ops.model.metrics.MetricConfig) Metric(org.platformlayer.ops.model.metrics.Metric)

Aggregations

Metric (org.platformlayer.ops.model.metrics.Metric)2 MetricConfig (org.platformlayer.ops.model.metrics.MetricConfig)2 MetricInfo (org.platformlayer.metrics.model.MetricInfo)1