From 9eab4f99b23bd91b6fa1a0d0acb723cd24536000 Mon Sep 17 00:00:00 2001 From: 8naama Date: Wed, 7 Aug 2024 15:14:45 +0300 Subject: [PATCH] remove hardcoded version in otel conf --- .../localhost/windows/system/telemetry/logs/functions.ps1 | 5 +++++ .../localhost/windows/system/telemetry/metrics/functions.ps1 | 5 +++++ resources-linux/otel/datasource_logs_utils.bash | 5 +++++ resources-linux/otel/datasource_metrics_utils.bash | 5 +++++ resources-mac/otel/datasource_logs_utils.bash | 5 +++++ resources-mac/otel/datasource_metrics_utils.bash | 5 +++++ resources/otel/processors/resource_agent.yaml | 2 +- 7 files changed, 31 insertions(+), 1 deletion(-) diff --git a/datasources/windows/localhost/windows/system/telemetry/logs/functions.ps1 b/datasources/windows/localhost/windows/system/telemetry/logs/functions.ps1 index d3ce30772..f5bdd05e2 100755 --- a/datasources/windows/localhost/windows/system/telemetry/logs/functions.ps1 +++ b/datasources/windows/localhost/windows/system/telemetry/logs/functions.ps1 @@ -504,6 +504,11 @@ function Add-LogsProcessorsToOtelConfig { foreach ($LogsOtelProcessor in $LogsOtelProcessors) { $local:ProcessorName = $LogsOtelProcessor.Replace('_', '/') + if ($ProcessorName -eq 'resource_agent') { + $local:AgentVersion = Get-Content "$env:TEMP\Logzio\version" + $Err = Add-YamlFileFieldValue "$script:OtelResourcesDir\$script:OtelConfigName" '.processors.resource/agent.attributes[0].value' $AgentVersion + } + $Err = Add-YamlFileFieldValue "$script:OtelResourcesDir\$script:OtelConfigName" '.service.pipelines.logs.processors' $ProcessorName if ($Err.Count -ne 0) { $Message = "logs.ps1 ($ExitCode): $($Err[0])" diff --git a/datasources/windows/localhost/windows/system/telemetry/metrics/functions.ps1 b/datasources/windows/localhost/windows/system/telemetry/metrics/functions.ps1 index 0adf307f1..748969334 100755 --- a/datasources/windows/localhost/windows/system/telemetry/metrics/functions.ps1 +++ b/datasources/windows/localhost/windows/system/telemetry/metrics/functions.ps1 @@ -302,6 +302,11 @@ function Add-MetricsProcessorsToOtelConfig { foreach ($MetricsOtelProcessor in $MetricsOtelProcessors) { $local:ProcessorName = $MetricsOtelProcessor.Replace('_', '/') + if ($ProcessorName -eq 'resource_agent') { + $local:AgentVersion = Get-Content "$env:TEMP\Logzio\version" + $Err = Add-YamlFileFieldValue "$script:OtelResourcesDir\$script:OtelConfigName" '.processors.resource/agent.attributes[0].value' $AgentVersion + } + $Err = Add-YamlFileFieldValue "$script:OtelResourcesDir\$script:OtelConfigName" '.service.pipelines.metrics.processors' $ProcessorName if ($Err.Count -ne 0) { $Message = "metrics.ps1 ($ExitCode): $($Err[0])" diff --git a/resources-linux/otel/datasource_logs_utils.bash b/resources-linux/otel/datasource_logs_utils.bash index 3ad6c8253..c7c151b58 100755 --- a/resources-linux/otel/datasource_logs_utils.bash +++ b/resources-linux/otel/datasource_logs_utils.bash @@ -196,6 +196,11 @@ function add_logs_processors_to_otel_config { for logs_otel_processor in "${LOGS_OTEL_PROCESSORS[@]}"; do local processor_name="${logs_otel_processor//_//}" + if [[ $processor_name == 'resource_agent' ]] ; then + AGENT_VERSION=$(cat '/tmp/logzio/version') + add_yaml_file_field_value "$OTEL_RESOURCES_DIR/$OTEL_CONFIG_NAME" '.processors.resource/agent.attributes[0].value' "$AGENT_VERSION" + fi + add_yaml_file_field_value "$OTEL_RESOURCES_DIR/$OTEL_CONFIG_NAME" '.service.pipelines.logs.processors' $processor_name if [[ $? -ne 0 ]]; then message="logs.bash ($EXIT_CODE): $(get_task_error_message)" diff --git a/resources-linux/otel/datasource_metrics_utils.bash b/resources-linux/otel/datasource_metrics_utils.bash index efe5d769f..aae3e996a 100755 --- a/resources-linux/otel/datasource_metrics_utils.bash +++ b/resources-linux/otel/datasource_metrics_utils.bash @@ -217,6 +217,11 @@ function add_metrics_processors_to_otel_config { for metrics_otel_processor in "${METRICS_OTEL_PROCESSORS[@]}"; do local processor_name="${metrics_otel_processor//_//}" + if [[ $processor_name == 'resource_agent' ]] ; then + AGENT_VERSION=$(cat '/tmp/logzio/version') + add_yaml_file_field_value "$OTEL_RESOURCES_DIR/$OTEL_CONFIG_NAME" '.processors.resource/agent.attributes[0].value' "$AGENT_VERSION" + fi + add_yaml_file_field_value "$OTEL_RESOURCES_DIR/$OTEL_CONFIG_NAME" '.service.pipelines.metrics.processors' "$processor_name" if [[ $? -ne 0 ]]; then message="metrics.bash ($EXIT_CODE): $(get_task_error_message)" diff --git a/resources-mac/otel/datasource_logs_utils.bash b/resources-mac/otel/datasource_logs_utils.bash index ff5cd7d13..2ee253fe2 100755 --- a/resources-mac/otel/datasource_logs_utils.bash +++ b/resources-mac/otel/datasource_logs_utils.bash @@ -197,6 +197,11 @@ function add_logs_processors_to_otel_config { for logs_otel_processor in "${LOGS_OTEL_PROCESSORS[@]}"; do local processor_name="${logs_otel_processor//_//}" + if [[ $processor_name == 'resource_agent' ]] ; then + AGENT_VERSION=$(cat '/tmp/logzio/version') + add_yaml_file_field_value "$OTEL_RESOURCES_DIR/$OTEL_CONFIG_NAME" '.processors.resource/agent.attributes[0].value' "$AGENT_VERSION" + fi + add_yaml_file_field_value "$OTEL_RESOURCES_DIR/$OTEL_CONFIG_NAME" '.service.pipelines.logs.processors' $processor_name if [[ $? -ne 0 ]]; then message="logs.bash ($EXIT_CODE): $(get_task_error_message)" diff --git a/resources-mac/otel/datasource_metrics_utils.bash b/resources-mac/otel/datasource_metrics_utils.bash index 0e9d80cce..e4a19ff0c 100755 --- a/resources-mac/otel/datasource_metrics_utils.bash +++ b/resources-mac/otel/datasource_metrics_utils.bash @@ -217,6 +217,11 @@ function add_metrics_processors_to_otel_config { for metrics_otel_processor in "${METRICS_OTEL_PROCESSORS[@]}"; do local processor_name="${metrics_otel_processor//_//}" + if [[ $processor_name == 'resource_agent' ]] ; then + AGENT_VERSION=$(cat '/tmp/logzio/version') + add_yaml_file_field_value "$OTEL_RESOURCES_DIR/$OTEL_CONFIG_NAME" '.processors.resource/agent.attributes[0].value' "$AGENT_VERSION" + fi + add_yaml_file_field_value "$OTEL_RESOURCES_DIR/$OTEL_CONFIG_NAME" '.service.pipelines.metrics.processors' "$processor_name" if [[ $? -ne 0 ]]; then message="metrics.bash ($EXIT_CODE): $(get_task_error_message)" diff --git a/resources/otel/processors/resource_agent.yaml b/resources/otel/processors/resource_agent.yaml index 5e660048b..94f022f2c 100644 --- a/resources/otel/processors/resource_agent.yaml +++ b/resources/otel/processors/resource_agent.yaml @@ -1,5 +1,5 @@ resource/agent: attributes: - key: logzio_agent_version - value: v1.1.34 + value: action: upsert \ No newline at end of file