From b5192db585e15bce114d054a03cec0e3a3c6739d Mon Sep 17 00:00:00 2001 From: "Erwin Vrolijk (technimad-splunk)" Date: Fri, 1 Aug 2025 15:05:23 +0200 Subject: [PATCH 1/2] added script to get all rum urls --- integration-examples/get-rum-urls/README.md | 43 +++++++++++++++++++ .../get-rum-urls/get_rum_urls.sh | 41 ++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 integration-examples/get-rum-urls/README.md create mode 100755 integration-examples/get-rum-urls/get_rum_urls.sh diff --git a/integration-examples/get-rum-urls/README.md b/integration-examples/get-rum-urls/README.md new file mode 100644 index 0000000..b42bff6 --- /dev/null +++ b/integration-examples/get-rum-urls/README.md @@ -0,0 +1,43 @@ +# Get Rum Urls + +This script will return all RUM urls present in Splunk Observability Cloud. +The script expects you to provide both the application and environment you want to get the urls for. These settings are required. +Use this an input to create of fine tune URL grouping rules. + +## Environment Variables +This script relies on environment variables. +Set the following: + +``` +export REALM= +export APP= +export ENVIRONMENT= +export TOKEN= +``` + +And run the script: + +``` +$ ./get_rum_urls.sh +REALM is set to: eu0 +TOKEN is set. +APP is set. +ENVIRONMENT is set. +Script continues with REALM=eu0, APP=online-boutique-eu-store, ENVIRONMENT=online-boutique-eu (TOKEN value hidden). +https://online-boutique-eu.splunko11y.com/ +https://online-boutique-eu.splunko11y.com/cart +https://online-boutique-eu.splunko11y.com/cart/ +https://online-boutique-eu.splunko11y.com/cart/checkout +https://online-boutique-eu.splunko11y.com/product/ +``` +By default, the script shows some information before the urls are printed. + +If you just want to get the list of urls output. Redirect stderr like this: +``` +$ ./get_rum_urls.sh 2> /dev/null +https://online-boutique-eu.splunko11y.com/ +https://online-boutique-eu.splunko11y.com/cart +https://online-boutique-eu.splunko11y.com/cart/ +https://online-boutique-eu.splunko11y.com/cart/checkout +https://online-boutique-eu.splunko11y.com/product/ +``` diff --git a/integration-examples/get-rum-urls/get_rum_urls.sh b/integration-examples/get-rum-urls/get_rum_urls.sh new file mode 100755 index 0000000..35e8663 --- /dev/null +++ b/integration-examples/get-rum-urls/get_rum_urls.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# --- Set default value for REALM if not already set --- +# This uses bash parameter expansion: +# ${parameter:-word} If parameter is unset or null, the expansion of word is substituted. +# Otherwise, the value of parameter is substituted. +REALM="${REALM:-eu1}" +echo "REALM is set to: $REALM" >&2 # Redirect to stderr + +# --- Function to check if an environment variable is set --- +# This makes the checks more concise and reusable. +check_env_var() { + local var_name="$1" + if [[ -z "${!var_name}" ]]; then # ${!var_name} is indirect expansion to get the value of the variable named by var_name + echo "Error: The environment variable $var_name is not set. Please set it before running this script." >&2 + exit 1 # Exit with a non-zero status to indicate an error + fi + echo "$var_name is set." >&2 # Redirect to stderr +} + +# --- Check required environment variables --- +check_env_var "TOKEN" +check_env_var "APP" +check_env_var "ENVIRONMENT" + +CURRENT_TIMESTAMP_MILLIS=$(($(date +%s) * 1000 + $(date +%N | cut -b1-3))) +echo "Script continues with REALM=$REALM, APP=$APP, ENVIRONMENT=$ENVIRONMENT (TOKEN value hidden)." >&2 # Redirect to stderr + + +curl -s 'https://app.'${REALM}'.signalfx.com/v2/rum/graphql?op=RumNodeMetricsAggregatedQuery1' \ +-X 'POST' \ +-H 'Content-Type: application/json' \ +-H 'Sec-Fetch-Dest: empty' \ +-H 'Accept: */*' \ +-H 'Sec-Fetch-Site: same-origin' \ +-H 'Accept-Language: nl-NL,nl;q=0.9' \ +-H 'Accept-Encoding: gzip, deflate, br' \ +-H 'Sec-Fetch-Mode: cors' \ +-H 'x-sf-token: '${TOKEN}'' \ +-H 'Priority: u=3, i' \ +--data-raw '{"operationName":"RumNodeMetricsAggregatedQuery1","variables":{"useAlternate":false,"endTimeMillis":'${CURRENT_TIMESTAMP_MILLIS}',"lookbackMillis":691200000,"resolutionMillis":7200000,"metricFamilyAggregations":{"metricFamilyName":"page_view","aggregations":["COUNT"],"orderByAggregation":"COUNT"},"limit":100,"filters":[{"type":"contains","scope":"GLOBAL","tag":"sf_product","values":["web"]},{"type":"contains","scope":"GLOBAL","tag":"app","values":["'${APP}'"]},{"type":"contains","scope":"GLOBAL","tag":"sf_environment","values":["'${ENVIRONMENT}'"]}],"dimension":"sf_node_name","includeNulls":true},"query":"query RumNodeMetricsAggregatedQuery1($endTimeMillis: Float, $lookbackMillis: Float, $resolutionMillis: Float, $dimension: String, $metricFamilyAggregations: MetricFamilyAggregationsInput!, $limit: Int, $includeNulls: Boolean, $filters: [Filter!], $useAlternate: Boolean, $skipTimeseries: Boolean) {\n rumNodeMetricsV3(\n endTimeMillis: $endTimeMillis\n lookbackMillis: $lookbackMillis\n resolutionMillis: $resolutionMillis\n dimension: $dimension\n metricFamilyAggregations: $metricFamilyAggregations\n limit: $limit\n includeNulls: $includeNulls\n filters: $filters\n useAlternate: $useAlternate\n skipTimeseries: $skipTimeseries\n ) {\n nodes {\n nodeName\n metrics {\n metricFamilyName\n aggregation\n total\n timeseries\n __typename\n }\n __typename\n }\n __typename\n }\n}\n"}' | gunzip | jq -r '.data.rumNodeMetricsV3.nodes[].nodeName' | sort From fe5aec8fb64081ac7b75f7b6a1ceefc6b4d0bd93 Mon Sep 17 00:00:00 2001 From: "Erwin Vrolijk (technimad-splunk)" Date: Fri, 1 Aug 2025 15:07:31 +0200 Subject: [PATCH 2/2] add prerequisites to readme --- integration-examples/get-rum-urls/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/integration-examples/get-rum-urls/README.md b/integration-examples/get-rum-urls/README.md index b42bff6..c658a9a 100644 --- a/integration-examples/get-rum-urls/README.md +++ b/integration-examples/get-rum-urls/README.md @@ -4,6 +4,10 @@ This script will return all RUM urls present in Splunk Observability Cloud. The script expects you to provide both the application and environment you want to get the urls for. These settings are required. Use this an input to create of fine tune URL grouping rules. +## Prerequisites +This script expects both `curl` and `jq` to be installed. +This script has onoly been tested on MacOS. + ## Environment Variables This script relies on environment variables. Set the following: