Skip to content

Commit

Permalink
enable opamp extension by default, update installers
Browse files Browse the repository at this point in the history
  • Loading branch information
smithclay committed Mar 6, 2024
1 parent 5a8bf27 commit ae78dfb
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 17 deletions.
5 changes: 3 additions & 2 deletions collector/config/otelcol-docker-hostmetrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ extensions:
opamp:
server:
http:
endpoint: https://opamp.lightstep.com/v1/opamp
endpoint: https://asdasdasdasfdasfd.free.beeceptor.com/v1/opamp
headers:
"Authorization": "Bearer ${LS_OPAMP_API_KEY}"
"Authorization": "Bearer YOUR_OPAMP_API_KEY"

service:
extensions: [health_check, opamp]
pipelines:
metrics/collector:
receivers: [prometheus/self]
Expand Down
3 changes: 2 additions & 1 deletion collector/config/otelcol-linux-hostmetrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ extensions:
http:
endpoint: https://opamp.lightstep.com/v1/opamp
headers:
"Authorization": "Bearer ${LS_OPAMP_API_KEY}"
"Authorization": "Bearer YOUR_OPAMP_API_KEY"
service:
extensions: [health_check, opamp]
pipelines:
metrics/collector:
receivers: [prometheus/self]
Expand Down
8 changes: 3 additions & 5 deletions collector/config/otelcol-macos-hostmetrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ receivers:
collection_interval: 5s
scrapers:
# cpu and disk are only supported if build with CGO_ENABLED=1
# The ServiceNow collector goreleaser build does this, other builds may not.
cpu:
disk:
load:
processes:
filesystem:
Expand Down Expand Up @@ -67,12 +64,13 @@ extensions:
health_check:
opamp:
server:
ws:
http:
endpoint: https://opamp.lightstep.com/v1/opamp
headers:
"Authorization": "Bearer ${LS_OPAMP_API_KEY}"
"Authorization": "Bearer YOUR_OPAMP_API_KEY"

service:
extensions: [health_check, opamp]
pipelines:
metrics/collector:
receivers: [prometheus/self]
Expand Down
3 changes: 2 additions & 1 deletion collector/config/otelcol-windows-hostmetrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ extensions:
http:
endpoint: https://opamp.lightstep.com/v1/opamp
headers:
"Authorization": "Bearer ${LS_OPAMP_API_KEY}"
"Authorization": "Bearer YOUR_OPAMP_API_KEY"
service:
extensions: [health_check, opamp]
pipelines:
metrics/collector:
receivers: [prometheus/self]
Expand Down
34 changes: 31 additions & 3 deletions collector/scripts/install/install-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ Usage:
$(fg_yellow '-i, --ingest-token')
Defines the token to be used when communicating with Cloud Observability
$(fg_yellow '-o, --opamp-key')
Defines the API key to be used when communicating with Cloud Observability via opAMP
EOF
)
info "$USAGE"
Expand Down Expand Up @@ -307,6 +310,7 @@ setup_installation()
set_download_urls
set_ingest_endpoint
set_ingest_token
set_opamp_api_key

success "Configuration complete!"
decrease_indent
Expand Down Expand Up @@ -377,6 +381,15 @@ set_ingest_token()
INGEST_TOKEN="$ingest_token"
}

set_opamp_api_key()
{
if [ -z "$opamp_api_key" ] ; then
opamp_api_key=$OPAMP_API_KEY
fi

OPAMP_API_KEY="$opamp_api_key"
}

# latest_version gets the tag of the latest release, without the v prefix.
latest_version()
{
Expand All @@ -386,13 +399,21 @@ latest_version()
}

# set the access token, if one was specified
set_access_token()
replace_access_token()
{
# uses | as INGEST_TOKEN can contain a /
# sed is different on macOS vs Linux!
sed -i '' "s|YOUR_TOKEN|"$INGEST_TOKEN"|g" $INSTALL_DIR/config.yaml
}

# replace the opamp api key , if one was specified
replace_opamp_api_key()
{
# uses | as INGEST_TOKEN can contain a /
# sed is different on macOS vs Linux!
sed -i '' "s|YOUR_OPAMP_API_KEY|"$OPAMP_API_KEY"|g" $INSTALL_DIR/config.yaml
}

# This will install the package by downloading & unpacking the tarball into the install directory
install_package()
{
Expand Down Expand Up @@ -464,8 +485,13 @@ install_package()
succeeded

if [ -n "$INGEST_TOKEN" ]; then
info "Setting access token..."
set_access_token
info "Replacing access token in config..."
replace_access_token
fi

if [ -n "$OPAMP_API_KEY" ]; then
info "Replacing opAMP API key in config..."
replace_opamp_api_key
fi

info "Starting service..."
Expand Down Expand Up @@ -574,6 +600,8 @@ main()
ingest_endpoint=$2 ; shift 2 ;;
-i|--ingest-token)
ingest_token=$2 ; shift 2 ;;
-o|--opamp-key)
opamp_api_key=$2 ; shift 2 ;;
-b|--base-url)
base_url=$2 ; shift 2 ;;
--)
Expand Down
35 changes: 30 additions & 5 deletions collector/scripts/install/install-unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ Usage:
$(fg_yellow '-i, --ingest-token')
Defines the token to be used when communicating with Cloud Observability
$(fg_yellow '-o, --opamp-key')
Defines the API key to be used when communicating with Cloud Observability via opAMP
EOF
)
info "$USAGE"
Expand Down Expand Up @@ -264,6 +267,7 @@ setup_installation()

set_ingest_endpoint
set_ingest_token
set_opamp_api_key

success "Configuration complete!"
decrease_indent
Expand Down Expand Up @@ -506,6 +510,14 @@ set_ingest_token()
INGEST_TOKEN="$ingest_token"
}

set_opamp_api_key()
{
if [ -z "$opamp_api_key" ] ; then
opamp_api_key=$OPAMP_API_KEY
fi

OPAMP_API_KEY="$opamp_api_key"
}

# latest_version gets the tag of the latest release, without the v prefix.
latest_version()
Expand All @@ -516,12 +528,20 @@ latest_version()
}

# set the access token, if one was specified
set_access_token()
replace_access_token()
{
# uses | as INGEST_TOKEN can contain a /
sed -i "s|YOUR_TOKEN|$INGEST_TOKEN|g" /opt/sn-collector/config.yaml
}

# replace the opamp api key , if one was specified
replace_opamp_api_key()
{
# uses | as INGEST_TOKEN can contain a /
# sed is different on macOS vs Linux!
sed -i '' "s|YOUR_OPAMP_API_KEY|"$OPAMP_API_KEY"|g" $INSTALL_DIR/config.yaml
}

# This will install the package by downloading the archived agent,
# extracting the binaries, and then removing the archive.
install_package()
Expand Down Expand Up @@ -559,8 +579,13 @@ install_package()
succeeded

if [ -n "$INGEST_TOKEN" ]; then
info "Setting access token..."
set_access_token
info "Replacing access token in config..."
replace_access_token
fi

if [ -n "$OPAMP_API_KEY" ]; then
info "Replacing opAMP API key in config..."
replace_opamp_api_key
fi

if [ "$(systemctl is-enabled sn-collector)" = "enabled" ]; then
Expand Down Expand Up @@ -694,8 +719,8 @@ main()
ingest_endpoint=$2 ; shift 2 ;;
-i|--ingest-token)
ingest_token=$2 ; shift 2 ;;
-c|--check-bp-url)
check_bp_url="true" ; shift 1 ;;
-o|--opamp-key)
opamp_api_key=$2 ; shift 2 ;;
-b|--base-url)
base_url=$2 ; shift 2 ;;
-r|--uninstall)
Expand Down

0 comments on commit ae78dfb

Please sign in to comment.