From ccf492e6cc5b95a03e458748a8676a218925c5ca Mon Sep 17 00:00:00 2001 From: kkhandelwal Date: Fri, 3 Oct 2025 13:45:43 +0530 Subject: [PATCH] enable spans and add default log path in the config --- recipes/newrelic/ebpf/centos.yml | 93 ++++++++++++++++++++++------ recipes/newrelic/ebpf/ubuntu.yml | 100 +++++++++++++++++++++++-------- 2 files changed, 150 insertions(+), 43 deletions(-) diff --git a/recipes/newrelic/ebpf/centos.yml b/recipes/newrelic/ebpf/centos.yml index 5cb8cdaa3..43ce26eb4 100644 --- a/recipes/newrelic/ebpf/centos.yml +++ b/recipes/newrelic/ebpf/centos.yml @@ -61,6 +61,14 @@ install: - task: disable_service_for_agent_control assert_pre_req: + status: + - | + if [ "${FORCE_INSTALL:-}" = "true" ]; then + echo "Force install enabled - skipping pre-requisite checks" + exit 0 + fi + # If FORCE_INSTALL is not true, we want the task to run normally + exit 1 cmds: - | IS_ROOT_OR_SUDO=$([ ! -z "$SUDO_USER" ] || [ $(whoami) = "root" ] && echo "true" || echo "false") # Assert root or sudo user @@ -112,6 +120,24 @@ install: echo "" exit 15 fi + - | + # Check kernel version - eBPF agent requires kernel 5.4 or higher + KERNEL_VERSION=$(uname -r | cut -d'-' -f1) + KERNEL_MAJOR=$(echo $KERNEL_VERSION | cut -d'.' -f1) + KERNEL_MINOR=$(echo $KERNEL_VERSION | cut -d'.' -f2) + + # Convert to comparable format (e.g., 5.4 becomes 504, 4.19 becomes 419) + KERNEL_NUM=$((KERNEL_MAJOR * 100 + KERNEL_MINOR)) + REQUIRED_KERNEL_NUM=504 # 5.4 + + if [ $KERNEL_NUM -lt $REQUIRED_KERNEL_NUM ]; then + echo "" + echo -e "\e[31mERROR:\e[0m eBPF agent requires Linux kernel version 5.4 or higher." >&2 + echo -e "Current kernel version: $KERNEL_VERSION" >&2 + echo -e "Please upgrade your kernel to version 5.4 or higher and re-run the installation." >&2 + echo "" + exit 17 + fi - | if [[ ! -d "/px" ]]; then if ! sudo mkdir -p "/px"; then @@ -166,7 +192,7 @@ install: # -- To configure the log level in increasing order of verboseness. [OFF, FATAL, ERROR, WARNING, INFO, DEBUG] NEW_RELIC_LOG_LEVEL=INFO # -- To configure log file path of eBPF Agent. If logging to this path fails, logs will be directed to stdout. - NEW_RELIC_LOG_FILE_PATH="" + NEW_RELIC_LOG_FILE_PATH="${NEW_RELIC_LOG_FILE_PATH:-}" # Regular expression pattern to match the specific name(s) of the entity set that you wish to exclude. DROP_DATA_FOR_ENTITY="" # -- Enable TLS communication between the eBPF client and agent. @@ -204,39 +230,39 @@ install: # -- To Enable/Disable the metrics, spans, sampling latency rate of MySQL DB PROTOCOLS_MYSQL_ENABLED="true" - PROTOCOLS_MYSQL_SPANS_ENABLED="false" + PROTOCOLS_MYSQL_SPANS_ENABLED="true" PROTOCOLS_MYSQL_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the metrics, spans, sampling latency rate of PostgreSQL DB PROTOCOLS_PGSQL_ENABLED="true" - PROTOCOLS_PGSQL_SPANS_ENABLED="false" + PROTOCOLS_PGSQL_SPANS_ENABLED="true" PROTOCOLS_PGSQL_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the metrics, spans, sampling latency rate of Cassandra DB PROTOCOLS_CASS_ENABLED="true" - PROTOCOLS_CASS_SPANS_ENABLED="false" + PROTOCOLS_CASS_SPANS_ENABLED="true" PROTOCOLS_CASS_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the metrics, spans, sampling latency rate of Redis DB PROTOCOLS_REDIS_ENABLED="true" - PROTOCOLS_REDIS_SPANS_ENABLED="false" + PROTOCOLS_REDIS_SPANS_ENABLED="true" PROTOCOLS_REDIS_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the metrics, spans, sampling latency rate of MongoDB PROTOCOLS_MONGODB_ENABLED="true" - PROTOCOLS_MONGODB_SPANS_ENABLED="false" + PROTOCOLS_MONGODB_SPANS_ENABLED="true" PROTOCOLS_MONGODB_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the spans and sampling latency of Kafka - PROTOCOLS_KAFKA_SPANS_ENABLED="false" + PROTOCOLS_KAFKA_SPANS_ENABLED="true" PROTOCOLS_KAFKA_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the spans and sampling latency of AMQP - PROTOCOLS_AMQP_SPANS_ENABLED="false" + PROTOCOLS_AMQP_SPANS_ENABLED="true" PROTOCOLS_AMQP_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the spans and sampling latency of DNS - PROTOCOLS_DNS_SPANS_ENABLED="false" + PROTOCOLS_DNS_SPANS_ENABLED="true" PROTOCOLS_DNS_SPANS_SAMPLING_LATENCY="" EOS @@ -381,6 +407,11 @@ install: sudo rm -f "$CONFIG_FILE" || log_error_and_exit "Failed to delete existing configuration file at $CONFIG_FILE." fi + # Set default log file path if NEW_RELIC_LOG_FILE_PATH is empty + if [ -z "${NEW_RELIC_LOG_FILE_PATH:-}" ]; then + NEW_RELIC_LOG_FILE_PATH="/var/log/newrelic-ebpf-agent" + fi + # Check if CONFIG_FILE_PATH is set and not empty if [[ -z "$CONFIG_FILE_PATH" ]]; then create_default_config_file @@ -411,6 +442,16 @@ install: else echo "TLS is disabled. Skipping certificate generation and validation." fi + + if [[ ! -d "$NEW_RELIC_LOG_FILE_PATH" ]]; then + echo "Directory $NEW_RELIC_LOG_FILE_PATH does not exist. Attempting to create it..." + if ! sudo mkdir -p "$NEW_RELIC_LOG_FILE_PATH"; then + echo -e "\e[31mERROR:\e[0m Failed to create directory $NEW_RELIC_LOG_FILE_PATH. Aborting installation." + exit 20 + fi + echo "Directory $NEW_RELIC_LOG_FILE_PATH created successfully." + fi + echo "eBPF logs directory: $NEW_RELIC_LOG_FILE_PATH" install_linux_headers: cmds: @@ -465,7 +506,7 @@ install: # -- To configure the log level in increasing order of verboseness. [OFF, FATAL, ERROR, WARNING, INFO, DEBUG] NEW_RELIC_LOG_LEVEL=INFO # -- To configure log file path of eBPF Agent. If logging to this path fails, logs will be directed to stdout. - NEW_RELIC_LOG_FILE_PATH="" + NEW_RELIC_LOG_FILE_PATH="${NEW_RELIC_LOG_FILE_PATH:-}" # Regular expression pattern to match the specific name(s) of the entity set that you wish to exclude. DROP_DATA_FOR_ENTITY="" # -- Enable TLS communication between the eBPF client and agent. @@ -503,39 +544,39 @@ install: # -- To Enable/Disable the metrics, spans, sampling latency rate of MySQL DB PROTOCOLS_MYSQL_ENABLED="true" - PROTOCOLS_MYSQL_SPANS_ENABLED="false" + PROTOCOLS_MYSQL_SPANS_ENABLED="true" PROTOCOLS_MYSQL_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the metrics, spans, sampling latency rate of PostgreSQL DB PROTOCOLS_PGSQL_ENABLED="true" - PROTOCOLS_PGSQL_SPANS_ENABLED="false" + PROTOCOLS_PGSQL_SPANS_ENABLED="true" PROTOCOLS_PGSQL_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the metrics, spans, sampling latency rate of Cassandra DB PROTOCOLS_CASS_ENABLED="true" - PROTOCOLS_CASS_SPANS_ENABLED="false" + PROTOCOLS_CASS_SPANS_ENABLED="true" PROTOCOLS_CASS_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the metrics, spans, sampling latency rate of Redis DB PROTOCOLS_REDIS_ENABLED="true" - PROTOCOLS_REDIS_SPANS_ENABLED="false" + PROTOCOLS_REDIS_SPANS_ENABLED="true" PROTOCOLS_REDIS_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the metrics, spans, sampling latency rate of MongoDB PROTOCOLS_MONGODB_ENABLED="true" - PROTOCOLS_MONGODB_SPANS_ENABLED="false" + PROTOCOLS_MONGODB_SPANS_ENABLED="true" PROTOCOLS_MONGODB_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the spans and sampling latency of Kafka - PROTOCOLS_KAFKA_SPANS_ENABLED="false" + PROTOCOLS_KAFKA_SPANS_ENABLED="true" PROTOCOLS_KAFKA_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the spans and sampling latency of AMQP - PROTOCOLS_AMQP_SPANS_ENABLED="false" + PROTOCOLS_AMQP_SPANS_ENABLED="true" PROTOCOLS_AMQP_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the spans and sampling latency of DNS - PROTOCOLS_DNS_SPANS_ENABLED="false" + PROTOCOLS_DNS_SPANS_ENABLED="true" PROTOCOLS_DNS_SPANS_SAMPLING_LATENCY="" EOS @@ -682,6 +723,12 @@ install: GREP_OUTPUT=$(systemctl status newrelic-ebpf-agent.service | grep "Active:" | grep inactive) if [[ $GREP_OUTPUT ]]; then if [[ ! -f "$CONFIG_FILE" ]]; then + + # Set default log file path if NEW_RELIC_LOG_FILE_PATH is empty + if [ -z "${NEW_RELIC_LOG_FILE_PATH:-}" ]; then + NEW_RELIC_LOG_FILE_PATH="/var/log/newrelic-ebpf-agent" + fi + # Check if CONFIG_FILE_PATH is set and not empty if [[ -z "$CONFIG_FILE_PATH" ]]; then create_default_config_file @@ -700,6 +747,16 @@ install: echo "TLS is disabled. Skipping certificate generation and validation." fi + if [[ ! -d "$NEW_RELIC_LOG_FILE_PATH" ]]; then + echo "Directory $NEW_RELIC_LOG_FILE_PATH does not exist. Attempting to create it..." + if ! sudo mkdir -p "$NEW_RELIC_LOG_FILE_PATH"; then + echo -e "\e[31mERROR:\e[0m Failed to create directory $NEW_RELIC_LOG_FILE_PATH. Aborting installation." + exit 20 + fi + echo "Directory $NEW_RELIC_LOG_FILE_PATH created successfully." + fi + echo "eBPF logs directory: $NEW_RELIC_LOG_FILE_PATH" + sudo mkdir -p /px; sleep 5s; systemctl restart newrelic-ebpf-agent.service diff --git a/recipes/newrelic/ebpf/ubuntu.yml b/recipes/newrelic/ebpf/ubuntu.yml index aefa1e3b9..09a01479a 100644 --- a/recipes/newrelic/ebpf/ubuntu.yml +++ b/recipes/newrelic/ebpf/ubuntu.yml @@ -53,6 +53,14 @@ install: - task: disable_service_for_agent_control assert_pre_req: + status: + - | + if [ "${FORCE_INSTALL:-}" = "true" ]; then + echo "Force install enabled - skipping pre-requisite checks" + exit 0 + fi + # If FORCE_INSTALL is not true, we want the task to run normally + exit 1 cmds: - | IS_ROOT_OR_SUDO=$([ ! -z "$SUDO_USER" ] || [ $(whoami) = "root" ] && echo "true" || echo "false") # Assert root or sudo user @@ -104,6 +112,24 @@ install: echo "" exit 15 fi + - | + # Check kernel version - eBPF agent requires kernel 5.4 or higher + KERNEL_VERSION=$(uname -r | cut -d'-' -f1) + KERNEL_MAJOR=$(echo $KERNEL_VERSION | cut -d'.' -f1) + KERNEL_MINOR=$(echo $KERNEL_VERSION | cut -d'.' -f2) + + # Convert to comparable format (e.g., 5.4 becomes 504, 4.19 becomes 419) + KERNEL_NUM=$((KERNEL_MAJOR * 100 + KERNEL_MINOR)) + REQUIRED_KERNEL_NUM=504 # 5.4 + + if [ $KERNEL_NUM -lt $REQUIRED_KERNEL_NUM ]; then + echo "" + echo -e "\e[31mERROR:\e[0m eBPF agent requires Linux kernel version 5.4 or higher." >&2 + echo -e "Current kernel version: $KERNEL_VERSION" >&2 + echo -e "Please upgrade your kernel to version 5.4 or higher and re-run the installation." >&2 + echo "" + exit 17 + fi - | if [[ ! -d "/px" ]]; then if ! sudo mkdir -p "/px"; then @@ -158,7 +184,7 @@ install: # -- To configure the log level in increasing order of verboseness. [OFF, FATAL, ERROR, WARNING, INFO, DEBUG] NEW_RELIC_LOG_LEVEL=INFO # -- To configure log file path of eBPF Agent. If logging to this path fails, logs will be directed to stdout. - NEW_RELIC_LOG_FILE_PATH="" + NEW_RELIC_LOG_FILE_PATH="${NEW_RELIC_LOG_FILE_PATH:-}" # Regular expression pattern to match the specific name(s) of the entity set that you wish to exclude. DROP_DATA_FOR_ENTITY="" # -- Enable TLS communication between the eBPF client and agent. @@ -196,39 +222,39 @@ install: # -- To Enable/Disable the metrics, spans, sampling latency rate of MySQL DB PROTOCOLS_MYSQL_ENABLED="true" - PROTOCOLS_MYSQL_SPANS_ENABLED="false" + PROTOCOLS_MYSQL_SPANS_ENABLED="true" PROTOCOLS_MYSQL_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the metrics, spans, sampling latency rate of PostgreSQL DB PROTOCOLS_PGSQL_ENABLED="true" - PROTOCOLS_PGSQL_SPANS_ENABLED="false" + PROTOCOLS_PGSQL_SPANS_ENABLED="true" PROTOCOLS_PGSQL_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the metrics, spans, sampling latency rate of Cassandra DB PROTOCOLS_CASS_ENABLED="true" - PROTOCOLS_CASS_SPANS_ENABLED="false" + PROTOCOLS_CASS_SPANS_ENABLED="true" PROTOCOLS_CASS_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the metrics, spans, sampling latency rate of Redis DB PROTOCOLS_REDIS_ENABLED="true" - PROTOCOLS_REDIS_SPANS_ENABLED="false" + PROTOCOLS_REDIS_SPANS_ENABLED="true" PROTOCOLS_REDIS_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the metrics, spans, sampling latency rate of MongoDB PROTOCOLS_MONGODB_ENABLED="true" - PROTOCOLS_MONGODB_SPANS_ENABLED="false" + PROTOCOLS_MONGODB_SPANS_ENABLED="true" PROTOCOLS_MONGODB_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the spans and sampling latency of Kafka - PROTOCOLS_KAFKA_SPANS_ENABLED="false" + PROTOCOLS_KAFKA_SPANS_ENABLED="true" PROTOCOLS_KAFKA_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the spans and sampling latency of AMQP - PROTOCOLS_AMQP_SPANS_ENABLED="false" + PROTOCOLS_AMQP_SPANS_ENABLED="true" PROTOCOLS_AMQP_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the spans and sampling latency of DNS - PROTOCOLS_DNS_SPANS_ENABLED="false" + PROTOCOLS_DNS_SPANS_ENABLED="true" PROTOCOLS_DNS_SPANS_SAMPLING_LATENCY="" EOS @@ -373,6 +399,11 @@ install: sudo rm -f "$CONFIG_FILE" || log_error_and_exit "Failed to delete existing configuration file at $CONFIG_FILE." fi + # Set default log file path if NEW_RELIC_LOG_FILE_PATH is empty + if [ -z "${NEW_RELIC_LOG_FILE_PATH:-}" ]; then + NEW_RELIC_LOG_FILE_PATH="/var/log/newrelic-ebpf-agent" + fi + # Check if CONFIG_FILE_PATH is set and not empty if [[ -z "$CONFIG_FILE_PATH" ]]; then create_default_config_file @@ -403,7 +434,16 @@ install: else echo "TLS is disabled. Skipping certificate generation and validation." fi - + + if [[ ! -d "$NEW_RELIC_LOG_FILE_PATH" ]]; then + echo "Directory $NEW_RELIC_LOG_FILE_PATH does not exist. Attempting to create it..." + if ! sudo mkdir -p "$NEW_RELIC_LOG_FILE_PATH"; then + echo -e "\e[31mERROR:\e[0m Failed to create directory $NEW_RELIC_LOG_FILE_PATH. Aborting installation." + exit 20 + fi + echo "Directory $NEW_RELIC_LOG_FILE_PATH created successfully." + fi + echo "eBPF logs directory: $NEW_RELIC_LOG_FILE_PATH" update_apt: cmds: - | @@ -501,7 +541,7 @@ install: # -- To configure the log level in increasing order of verboseness. [OFF, FATAL, ERROR, WARNING, INFO, DEBUG] NEW_RELIC_LOG_LEVEL=INFO # -- To configure log file path of eBPF Agent. If logging to this path fails, logs will be directed to stdout. - NEW_RELIC_LOG_FILE_PATH="" + NEW_RELIC_LOG_FILE_PATH="${NEW_RELIC_LOG_FILE_PATH:-}" # Regular expression pattern to match the specific name(s) of the entity set that you wish to exclude. DROP_DATA_FOR_ENTITY="" # -- Enable TLS communication between the eBPF client and agent. @@ -539,39 +579,39 @@ install: # -- To Enable/Disable the metrics, spans, sampling latency rate of MySQL DB PROTOCOLS_MYSQL_ENABLED="true" - PROTOCOLS_MYSQL_SPANS_ENABLED="false" + PROTOCOLS_MYSQL_SPANS_ENABLED="true" PROTOCOLS_MYSQL_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the metrics, spans, sampling latency rate of PostgreSQL DB PROTOCOLS_PGSQL_ENABLED="true" - PROTOCOLS_PGSQL_SPANS_ENABLED="false" + PROTOCOLS_PGSQL_SPANS_ENABLED="true" PROTOCOLS_PGSQL_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the metrics, spans, sampling latency rate of Cassandra DB PROTOCOLS_CASS_ENABLED="true" - PROTOCOLS_CASS_SPANS_ENABLED="false" + PROTOCOLS_CASS_SPANS_ENABLED="true" PROTOCOLS_CASS_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the metrics, spans, sampling latency rate of Redis DB PROTOCOLS_REDIS_ENABLED="true" - PROTOCOLS_REDIS_SPANS_ENABLED="false" + PROTOCOLS_REDIS_SPANS_ENABLED="true" PROTOCOLS_REDIS_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the metrics, spans, sampling latency rate of MongoDB PROTOCOLS_MONGODB_ENABLED="true" - PROTOCOLS_MONGODB_SPANS_ENABLED="false" + PROTOCOLS_MONGODB_SPANS_ENABLED="true" PROTOCOLS_MONGODB_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the spans and sampling latency of Kafka - PROTOCOLS_KAFKA_SPANS_ENABLED="false" + PROTOCOLS_KAFKA_SPANS_ENABLED="true" PROTOCOLS_KAFKA_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the spans and sampling latency of AMQP - PROTOCOLS_AMQP_SPANS_ENABLED="false" + PROTOCOLS_AMQP_SPANS_ENABLED="true" PROTOCOLS_AMQP_SPANS_SAMPLING_LATENCY="" # -- To Enable/Disable the spans and sampling latency of DNS - PROTOCOLS_DNS_SPANS_ENABLED="false" + PROTOCOLS_DNS_SPANS_ENABLED="true" PROTOCOLS_DNS_SPANS_SAMPLING_LATENCY="" EOS @@ -713,6 +753,12 @@ install: apt-get $OPTIONS install -yq --no-install-recommends newrelic-ebpf-agent || { if [[ ! -f "$CONFIG_FILE" ]]; then + + # Set default log file path if NEW_RELIC_LOG_FILE_PATH is empty + if [ -z "${NEW_RELIC_LOG_FILE_PATH:-}" ]; then + NEW_RELIC_LOG_FILE_PATH="/var/log/newrelic-ebpf-agent" + fi + # Check if CONFIG_FILE_PATH is set and not empty if [[ -z "$CONFIG_FILE_PATH" ]]; then create_default_config_file @@ -731,6 +777,16 @@ install: echo "TLS is disabled. Skipping certificate generation and validation." fi + if [[ ! -d "$NEW_RELIC_LOG_FILE_PATH" ]]; then + echo "Directory $NEW_RELIC_LOG_FILE_PATH does not exist. Attempting to create it..." + if ! sudo mkdir -p "$NEW_RELIC_LOG_FILE_PATH"; then + echo -e "\e[31mERROR:\e[0m Failed to create directory $NEW_RELIC_LOG_FILE_PATH. Aborting installation." + exit 20 + fi + echo "Directory $NEW_RELIC_LOG_FILE_PATH created successfully." + fi + echo "eBPF logs directory: $NEW_RELIC_LOG_FILE_PATH" + sudo mkdir -p /px; sleep 5s; systemctl restart newrelic-ebpf-agent.service @@ -753,12 +809,6 @@ install: fi } - - - - - - silent: true # When the eBPF agent is installed alongside Agent Control, the default services are disabled