Skip to content

Commit b5192db

Browse files
added script to get all rum urls
1 parent 0083468 commit b5192db

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Get Rum Urls
2+
3+
This script will return all RUM urls present in Splunk Observability Cloud.
4+
The script expects you to provide both the application and environment you want to get the urls for. These settings are required.
5+
Use this an input to create of fine tune URL grouping rules.
6+
7+
## Environment Variables
8+
This script relies on environment variables.
9+
Set the following:
10+
11+
```
12+
export REALM=<us1|eu0|eu1|...>
13+
export APP=<name of the application in RUM>
14+
export ENVIRONMENT=<environment used for the application>
15+
export TOKEN=<user session token>
16+
```
17+
18+
And run the script:
19+
20+
```
21+
$ ./get_rum_urls.sh
22+
REALM is set to: eu0
23+
TOKEN is set.
24+
APP is set.
25+
ENVIRONMENT is set.
26+
Script continues with REALM=eu0, APP=online-boutique-eu-store, ENVIRONMENT=online-boutique-eu (TOKEN value hidden).
27+
https://online-boutique-eu.splunko11y.com/
28+
https://online-boutique-eu.splunko11y.com/cart
29+
https://online-boutique-eu.splunko11y.com/cart/<??>
30+
https://online-boutique-eu.splunko11y.com/cart/checkout
31+
https://online-boutique-eu.splunko11y.com/product/<??>
32+
```
33+
By default, the script shows some information before the urls are printed.
34+
35+
If you just want to get the list of urls output. Redirect stderr like this:
36+
```
37+
$ ./get_rum_urls.sh 2> /dev/null
38+
https://online-boutique-eu.splunko11y.com/
39+
https://online-boutique-eu.splunko11y.com/cart
40+
https://online-boutique-eu.splunko11y.com/cart/<??>
41+
https://online-boutique-eu.splunko11y.com/cart/checkout
42+
https://online-boutique-eu.splunko11y.com/product/<??>
43+
```
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
# --- Set default value for REALM if not already set ---
4+
# This uses bash parameter expansion:
5+
# ${parameter:-word} If parameter is unset or null, the expansion of word is substituted.
6+
# Otherwise, the value of parameter is substituted.
7+
REALM="${REALM:-eu1}"
8+
echo "REALM is set to: $REALM" >&2 # Redirect to stderr
9+
10+
# --- Function to check if an environment variable is set ---
11+
# This makes the checks more concise and reusable.
12+
check_env_var() {
13+
local var_name="$1"
14+
if [[ -z "${!var_name}" ]]; then # ${!var_name} is indirect expansion to get the value of the variable named by var_name
15+
echo "Error: The environment variable $var_name is not set. Please set it before running this script." >&2
16+
exit 1 # Exit with a non-zero status to indicate an error
17+
fi
18+
echo "$var_name is set." >&2 # Redirect to stderr
19+
}
20+
21+
# --- Check required environment variables ---
22+
check_env_var "TOKEN"
23+
check_env_var "APP"
24+
check_env_var "ENVIRONMENT"
25+
26+
CURRENT_TIMESTAMP_MILLIS=$(($(date +%s) * 1000 + $(date +%N | cut -b1-3)))
27+
echo "Script continues with REALM=$REALM, APP=$APP, ENVIRONMENT=$ENVIRONMENT (TOKEN value hidden)." >&2 # Redirect to stderr
28+
29+
30+
curl -s 'https://app.'${REALM}'.signalfx.com/v2/rum/graphql?op=RumNodeMetricsAggregatedQuery1' \
31+
-X 'POST' \
32+
-H 'Content-Type: application/json' \
33+
-H 'Sec-Fetch-Dest: empty' \
34+
-H 'Accept: */*' \
35+
-H 'Sec-Fetch-Site: same-origin' \
36+
-H 'Accept-Language: nl-NL,nl;q=0.9' \
37+
-H 'Accept-Encoding: gzip, deflate, br' \
38+
-H 'Sec-Fetch-Mode: cors' \
39+
-H 'x-sf-token: '${TOKEN}'' \
40+
-H 'Priority: u=3, i' \
41+
--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

0 commit comments

Comments
 (0)