diff --git a/config-templates/helm.json b/config-templates/helm.json index 01ed8362c..12ddf505a 100644 --- a/config-templates/helm.json +++ b/config-templates/helm.json @@ -101,6 +101,10 @@ "template": " --set logzio-k8s-telemetry.secrets.SpmToken='<>' \\" } ] + }, + { + "template": " --set logzio-k8s-telemetry.serviceGraph.enabled=true \\", + "targetElement": "datasources[?(@.name=='Kubernetes')].telemetries[?(@.type=='METRICS')].params[?(@.name == 'isServiceGraph')].value" } ] }, diff --git a/configs/2-1-k8s-eks.json b/configs/2-1-k8s-eks.json index b4a876715..13a66844a 100644 --- a/configs/2-1-k8s-eks.json +++ b/configs/2-1-k8s-eks.json @@ -70,6 +70,14 @@ "description": "", "hint": "Check this box if you want Logz.io Telemetry Collector to collect only the relevant system metrics to populate Kubernetes 360 and prebuilt dashboards. In addition, we will also collect application metrics that are exposed by your pods.", "value": true + }, + { + "type": "boolean", + "name": "isServiceGraph", + "label": "Collect Service Graph metrics", + "description": "", + "hint": "Check this box if you want Logz.io Telemetry Collector to collect Service Graph metrics to populate the Services Overview.", + "value": true } ], "dashboards": [ diff --git a/configs/2-2-k8s-aks.json b/configs/2-2-k8s-aks.json index df7dfbb84..18fbfbe8e 100644 --- a/configs/2-2-k8s-aks.json +++ b/configs/2-2-k8s-aks.json @@ -58,6 +58,14 @@ "hint": "Check this box if you want Logz.io Telemetry Collector to collect only the relevant system metrics to populate Kubernetes 360 and prebuilt dashboards. In addition, we will also collect application metrics that are exposed by your pods.", "value": true }, + { + "type": "boolean", + "name": "isServiceGraph", + "label": "Collect Service Graph metrics", + "description": "", + "hint": "Check this box if you want Logz.io Telemetry Collector to collect Service Graph metrics to populate the Services Overview.", + "value": true + }, { "type": "boolean", "name": "isWindows", diff --git a/configs/2-3-k8s-gke.json b/configs/2-3-k8s-gke.json index 26e2b8929..cce77508a 100644 --- a/configs/2-3-k8s-gke.json +++ b/configs/2-3-k8s-gke.json @@ -62,6 +62,14 @@ "description": "", "hint": "Check this box if you want Logz.io Telemetry Collector to collect only the relevant system metrics to populate Kubernetes 360 and prebuilt dashboards. In addition, we will also collect application metrics that are exposed by your pods.", "value": true + }, + { + "type": "boolean", + "name": "isServiceGraph", + "label": "Collect Service Graph metrics", + "description": "", + "hint": "Check this box if you want Logz.io Telemetry Collector to collect Service Graph metrics to populate the Services Overview.", + "value": true } ], "dashboards": [ diff --git a/configs/2-4-k8s-digitalocean.json b/configs/2-4-k8s-digitalocean.json index f7e889176..8d1fffb94 100644 --- a/configs/2-4-k8s-digitalocean.json +++ b/configs/2-4-k8s-digitalocean.json @@ -62,6 +62,14 @@ "description": "", "hint": "Check this box if you want Logz.io Telemetry Collector to collect only the relevant system metrics to populate Kubernetes 360 and prebuilt dashboards. In addition, we will also collect application metrics that are exposed by your pods.", "value": true + }, + { + "type": "boolean", + "name": "isServiceGraph", + "label": "Collect Service Graph metrics", + "description": "", + "hint": "Check this box if you want Logz.io Telemetry Collector to collect Service Graph metrics to populate the Services Overview.", + "value": true } ], "dashboards": [ diff --git a/datasources/linux/kubernetes/aks/kubernetes/telemetry/metrics/metrics.bash b/datasources/linux/kubernetes/aks/kubernetes/telemetry/metrics/metrics.bash index cf8cbaca9..b11fa83f7 100755 --- a/datasources/linux/kubernetes/aks/kubernetes/telemetry/metrics/metrics.bash +++ b/datasources/linux/kubernetes/aks/kubernetes/telemetry/metrics/metrics.bash @@ -36,3 +36,6 @@ if $IS_FILTER; then CLOUD_PROVIDER='aks' execute_task 'build_enable_metrics_filter_helm_set' 'Building enable metrics filter Helm set' fi +if $IS_SERVICE_GRAPH; then + execute_task 'build_enable_service_graph_helm_set' 'Building service graph Helm set' +fi \ No newline at end of file diff --git a/datasources/linux/kubernetes/digitalocean/kubernetes/telemetry/metrics/metrics.bash b/datasources/linux/kubernetes/digitalocean/kubernetes/telemetry/metrics/metrics.bash index 9a387b0db..eb5a2e7d5 100755 --- a/datasources/linux/kubernetes/digitalocean/kubernetes/telemetry/metrics/metrics.bash +++ b/datasources/linux/kubernetes/digitalocean/kubernetes/telemetry/metrics/metrics.bash @@ -30,3 +30,8 @@ if $IS_FILTER; then CLOUD_PROVIDER='aks' execute_task 'build_enable_metrics_filter_helm_set' 'Building enable metrics filter Helm set' fi +# Get if service graph option was selected +execute_task 'get_is_service_graph_was_selected' 'Getting is service graph option was selected' +if $IS_SERVICE_GRAPH; then + execute_task 'build_enable_service_graph_helm_set' 'Building service graph Helm set' +fi \ No newline at end of file diff --git a/datasources/linux/kubernetes/eks/kubernetes/telemetry/metrics/metrics.bash b/datasources/linux/kubernetes/eks/kubernetes/telemetry/metrics/metrics.bash index cc57706b4..05e9d2fff 100755 --- a/datasources/linux/kubernetes/eks/kubernetes/telemetry/metrics/metrics.bash +++ b/datasources/linux/kubernetes/eks/kubernetes/telemetry/metrics/metrics.bash @@ -34,3 +34,8 @@ if $IS_FARGATE; then # Build Fargate collector mode standalone Helm set execute_task 'build_fargate_collector_mode_standalone_helm_set' 'Building Fargate collector mode standalone Helm set' fi +# Get if service graph option was selected +execute_task 'get_is_service_graph_was_selected' 'Getting is service graph option was selected' +if $IS_SERVICE_GRAPH; then + execute_task 'build_enable_service_graph_helm_set' 'Building service graph Helm set' +fi \ No newline at end of file diff --git a/datasources/linux/kubernetes/gke/kubernetes/telemetry/metrics/metrics.bash b/datasources/linux/kubernetes/gke/kubernetes/telemetry/metrics/metrics.bash index 7dd821fc4..7f320b025 100755 --- a/datasources/linux/kubernetes/gke/kubernetes/telemetry/metrics/metrics.bash +++ b/datasources/linux/kubernetes/gke/kubernetes/telemetry/metrics/metrics.bash @@ -30,3 +30,8 @@ if $IS_FILTER; then CLOUD_PROVIDER='gke' execute_task 'build_enable_metrics_filter_helm_set' 'Building enable metrics filter Helm set' fi +# Get if service graph option was selected +execute_task 'get_is_service_graph_was_selected' 'Getting is service graph option was selected' +if $IS_SERVICE_GRAPH; then + execute_task 'build_enable_service_graph_helm_set' 'Building service graph Helm set' +fi \ No newline at end of file diff --git a/datasources/mac/kubernetes/aks/kubernetes/telemetry/metrics/metrics.bash b/datasources/mac/kubernetes/aks/kubernetes/telemetry/metrics/metrics.bash index 2dc565bc6..8396c3a68 100755 --- a/datasources/mac/kubernetes/aks/kubernetes/telemetry/metrics/metrics.bash +++ b/datasources/mac/kubernetes/aks/kubernetes/telemetry/metrics/metrics.bash @@ -36,3 +36,8 @@ if $IS_FILTER; then CLOUD_PROVIDER='aks' execute_task 'build_enable_metrics_filter_helm_set' 'Building enable metrics filter Helm set' fi +# Get if service graph option was selected +execute_task 'get_is_service_graph_was_selected' 'Getting is service graph option was selected' +if $IS_SERVICE_GRAPH; then + execute_task 'build_enable_service_graph_helm_set' 'Building service graph Helm set' +fi \ No newline at end of file diff --git a/datasources/mac/kubernetes/digitalocean/kubernetes/telemetry/metrics/metrics.bash b/datasources/mac/kubernetes/digitalocean/kubernetes/telemetry/metrics/metrics.bash index c46678a1d..b53d94d5e 100755 --- a/datasources/mac/kubernetes/digitalocean/kubernetes/telemetry/metrics/metrics.bash +++ b/datasources/mac/kubernetes/digitalocean/kubernetes/telemetry/metrics/metrics.bash @@ -30,3 +30,8 @@ if $IS_FILTER; then CLOUD_PROVIDER='aks' execute_task 'build_enable_metrics_filter_helm_set' 'Building enable metrics filter Helm set' fi +# Get if service graph option was selected +execute_task 'get_is_service_graph_was_selected' 'Getting is service graph option was selected' +if $IS_SERVICE_GRAPH; then + execute_task 'build_enable_service_graph_helm_set' 'Building service graph Helm set' +fi \ No newline at end of file diff --git a/datasources/mac/kubernetes/eks/kubernetes/telemetry/metrics/metrics.bash b/datasources/mac/kubernetes/eks/kubernetes/telemetry/metrics/metrics.bash index 3ee1a8075..7088a74d5 100755 --- a/datasources/mac/kubernetes/eks/kubernetes/telemetry/metrics/metrics.bash +++ b/datasources/mac/kubernetes/eks/kubernetes/telemetry/metrics/metrics.bash @@ -34,3 +34,8 @@ if $IS_FARGATE; then # Build Fargate collector mode standalone Helm set execute_task 'build_fargate_collector_mode_standalone_helm_set' 'Building Fargate collector mode standalone Helm set' fi +# Get if service graph option was selected +execute_task 'get_is_service_graph_was_selected' 'Getting is service graph option was selected' +if $IS_SERVICE_GRAPH; then + execute_task 'build_enable_service_graph_helm_set' 'Building service graph Helm set' +fi \ No newline at end of file diff --git a/datasources/mac/kubernetes/gke/kubernetes/telemetry/metrics/metrics.bash b/datasources/mac/kubernetes/gke/kubernetes/telemetry/metrics/metrics.bash index d00c3bb8f..96bd7dcd6 100755 --- a/datasources/mac/kubernetes/gke/kubernetes/telemetry/metrics/metrics.bash +++ b/datasources/mac/kubernetes/gke/kubernetes/telemetry/metrics/metrics.bash @@ -30,3 +30,8 @@ if $IS_FILTER; then CLOUD_PROVIDER='gke' execute_task 'build_enable_metrics_filter_helm_set' 'Building enable metrics filter Helm set' fi +# Get if service graph option was selected +execute_task 'get_is_service_graph_was_selected' 'Getting is service graph option was selected' +if $IS_SERVICE_GRAPH; then + execute_task 'build_enable_service_graph_helm_set' 'Building service graph Helm set' +fi \ No newline at end of file diff --git a/datasources/windows/kubernetes/aks/kubernetes/telemetry/metrics/functions.ps1 b/datasources/windows/kubernetes/aks/kubernetes/telemetry/metrics/functions.ps1 index 06a3542dd..a643259f8 100755 --- a/datasources/windows/kubernetes/aks/kubernetes/telemetry/metrics/functions.ps1 +++ b/datasources/windows/kubernetes/aks/kubernetes/telemetry/metrics/functions.ps1 @@ -259,3 +259,77 @@ function Build-EnableMetricsFilterHelmSet { Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" } + +# Gets is service graph was selected +# Input: +# FuncArgs - Hashtable {MetricsParams = $script:MetricsParams} +# Output: +# IsServiceGraph - Tells if service graph was selected (true/false) +function Get-IsServiceGraphWasSelected { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 4 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting if service graph option was selected ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('MetricsParams') + if ($Err.Count -ne 0) { + $Message = "metrics.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:MetricsParams = $FuncArgs.MetricsParams + + $Err = Get-ParamValue $MetricsParams 'isServiceGraph' + if ($Err.Count -ne 0) { + $Message = "metrics.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:IsServiceGraph = $script:ParamValue + + if ($IsServiceGraph) { + $Message = 'Service Graph option was selected' + } + else { + $Message = 'Service Graph option was not selected' + } + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:IsServiceGraph = `$$IsServiceGraph" +} + +# Builds enable service graph Helm set +# Input: +# --- +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# HelmSets - Contains all the Helm sets +function Build-EnableServiceGraphHelmSet { + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building service graph Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:HelmSet = " --set logzio-k8s-telemetry.serviceGraph.enabled=true" + + $local:Message = "Enable service graph Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} diff --git a/datasources/windows/kubernetes/aks/kubernetes/telemetry/metrics/metrics.ps1 b/datasources/windows/kubernetes/aks/kubernetes/telemetry/metrics/metrics.ps1 index 5d094bc0c..4fa24689f 100755 --- a/datasources/windows/kubernetes/aks/kubernetes/telemetry/metrics/metrics.ps1 +++ b/datasources/windows/kubernetes/aks/kubernetes/telemetry/metrics/metrics.ps1 @@ -60,6 +60,11 @@ if ($script:IsFilter) { # Build enable metrics filter Helm set Invoke-Task 'Build-EnableMetricsFilterHelmSet' @{} 'Building enable metrics filter Helm set' @($MetricsFunctionsScript) } - +# Get if service graph option was selected +Invoke-Task 'Get-IsServiceGraphWasSelected' @{MetricsParams = $script:MetricsParams} 'Getting if service graph was selected' @($MetricsFunctionsScript) +if ($script:IsServiceGraph) { + # Build enable metrics filter Helm set + Invoke-Task 'Build-EnableServiceGraphHelmSet' @{} 'Building enable service graph Helm set' @($MetricsFunctionsScript) +} # Finished successfully Exit 0 diff --git a/datasources/windows/kubernetes/digitalocean/kubernetes/telemetry/metrics/functions.ps1 b/datasources/windows/kubernetes/digitalocean/kubernetes/telemetry/metrics/functions.ps1 index 51612b043..87d8084a3 100755 --- a/datasources/windows/kubernetes/digitalocean/kubernetes/telemetry/metrics/functions.ps1 +++ b/datasources/windows/kubernetes/digitalocean/kubernetes/telemetry/metrics/functions.ps1 @@ -208,3 +208,77 @@ function Build-EnableMetricsFilterHelmSet { Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" } + +# Gets is service graph was selected +# Input: +# FuncArgs - Hashtable {MetricsParams = $script:MetricsParams} +# Output: +# IsServiceGraph - Tells if service graph was selected (true/false) +function Get-IsServiceGraphWasSelected { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 4 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting if service graph option was selected ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('MetricsParams') + if ($Err.Count -ne 0) { + $Message = "metrics.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:MetricsParams = $FuncArgs.MetricsParams + + $Err = Get-ParamValue $MetricsParams 'isServiceGraph' + if ($Err.Count -ne 0) { + $Message = "metrics.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:IsServiceGraph = $script:ParamValue + + if ($IsServiceGraph) { + $Message = 'Service Graph option was selected' + } + else { + $Message = 'Service Graph option was not selected' + } + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:IsServiceGraph = `$$IsServiceGraph" +} + +# Builds enable service graph Helm set +# Input: +# --- +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# HelmSets - Contains all the Helm sets +function Build-EnableServiceGraphHelmSet { + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building service graph Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:HelmSet = " --set logzio-k8s-telemetry.serviceGraph.enabled=true" + + $local:Message = "Enable service graph Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} diff --git a/datasources/windows/kubernetes/digitalocean/kubernetes/telemetry/metrics/metrics.ps1 b/datasources/windows/kubernetes/digitalocean/kubernetes/telemetry/metrics/metrics.ps1 index fd2b3a826..1a64f27c7 100755 --- a/datasources/windows/kubernetes/digitalocean/kubernetes/telemetry/metrics/metrics.ps1 +++ b/datasources/windows/kubernetes/digitalocean/kubernetes/telemetry/metrics/metrics.ps1 @@ -26,6 +26,11 @@ if ($script:IsFilter) { # Build enable metrics filter Helm set Invoke-Task 'Build-EnableMetricsFilterHelmSet' @{} 'Building enable metrics filter Helm set' @($MetricsFunctionsScript) } - +# Get if service graph option was selected +Invoke-Task 'Get-IsServiceGraphWasSelected' @{MetricsParams = $script:MetricsParams} 'Getting if service graph was selected' @($MetricsFunctionsScript) +if ($script:IsServiceGraph) { + # Build enable metrics filter Helm set + Invoke-Task 'Build-EnableServiceGraphHelmSet' @{} 'Building enable service graph Helm set' @($MetricsFunctionsScript) +} # Finished successfully Exit 0 diff --git a/datasources/windows/kubernetes/eks/kubernetes/telemetry/metrics/functions.ps1 b/datasources/windows/kubernetes/eks/kubernetes/telemetry/metrics/functions.ps1 index e54a3db35..a0ed95cba 100755 --- a/datasources/windows/kubernetes/eks/kubernetes/telemetry/metrics/functions.ps1 +++ b/datasources/windows/kubernetes/eks/kubernetes/telemetry/metrics/functions.ps1 @@ -231,3 +231,77 @@ function Build-FargateCollectorModeStandaloneHelmSet { Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" } + +# Gets is service graph was selected +# Input: +# FuncArgs - Hashtable {MetricsParams = $script:MetricsParams} +# Output: +# IsServiceGraph - Tells if service graph was selected (true/false) +function Get-IsServiceGraphWasSelected { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 4 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting if service graph option was selected ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('MetricsParams') + if ($Err.Count -ne 0) { + $Message = "metrics.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:MetricsParams = $FuncArgs.MetricsParams + + $Err = Get-ParamValue $MetricsParams 'isServiceGraph' + if ($Err.Count -ne 0) { + $Message = "metrics.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:IsServiceGraph = $script:ParamValue + + if ($IsServiceGraph) { + $Message = 'Service Graph option was selected' + } + else { + $Message = 'Service Graph option was not selected' + } + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:IsServiceGraph = `$$IsServiceGraph" +} + +# Builds enable service graph Helm set +# Input: +# --- +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# HelmSets - Contains all the Helm sets +function Build-EnableServiceGraphHelmSet { + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building service graph Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:HelmSet = " --set logzio-k8s-telemetry.serviceGraph.enabled=true" + + $local:Message = "Enable service graph Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} diff --git a/datasources/windows/kubernetes/eks/kubernetes/telemetry/metrics/metrics.ps1 b/datasources/windows/kubernetes/eks/kubernetes/telemetry/metrics/metrics.ps1 index d97b0748e..c326a44c3 100755 --- a/datasources/windows/kubernetes/eks/kubernetes/telemetry/metrics/metrics.ps1 +++ b/datasources/windows/kubernetes/eks/kubernetes/telemetry/metrics/metrics.ps1 @@ -30,6 +30,11 @@ if ($script:IsFargate) { # Build Fargate collector mode standalone Helm set Invoke-Task 'Build-FargateCollectorModeStandaloneHelmSet' @{} 'Building Fargate collector mode standalone Helm set' @($MetricsFunctionsScript) } - +# Get if service graph option was selected +Invoke-Task 'Get-IsServiceGraphWasSelected' @{MetricsParams = $script:MetricsParams} 'Getting if service graph was selected' @($MetricsFunctionsScript) +if ($script:IsServiceGraph) { + # Build enable metrics filter Helm set + Invoke-Task 'Build-EnableServiceGraphHelmSet' @{} 'Building enable service graph Helm set' @($MetricsFunctionsScript) +} # Finished successfully Exit 0 diff --git a/datasources/windows/kubernetes/gke/kubernetes/telemetry/metrics/functions.ps1 b/datasources/windows/kubernetes/gke/kubernetes/telemetry/metrics/functions.ps1 index 51612b043..87d8084a3 100755 --- a/datasources/windows/kubernetes/gke/kubernetes/telemetry/metrics/functions.ps1 +++ b/datasources/windows/kubernetes/gke/kubernetes/telemetry/metrics/functions.ps1 @@ -208,3 +208,77 @@ function Build-EnableMetricsFilterHelmSet { Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" } + +# Gets is service graph was selected +# Input: +# FuncArgs - Hashtable {MetricsParams = $script:MetricsParams} +# Output: +# IsServiceGraph - Tells if service graph was selected (true/false) +function Get-IsServiceGraphWasSelected { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 4 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting if service graph option was selected ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('MetricsParams') + if ($Err.Count -ne 0) { + $Message = "metrics.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:MetricsParams = $FuncArgs.MetricsParams + + $Err = Get-ParamValue $MetricsParams 'isServiceGraph' + if ($Err.Count -ne 0) { + $Message = "metrics.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:IsServiceGraph = $script:ParamValue + + if ($IsServiceGraph) { + $Message = 'Service Graph option was selected' + } + else { + $Message = 'Service Graph option was not selected' + } + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:IsServiceGraph = `$$IsServiceGraph" +} + +# Builds enable service graph Helm set +# Input: +# --- +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# HelmSets - Contains all the Helm sets +function Build-EnableServiceGraphHelmSet { + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building service graph Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:HelmSet = " --set logzio-k8s-telemetry.serviceGraph.enabled=true" + + $local:Message = "Enable service graph Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepMetrics $script:LogScriptMetrics $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} diff --git a/datasources/windows/kubernetes/gke/kubernetes/telemetry/metrics/metrics.ps1 b/datasources/windows/kubernetes/gke/kubernetes/telemetry/metrics/metrics.ps1 index fd2b3a826..1a64f27c7 100755 --- a/datasources/windows/kubernetes/gke/kubernetes/telemetry/metrics/metrics.ps1 +++ b/datasources/windows/kubernetes/gke/kubernetes/telemetry/metrics/metrics.ps1 @@ -26,6 +26,11 @@ if ($script:IsFilter) { # Build enable metrics filter Helm set Invoke-Task 'Build-EnableMetricsFilterHelmSet' @{} 'Building enable metrics filter Helm set' @($MetricsFunctionsScript) } - +# Get if service graph option was selected +Invoke-Task 'Get-IsServiceGraphWasSelected' @{MetricsParams = $script:MetricsParams} 'Getting if service graph was selected' @($MetricsFunctionsScript) +if ($script:IsServiceGraph) { + # Build enable metrics filter Helm set + Invoke-Task 'Build-EnableServiceGraphHelmSet' @{} 'Building enable service graph Helm set' @($MetricsFunctionsScript) +} # Finished successfully Exit 0 diff --git a/resources-linux/k8s/datasource_metrics_utils.bash b/resources-linux/k8s/datasource_metrics_utils.bash index 3d9f01f38..f437ac1b2 100755 --- a/resources-linux/k8s/datasource_metrics_utils.bash +++ b/resources-linux/k8s/datasource_metrics_utils.bash @@ -131,3 +131,60 @@ function build_enable_metrics_filter_helm_set { write_task_post_run "LOG_HELM_SETS+='$helm_set'" write_task_post_run "HELM_SETS+='$helm_set'" } + +# Gets is service graph was selected +# Input: +# --- +# Output: +# IS_SERVICE_GRAPH - Tells if service graph was selected (true/false) +function get_is_service_graph_was_selected { + local func_name="${FUNCNAME[0]}" + + local message='Getting is Service Graph metrics option was selected ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_METRICS" "$LOG_SCRIPT_METRICS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + PARAMS=("${METRICS_PARAMS[@]}") + get_param_value 'isServiceGraph' + if [[ $? -ne 0 ]]; then + message="metrics.bash ($EXIT_CODE): $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_METRICS" "$LOG_SCRIPT_METRICS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_task_post_run "write_error \"$message\"" + + return $EXIT_CODE + fi + + local is_servicegraph=$PARAM_VALUE + + if $is_servicegraph; then + message='Service Graph metrics option was selected' + else + message='Service Graph metrics option was not selected' + fi + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_METRICS" "$LOG_SCRIPT_METRICS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "IS_SERVICE_GRAPH=$is_servicegraph" +} +# Builds enable service graph Helm set +# Input: +# --- +# Output: +# LOG_HELM_SETS - Contains all the Helm sets for logging +# HELM_SETS - Contains all the Helm sets +function build_enable_service_graph_helm_set { + local func_name="${FUNCNAME[0]}" + + local message='Building enable service graph Helm set ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_METRICS" "$LOG_SCRIPT_METRICS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + local helm_set=" --set logzio-k8s-telemetry.serviceGraph.enabled=$IS_SERVICE_GRAPH" + + message="Enable service graph Helm set is '$helm_set'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_METRICS" "$LOG_SCRIPT_METRICS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "LOG_HELM_SETS+='$helm_set'" + write_task_post_run "HELM_SETS+='$helm_set'" +} diff --git a/resources-mac/k8s/datasource_metrics_utils.bash b/resources-mac/k8s/datasource_metrics_utils.bash index 6398da413..83280566c 100755 --- a/resources-mac/k8s/datasource_metrics_utils.bash +++ b/resources-mac/k8s/datasource_metrics_utils.bash @@ -131,3 +131,60 @@ function build_enable_metrics_filter_helm_set { write_task_post_run "LOG_HELM_SETS+='$helm_set'" write_task_post_run "HELM_SETS+='$helm_set'" } + +# Gets is service graph was selected +# Input: +# --- +# Output: +# IS_SERVICE_GRAPH - Tells if service graph was selected (true/false) +function get_is_service_graph_was_selected { + local func_name="${FUNCNAME[0]}" + + local message='Getting is Service Graph metrics option was selected ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_METRICS" "$LOG_SCRIPT_METRICS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + PARAMS=("${METRICS_PARAMS[@]}") + get_param_value 'isServiceGraph' + if [[ $? -ne 0 ]]; then + message="metrics.bash ($EXIT_CODE): $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_METRICS" "$LOG_SCRIPT_METRICS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_task_post_run "write_error \"$message\"" + + return $EXIT_CODE + fi + + local is_servicegraph=$PARAM_VALUE + + if $is_servicegraph; then + message='Service Graph metrics option was selected' + else + message='Service Graph metrics option was not selected' + fi + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_METRICS" "$LOG_SCRIPT_METRICS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "IS_SERVICE_GRAPH=$is_servicegraph" +} +# Builds enable service graph Helm set +# Input: +# --- +# Output: +# LOG_HELM_SETS - Contains all the Helm sets for logging +# HELM_SETS - Contains all the Helm sets +function build_enable_service_graph_helm_set { + local func_name="${FUNCNAME[0]}" + + local message='Building enable service graph Helm set ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_METRICS" "$LOG_SCRIPT_METRICS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + local helm_set=" --set logzio-k8s-telemetry.serviceGraph.enabled=$IS_SERVICE_GRAPH" + + message="Enable service graph Helm set is '$helm_set'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_METRICS" "$LOG_SCRIPT_METRICS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "LOG_HELM_SETS+='$helm_set'" + write_task_post_run "HELM_SETS+='$helm_set'" +} \ No newline at end of file