Skip to content

Commit

Permalink
feat: add docs for reading dns logs from file
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasmueller committed May 29, 2024
1 parent 9f530e7 commit c424400
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AggregatorManager(aggregationConfig: AggregationConfig) {
}

kubernetesConfig.aggregators.dns?.ifEnabled { dnsAggregatorConfig ->
val config = KubernetesDnsAggregator.Config(kubernetesConfig.namespaces, kubernetesConfig.includeKubeNamespaces, dnsAggregatorConfig.logsSinceTime)
val config = KubernetesDnsAggregator.Config(kubernetesConfig.namespaces, kubernetesConfig.includeKubeNamespaces, dnsAggregatorConfig.logsSinceTime, dnsAggregatorConfig.useLogsFromFile, dnsAggregatorConfig.pathToDnsLogs)
add(KubernetesDnsAggregator(config, KubernetesClientFabric8()))
log.info { "Registered aggregator: Kubernetes DNS" }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class KubernetesDnsAggregator(
val namespaces: List<Namespace>,
val includeKubeNamespaces: Boolean,
val sinceTime: String,
val useLogsFromFile: Boolean = false
val useLogsFromFile: Boolean = false,
val pathToDnsLogs: String = "",
)

private val log = KotlinLogging.logger {}
Expand All @@ -35,7 +36,7 @@ class KubernetesDnsAggregator(
.getOrElse { return Either.Left(DnsAggregationFailure(it.description)) }
else {
runCatching {
val logFile = File("/app/resources/dnslogs")
val logFile = File(config.pathToDnsLogs)
val logLine = logFile.readLines().joinToString("\n" )
listOf(logLine)
}.getOrElse { return Either.Left(DnsAggregationFailure("${it.message}")) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ data class AggregationConfig(
data class DnsAggregator(
override val enable: Boolean = true,
val logsSinceTime: String = "",
val useLogsFromFile: Boolean = false,
val pathToDnsLogs: String = "",
) : Enable

data class SyftSbomAggregator(
Expand Down
4 changes: 3 additions & 1 deletion clara-app/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ aggregation:
kube-api:
dns:
logs-since-time: 2024-03-27T00:00:00Z
use-logs-from-file: false
path-to-dns-logs: "/home/user/clara/dnslogs"
open-telemetry:
listen-port: 7878
listen-duration: 10 seconds
syft-sbom:
sbom-file-path: sbom/
use-stored-sbom-files: false
use-stored-sbom-files: true

merge:
comparison-strategy: Equals
Expand Down
10 changes: 10 additions & 0 deletions docs/content/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ All options with a default value are optional.
This option defines how recent the logs must be to be considered by CLARA.
If this option is just an empty String (the default), all available logs will be used, which can lead to unwanted side effects, like old logs from a previous version of the deployment polluting the recovered architecture.

??? config-option "**_aggregation.platforms.kubernetes.aggregators.dns.use-logs-from-file_**"
- Type: Boolean
- Default: true
- Description: Simple way to switch if the DNS logs should be read from a file instead the Kubernetes API directly.

??? config-option "**_aggregation.platforms.kubernetes.aggregators.dns.path-to-dns-logs_**"
- Type: String
- Default: empty String
- Description: The DNS aggregator when used with files instead of the API must obtain an absolute path to the file.

#### Aggregator: OpenTelemetry (optional)

??? config-option "**_aggregation.platforms.kubernetes.aggregators.open-telemetry.enable_**"
Expand Down

0 comments on commit c424400

Please sign in to comment.