Search in sources :

Example 1 with TelemetryConfig

use of org.onosproject.openstacktelemetry.api.config.TelemetryConfig in project onos by opennetworkinglab.

the class TelemetryConfigListCommand method doExecute.

@Override
protected void doExecute() {
    TelemetryConfigService service = get(TelemetryConfigService.class);
    List<TelemetryConfig> configs = service.getConfigs().stream().filter(c -> !c.swVersion().equals(MASTER)).sorted(Comparator.comparing(TelemetryConfig::type)).collect(Collectors.toList());
    print(FORMAT, "Name", "Type", "Enabled", "Manufacturer", "swVersion");
    for (TelemetryConfig config : configs) {
        print(FORMAT, config.name(), config.type(), config.status().name(), config.manufacturer(), config.swVersion());
    }
}
Also used : TelemetryConfigService(org.onosproject.openstacktelemetry.api.TelemetryConfigService) TelemetryConfig(org.onosproject.openstacktelemetry.api.config.TelemetryConfig)

Example 2 with TelemetryConfig

use of org.onosproject.openstacktelemetry.api.config.TelemetryConfig in project onos by opennetworkinglab.

the class TelemetryConfigNameCompleter method complete.

@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    StringsCompleter delegate = new StringsCompleter();
    TelemetryConfigService service = get(TelemetryConfigService.class);
    Set<String> set = service.getConfigs().stream().filter(c -> !c.swVersion().equals(MASTER)).sorted(Comparator.comparing(TelemetryConfig::name)).map(TelemetryConfig::name).collect(Collectors.toSet());
    SortedSet<String> strings = delegate.getStrings();
    strings.addAll(set);
    return delegate.complete(session, commandLine, candidates);
}
Also used : Session(org.apache.karaf.shell.api.console.Session) TelemetryConfigService(org.onosproject.openstacktelemetry.api.TelemetryConfigService) Completer(org.apache.karaf.shell.api.console.Completer) TelemetryConfig(org.onosproject.openstacktelemetry.api.config.TelemetryConfig) SortedSet(java.util.SortedSet) StringsCompleter(org.apache.karaf.shell.support.completers.StringsCompleter) Set(java.util.Set) Collectors(java.util.stream.Collectors) AbstractShellCommand.get(org.onosproject.cli.AbstractShellCommand.get) CommandLine(org.apache.karaf.shell.api.console.CommandLine) List(java.util.List) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Comparator(java.util.Comparator) StringsCompleter(org.apache.karaf.shell.support.completers.StringsCompleter) TelemetryConfigService(org.onosproject.openstacktelemetry.api.TelemetryConfigService)

Example 3 with TelemetryConfig

use of org.onosproject.openstacktelemetry.api.config.TelemetryConfig in project onos by opennetworkinglab.

the class DefaultTelemetryConfig method getProperty.

@Override
public String getProperty(String name) {
    Queue<TelemetryConfig> queue = new LinkedList<>();
    queue.add(this);
    while (!queue.isEmpty()) {
        TelemetryConfig config = queue.remove();
        String property = config.properties().get(name);
        if (property != null) {
            return property;
        } else if (config.parents() != null) {
            queue.addAll(config.parents());
        }
    }
    return null;
}
Also used : LinkedList(java.util.LinkedList) TelemetryConfig(org.onosproject.openstacktelemetry.api.config.TelemetryConfig)

Example 4 with TelemetryConfig

use of org.onosproject.openstacktelemetry.api.config.TelemetryConfig in project onos by opennetworkinglab.

the class RestTelemetryManager method publish.

@Override
public Set<Response> publish(String record) {
    Set<Response> responses = Sets.newConcurrentHashSet();
    targets.forEach((k, v) -> {
        TelemetryConfig config = telemetryConfigService.getConfig(k);
        RestTelemetryConfig restConfig = fromTelemetryConfig(config);
        switch(restConfig.method()) {
            case POST_METHOD:
                responses.add(v.request(restConfig.requestMediaType()).post(Entity.json(record)));
                break;
            case GET_METHOD:
                responses.add(v.request(restConfig.requestMediaType()).get());
                break;
            default:
                break;
        }
    });
    return responses;
}
Also used : Response(javax.ws.rs.core.Response) RestTelemetryConfig(org.onosproject.openstacktelemetry.api.config.RestTelemetryConfig) DefaultRestTelemetryConfig.fromTelemetryConfig(org.onosproject.openstacktelemetry.config.DefaultRestTelemetryConfig.fromTelemetryConfig) TelemetryConfig(org.onosproject.openstacktelemetry.api.config.TelemetryConfig) RestTelemetryConfig(org.onosproject.openstacktelemetry.api.config.RestTelemetryConfig)

Example 5 with TelemetryConfig

use of org.onosproject.openstacktelemetry.api.config.TelemetryConfig in project onos by opennetworkinglab.

the class InfluxDbTelemetryManager method publish.

