Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove bundle and use resourcedetectionprocessor for heroku metadata #11

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ Use the following environment variables to configure this buildpack

| Environment Variable | Required | Default | Description |
|---------------------------|----------|-----------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------|
| `SFX_AGENT_DISABLED` | No | `false` | Whether to disable installing the smart agent as part of the buildpack. |
| `SPLUNK_ACCESS_TOKEN` | Yes | | [Splunk access token](https://docs.splunk.com/Observability/admin/authentication-tokens/org-tokens.html#admin-org-tokens). |
| `SPLUNK_REALM` | Yes | | [Splunk realm](https://dev.splunk.com/observability/docs/realms_in_endpoints/). |
| `SPLUNK_API_URL` | No | `https://api.SPLUNK_REALM.signalfx.com` | The Splunk API base URL. |
Expand Down
33 changes: 0 additions & 33 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,6 @@ if [ -f "$ENV_DIR/SPLUNK_OTEL_VERSION" ]; then
fi
splunk_otel_collector="otelcol_linux_amd64"

# Use the latest version of the SignalFx Agent if none is specified
SFX_AGENT_VERSION=$(curl -s https://api.github.com/repos/signalfx/signalfx-agent/releases/latest | grep tarball_url | cut -d'"' -f4 | cut -d'/' -f8 | cut -d'v' -f2)
# Get SignalFx Agent version from the environment if available
if [ -f "$ENV_DIR/SFX_AGENT_VERSION" ]; then
SFX_AGENT_VERSION=$(cat "$ENV_DIR/SFX_AGENT_VERSION")
fi
signalfx_agent_tar="signalfx-agent-$SFX_AGENT_VERSION.tar.gz"

# Check if the SignalFx Agent download is explicitly disabled
SFX_AGENT_DISABLED=false
if [ -f "$ENV_DIR/SFX_AGENT_DISABLED" ]; then
SFX_AGENT_DISABLED=$(cat "$ENV_DIR/SFX_AGENT_DISABLED")
fi

SPLUNK_CONFIG_DIR="$BUILD_DIR/.splunk"
cp "$BUILDPACK_DIR/setup/config.yaml" "$SPLUNK_CONFIG_DIR"

Expand All @@ -58,25 +44,6 @@ if [ $? -ne 0 ]; then
exit 1;
fi

if [ "${SFX_AGENT_DISABLED}" = "true" ]; then
echo "-----> Skipping installing the SignalFx Agent Bundle"
else
echo "-----> Downloading SignalFx Agent Bundle $SFX_AGENT_VERSION ($signalfx_agent_tar)"
wget -P "$SPLUNK_CONFIG_DIR/" "https://github.com/signalfx/signalfx-agent/releases/download/v$SFX_AGENT_VERSION/$signalfx_agent_tar" -o $signalfx_agent_tar > /dev/null 2>&1
#curl -L "https://github.com/signalfx/signalfx-agent/releases/download/v$SFX_AGENT_VERSION/$signalfx_agent_tar" -o $SPLUNK_CONFIG_DIR/$signalfx_agent_tar > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Downloading agent tarball failed" | indent
echo "$SFX_AGENT_VERSION may not be a valid version of the SignalFx Agent." | indent
echo "Find valid versions here: https://github.com/signalfx/signalfx-agent/tags" | indent
exit 1;
fi

echo "-----> Extracting SignalFx Agent Bundle"
tar -xf "$SPLUNK_CONFIG_DIR/$signalfx_agent_tar" -C "$SPLUNK_CONFIG_DIR"
rm -f "$SPLUNK_CONFIG_DIR/$signalfx_agent_tar"
fi


mkdir -p "$BUILD_DIR/.profile.d"
cp "$BUILDPACK_DIR/setup/agent.sh" "$BUILD_DIR/.profile.d/"
chmod +x "$BUILD_DIR/.profile.d/agent.sh"
15 changes: 1 addition & 14 deletions setup/agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ fi
# Set configuration file

export SPLUNK_CONFIG_DIR="$HOME/.splunk"
if [[ "${SFX_AGENT_DISABLED}" == "true" ]]; then
export FALLBACK_AGENT_CONFIG="$SPLUNK_CONFIG_DIR/config_without_sa.yaml"
else
export SPLUNK_COLLECTD_CONFIG_DIR="$SPLUNK_CONFIG_DIR/signalfx-agent/var/run/collectd"
mkdir -p "$SPLUNK_COLLECTD_CONFIG_DIR"

export FALLBACK_AGENT_CONFIG="$SPLUNK_CONFIG_DIR/config.yaml"
fi
export FALLBACK_AGENT_CONFIG="$SPLUNK_CONFIG_DIR/config.yaml"

export DEFAULT_APP_CONFIG="$HOME/config.yaml"

Expand Down Expand Up @@ -62,12 +56,5 @@ else
mkdir -p $(dirname $SPLUNK_LOG_FILE)
fi

if [[ "${SFX_AGENT_DISABLED}" != "true" ]]; then

export SPLUNK_BUNDLE_DIR="$SPLUNK_CONFIG_DIR/signalfx-agent"

(cd $SPLUNK_CONFIG_DIR/signalfx-agent/ && bin/patch-interpreter $SPLUNK_CONFIG_DIR/signalfx-agent/)
fi

chmod a+x $SPLUNK_CONFIG_DIR/otelcol_linux_amd64
$SPLUNK_CONFIG_DIR/otelcol_linux_amd64 > $SPLUNK_LOG_FILE 2>&1&
56 changes: 5 additions & 51 deletions setup/config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
config_sources:
env:
defaults:
HEROKU_DYNO_ID: "unset"
HEROKU_APP_ID: "unset"
HEROKU_APP_NAME: "unset"

extensions:
health_check:
endpoint: 0.0.0.0:13133
Expand All @@ -15,10 +8,6 @@ extensions:
endpoint: "${SPLUNK_API_URL}"
# Use instead when sending to gateway
#endpoint: "${SPLUNK_GATEWAY_URL}"
smartagent:
bundleDir: "${SPLUNK_BUNDLE_DIR}"
collectd:
configDir: "${SPLUNK_COLLECTD_DIR}"
zpages:
#endpoint: 0.0.0.0:55679
memory_ballast:
Expand Down Expand Up @@ -54,8 +43,6 @@ receivers:
- source_labels: [ __name__ ]
regex: '.*grpc_io.*'
action: drop
smartagent/heroku-metadata:
type: heroku-metadata
smartagent/signalfx-forwarder:
rmfitzpatrick marked this conversation as resolved.
Show resolved Hide resolved
type: signalfx-forwarder
listenAddress: 0.0.0.0:9080
Expand All @@ -69,40 +56,8 @@ processors:
memory_limiter:
check_interval: 2s
limit_mib: ${SPLUNK_MEMORY_LIMIT_MIB}
attributes/heroku:
actions:
- action: insert
key: dyno_id
value: ${env:HEROKU_DYNO_ID}
- action: insert
key: app_id
value: ${env:HEROKU_APP_ID}
- action: insert
key: app_name
value: ${env:HEROKU_APP_NAME}
metricstransform/heroku:
transforms:
- include: .*
match_type: regexp
action: update
operations:
- action: add_label
new_label: dyno_id
new_value: ${env:HEROKU_DYNO_ID}
- action: add_label
new_label: app_id
new_value: ${env:HEROKU_APP_ID}
- action: add_label
new_label: app_name
new_value: ${env:HEROKU_APP_NAME}
# Optional: The following processor can be used to add a default "deployment.environment" attribute to the logs and
# traces when it's not populated by instrumentation libraries.
# If enabled, make sure to enable this processor in the pipeline below.
#resource/add_environment:
#attributes:
#- action: insert
#key: deployment.environment
#value: staging/production/...
resourcedetection:
detectors: [heroku]

exporters:
# Traces
Expand Down Expand Up @@ -135,16 +90,15 @@ service:
processors:
- memory_limiter
- batch
- attributes/heroku
#- resource/add_environment
- resourcedetection
exporters: [sapm, signalfx]
metrics:
receivers: [otlp, signalfx, smartagent/heroku-metadata, smartagent/signalfx-forwarder]
processors: [memory_limiter, batch, metricstransform/heroku]
processors: [memory_limiter, batch, resourcedetection]
exporters: [signalfx]
metrics/internal:
receivers: [prometheus/internal]
processors: [memory_limiter, batch, metricstransform/heroku]
processors: [memory_limiter, batch, resourcedetection]
exporters: [signalfx]
logs/profiling:
receivers: [otlp]
Expand Down
142 changes: 0 additions & 142 deletions setup/config_without_sa.yaml

This file was deleted.