use of org.graylog2.contentpacks.model.entities.EntityDescriptor in project graylog2-server by Graylog2.
the class InputFacade method exportEntity.
@Override
public Optional<Entity> exportEntity(EntityDescriptor entityDescriptor, EntityDescriptorIds entityDescriptorIds) {
final ModelId modelId = entityDescriptor.id();
try {
final Input input = inputService.find(modelId.id());
final InputWithExtractors inputWithExtractors = InputWithExtractors.create(input, inputService.getExtractors(input));
return Optional.of(exportNativeEntity(inputWithExtractors, entityDescriptorIds));
} catch (NotFoundException e) {
return Optional.empty();
}
}
use of org.graylog2.contentpacks.model.entities.EntityDescriptor in project graylog2-server by Graylog2.
the class GrokPatternFacade method resolveForInstallationV1.
private Graph<Entity> resolveForInstallationV1(EntityV1 entity, Map<EntityDescriptor, Entity> entities) {
final MutableGraph<Entity> mutableGraph = GraphBuilder.directed().build();
mutableGraph.addNode(entity);
final GrokPatternEntity grokPatternEntity = objectMapper.convertValue(entity.data(), GrokPatternEntity.class);
final String namedPattern = grokPatternEntity.pattern();
final Set<String> patterns = GrokPatternService.extractPatternNames(namedPattern);
patterns.stream().forEach(patternName -> {
entities.entrySet().stream().filter(x -> x.getValue().type().equals(ModelTypes.GROK_PATTERN_V1)).filter(x -> {
EntityV1 entityV1 = (EntityV1) x.getValue();
GrokPatternEntity grokPatternEntity1 = objectMapper.convertValue(entityV1.data(), GrokPatternEntity.class);
return grokPatternEntity1.name().equals(patternName);
}).forEach(x -> mutableGraph.putEdge(entity, x.getValue()));
});
return ImmutableGraph.copyOf(mutableGraph);
}
use of org.graylog2.contentpacks.model.entities.EntityDescriptor in project graylog2-server by Graylog2.
the class GrokPatternFacade method resolveNativeEntity.
@Override
public Graph<EntityDescriptor> resolveNativeEntity(EntityDescriptor entityDescriptor) {
final MutableGraph<EntityDescriptor> mutableGraph = GraphBuilder.directed().build();
mutableGraph.addNode(entityDescriptor);
final ModelId modelId = entityDescriptor.id();
try {
final GrokPattern grokPattern = grokPatternService.load(modelId.id());
final String namedPattern = grokPattern.pattern();
final Set<String> patterns = GrokPatternService.extractPatternNames(namedPattern);
patterns.stream().forEach(patternName -> {
grokPatternService.loadByName(patternName).ifPresent(depPattern -> {
final EntityDescriptor depEntityDescriptor = EntityDescriptor.create(depPattern.id(), ModelTypes.GROK_PATTERN_V1);
mutableGraph.putEdge(entityDescriptor, depEntityDescriptor);
});
});
} catch (NotFoundException e) {
LOG.debug("Couldn't find grok pattern {}", entityDescriptor, e);
}
return mutableGraph;
}
use of org.graylog2.contentpacks.model.entities.EntityDescriptor in project graylog2-server by Graylog2.
the class SidecarCollectorConfigurationFacade method resolveEntityV1.
private Graph<Entity> resolveEntityV1(EntityV1 entity, Map<String, ValueReference> parameters, Map<EntityDescriptor, Entity> entities) {
final MutableGraph<Entity> mutableGraph = GraphBuilder.directed().build();
mutableGraph.addNode(entity);
final SidecarCollectorConfigurationEntity configurationEntity = objectMapper.convertValue(entity.data(), SidecarCollectorConfigurationEntity.class);
final EntityDescriptor collectorDescriptor = EntityDescriptor.create(configurationEntity.collectorId().asString(parameters), ModelTypes.SIDECAR_COLLECTOR_V1);
final Entity collectorEntity = entities.get(collectorDescriptor);
if (collectorEntity != null) {
mutableGraph.putEdge(entity, collectorEntity);
}
return ImmutableGraph.copyOf(mutableGraph);
}
use of org.graylog2.contentpacks.model.entities.EntityDescriptor in project graylog2-server by Graylog2.
the class StreamFacade method resolveNativeEntity.
@Override
public Graph<EntityDescriptor> resolveNativeEntity(EntityDescriptor entityDescriptor) {
final MutableGraph<EntityDescriptor> mutableGraph = GraphBuilder.directed().build();
mutableGraph.addNode(entityDescriptor);
final ModelId modelId = entityDescriptor.id();
try {
final Stream stream = streamService.load(modelId.id());
stream.getOutputs().stream().map(Output::getId).map(ModelId::of).map(id -> EntityDescriptor.create(id, ModelTypes.OUTPUT_V1)).forEach(output -> mutableGraph.putEdge(entityDescriptor, output));
} catch (NotFoundException e) {
LOG.debug("Couldn't find stream {}", entityDescriptor, e);
}
return ImmutableGraph.copyOf(mutableGraph);
}
Aggregations