@Override
public void publish(InfluxRecord<String, Set<FlowInfo>> record) {
    if (producers == null || producers.isEmpty()) {
        log.debug("InfluxDB telemetry service has not been enabled!");
        return;
    }
    if (record.flowInfos().size() == 0) {
        log.debug("No record to publish");
        return;
    }
    log.debug("Publish {} stats records to InfluxDB", record.flowInfos().size());
    producers.forEach((k, v) -> {
        TelemetryConfig config = telemetryConfigService.getConfig(k);
        InfluxDbTelemetryConfig influxDbConfig = fromTelemetryConfig(config);
        String database = influxDbConfig.database();
        String measurement = influxDbConfig.measurement();
        BatchPoints batchPoints = BatchPoints.database(database).build();
        for (FlowInfo flowInfo : record.flowInfos()) {
            Point.Builder pointBuilder = Point.measurement((measurement == null) ? record.measurement() : measurement).tag(FLOW_TYPE, String.valueOf(flowInfo.flowType())).tag(DEVICE_ID, flowInfo.deviceId().toString()).tag(INPUT_INTERFACE_ID, String.valueOf(flowInfo.inputInterfaceId())).tag(OUTPUT_INTERFACE_ID, String.valueOf(flowInfo.outputInterfaceId())).tag(VXLAN_ID, String.valueOf(flowInfo.vxlanId())).tag(SRC_IP, flowInfo.srcIp().toString()).tag(DST_IP, flowInfo.dstIp().toString()).tag(DST_PORT, getTpPort(flowInfo.dstPort())).tag(PROTOCOL, String.valueOf(flowInfo.protocol())).addField(STARTUP_TIME, flowInfo.statsInfo().startupTime()).addField(FST_PKT_ARR_TIME, flowInfo.statsInfo().fstPktArrTime()).addField(LST_PKT_OFFSET, flowInfo.statsInfo().lstPktOffset()).addField(PREV_ACC_BYTES, flowInfo.statsInfo().prevAccBytes()).addField(PREV_ACC_PKTS, flowInfo.statsInfo().prevAccPkts()).addField(CURR_ACC_BYTES, flowInfo.statsInfo().currAccBytes()).addField(CURR_ACC_PKTS, flowInfo.statsInfo().currAccPkts()).addField(ERROR_PKTS, flowInfo.statsInfo().errorPkts()).addField(DROP_PKTS, flowInfo.statsInfo().dropPkts());
            if (flowInfo.vlanId() != null) {
                pointBuilder.tag(VLAN_ID, flowInfo.vlanId().toString());
            }
            if (flowInfo.srcPort() != null) {
                pointBuilder.tag(SRC_PORT, getTpPort(flowInfo.srcPort()));
            }
            if (flowInfo.dstPort() != null) {
                pointBuilder.tag(DST_PORT, getTpPort(flowInfo.dstPort()));
            }
            batchPoints.point(pointBuilder.build());
        }
        v.write(batchPoints);
    });
}
Also used : FlowInfo(org.onosproject.openstacktelemetry.api.FlowInfo) InfluxDbTelemetryConfig(org.onosproject.openstacktelemetry.api.config.InfluxDbTelemetryConfig) BatchPoints(org.influxdb.dto.BatchPoints) Point(org.influxdb.dto.Point) DefaultInfluxDbTelemetryConfig.fromTelemetryConfig(org.onosproject.openstacktelemetry.config.DefaultInfluxDbTelemetryConfig.fromTelemetryConfig) InfluxDbTelemetryConfig(org.onosproject.openstacktelemetry.api.config.InfluxDbTelemetryConfig) TelemetryConfig(org.onosproject.openstacktelemetry.api.config.TelemetryConfig)

Aggregations

TelemetryConfig (org.onosproject.openstacktelemetry.api.config.TelemetryConfig)34 Test (org.junit.Test)10 DefaultTelemetryConfig (org.onosproject.openstacktelemetry.api.DefaultTelemetryConfig)10 Consumes (javax.ws.rs.Consumes)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 InputStream (java.io.InputStream)3 PUT (javax.ws.rs.PUT)3 TelemetryConfigAdminService (org.onosproject.openstacktelemetry.api.TelemetryConfigAdminService)3 TelemetryConfigService (org.onosproject.openstacktelemetry.api.TelemetryConfigService)3 InfluxDbTelemetryConfig (org.onosproject.openstacktelemetry.api.config.InfluxDbTelemetryConfig)3 KafkaTelemetryConfig (org.onosproject.openstacktelemetry.api.config.KafkaTelemetryConfig)3 RestTelemetryConfig (org.onosproject.openstacktelemetry.api.config.RestTelemetryConfig)3 TelemetryConfigJsonMatcher.matchesTelemetryConfig (org.onosproject.openstacktelemetry.codec.rest.TelemetryConfigJsonMatcher.matchesTelemetryConfig)3 DefaultInfluxDbTelemetryConfig.fromTelemetryConfig (org.onosproject.openstacktelemetry.config.DefaultInfluxDbTelemetryConfig.fromTelemetryConfig)3 DefaultKafkaTelemetryConfig.fromTelemetryConfig (org.onosproject.openstacktelemetry.config.DefaultKafkaTelemetryConfig.fromTelemetryConfig)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 TelemetryConfigProvider (org.onosproject.openstacktelemetry.api.TelemetryConfigProvider)2 PrometheusTelemetryConfig (org.onosproject.openstacktelemetry.api.config.PrometheusTelemetryConfig)2