Skip to content

Commit f2d47e7

Browse files
committed
Fix dashboard errors, enable scheduled searches, and add test automation job
1 parent c02a25c commit f2d47e7

File tree

3 files changed

+74
-212
lines changed

3 files changed

+74
-212
lines changed

default/savedsearches.conf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cron_schedule = */5 * * * *
1111
description = Collects dashboard view metrics from splunkd_ui_access logs
1212
dispatch.earliest_time = -5m
1313
dispatch.latest_time = now
14-
enableSched = 0
14+
enableSched = 1
1515
search = index=_internal sourcetype=splunkd_ui_access uri_path="/*/app/*" | rex field=uri_path "/[^/]+/app/(?<app>[^/]+)/(?<dashboard_name>[^/?]+)" | where isnotnull(dashboard_name) AND dashboard_name!="search" AND dashboard_name!="home" AND dashboard_name!="launcher" AND dashboard_name!="analytics_workspace" | eval dashboard_uri="/app/".app."/".dashboard_name | lookup dashboard_registry dashboard_uri OUTPUT pretty_name | where isnotnull(pretty_name) | stats count by dashboard_uri, pretty_name, app, user | eval activity_type="view", metric_name="dashboard.views" | mcollect index=caca_metrics split=t pretty_name app user activity_type
1616
schedule_priority = default
1717
schedule_window = 5
@@ -24,7 +24,7 @@ cron_schedule = */10 * * * *
2424
description = Collects dashboard edit/creation metrics from audit logs
2525
dispatch.earliest_time = -10m
2626
dispatch.latest_time = now
27-
enableSched = 0
27+
enableSched = 1
2828
search = index=_audit action=edit_ui_view | rex field=object "(?<app>[^:]+):(?<dashboard_name>.+)" | where isnotnull(dashboard_name) | eval dashboard_uri="/app/".app."/".dashboard_name | lookup dashboard_registry dashboard_uri OUTPUT pretty_name app as reg_app owner | where isnotnull(pretty_name) | stats count by dashboard_uri, pretty_name, app, user | eval activity_type="edit", metric_name="dashboard.edits" | mcollect index=caca_metrics split=t pretty_name app user activity_type
2929
schedule_priority = default
3030
schedule_window = 5
@@ -37,7 +37,7 @@ cron_schedule = */15 * * * *
3737
description = Collects dashboard health metrics including errors and performance
3838
dispatch.earliest_time = -15m
3939
dispatch.latest_time = now
40-
enableSched = 0
40+
enableSched = 1
4141
search = index=_internal (sourcetype=splunkd log_level=ERROR OR log_level=WARN) (component=ScheduledViewsReporter OR component=DashboardController OR component=SimpleXML) | rex field=_raw "view=(?<dashboard_name>[^\\s,]+)" | rex field=_raw "app=(?<app>[^\\s,]+)" | where isnotnull(dashboard_name) AND isnotnull(app) | eval dashboard_uri="/app/".app."/".dashboard_name | lookup dashboard_registry dashboard_uri OUTPUT pretty_name app as reg_app owner | where isnotnull(pretty_name) | stats count by dashboard_uri, pretty_name, app, log_level | eval severity=lower(log_level), activity_type="health", metric_name="dashboard.errors" | mcollect index=caca_metrics split=t pretty_name app severity activity_type
4242
schedule_priority = default
4343
schedule_window = 5
@@ -50,7 +50,7 @@ cron_schedule = */10 * * * *
5050
description = Collects dashboard load time and performance metrics
5151
dispatch.earliest_time = -10m
5252
dispatch.latest_time = now
53-
enableSched = 0
53+
enableSched = 1
5454
search = index=_internal sourcetype=splunkd_ui_access uri_path="/*/app/*" | rex field=uri_path "/[^/]+/app/(?<app>[^/]+)/(?<dashboard_name>[^/?]+)" | where isnotnull(dashboard_name) AND isnotnull(spent) | eval dashboard_uri="/app/".app."/".dashboard_name | lookup dashboard_registry dashboard_uri OUTPUT pretty_name app as reg_app owner | where isnotnull(pretty_name) | eval load_time_ms=tonumber(spent) | where isnotnull(load_time_ms) AND load_time_ms > 0 | stats sum(load_time_ms) as total_load_time, count as request_count by dashboard_uri, pretty_name, app, user | eval _value=round(total_load_time/request_count, 2), activity_type="performance", metric_name="dashboard.load_time" | mcollect index=caca_metrics split=t _value pretty_name app user activity_type
5555
schedule_priority = default
5656
schedule_window = 5
@@ -67,7 +67,7 @@ cron_schedule = 0 2 * * *
6767
description = Automatically updates dashboard registry via REST API, respecting app filter configuration
6868
dispatch.earliest_time = -5m
6969
dispatch.latest_time = now
70-
enableSched = 0
70+
enableSched = 1
7171
search = | rest /services/data/ui/views splunk_server=local count=0 | search isDashboard=1 OR isVisible=1 | eval dashboard_uri="/app/".'eai:acl.app'."/".title | eval pretty_name=coalesce(label, title) | eval app='eai:acl.app' | eval owner='eai:acl.owner' | eval sharing='eai:acl.sharing' | rex field="eai:data" "<description>(?<xml_description>.*?)</description>" | eval description=coalesce(xml_description, "") | eval status="active" | lookup app_filter app OUTPUT include | where isnull(include) OR include="true" OR include="1" OR include="yes" | fields - include | table dashboard_uri pretty_name app owner sharing description status | outputlookup dashboard_registry.csv
7272
schedule_priority = default
7373
dispatchAs = owner

local/local-environment.yaml

Lines changed: 0 additions & 207 deletions
This file was deleted.

local/test-environment.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ spec:
245245
ports:
246246
- name: http
247247
port: 8000
248+
- name: mgmt
249+
port: 8089
248250
type: ClusterIP
249251
selector:
250252
app: splunk
@@ -278,3 +280,70 @@ spec:
278280
type: ClusterIP
279281
selector:
280282
app: splunk
283+
---
284+
# Test Runner Job
285+
# Automates the test environment setup: runs registry update, generates traffic, and runs collectors
286+
apiVersion: batch/v1
287+
kind: Job
288+
metadata:
289+
name: caca-test-runner
290+
namespace: splunk-caca
291+
spec:
292+
ttlSecondsAfterFinished: 600
293+
template:
294+
spec:
295+
restartPolicy: Never
296+
containers:
297+
- name: test-runner
298+
image: curlimages/curl:latest
299+
env:
300+
- name: SPLUNK_PASSWORD
301+
valueFrom:
302+
secretKeyRef:
303+
name: splunk-secret
304+
key: password
305+
- name: SPLUNK_HOST
306+
value: "splunk-http"
307+
command:
308+
- /bin/sh
309+
- -c
310+
- |
311+
echo "Waiting for Splunk Management API (8089)..."
312+
until curl -s -k -o /dev/null https://${SPLUNK_HOST}:8089/services/server/info; do
313+
echo "Splunk not ready yet..."
314+
sleep 10
315+
done
316+
317+
# Wait a bit more for login to be fully ready
318+
echo "Splunk API is responding. Waiting 30s for full startup..."
319+
sleep 30
320+
321+
echo "=== 1. Running Registry Update ==="
322+
curl -k -u admin:${SPLUNK_PASSWORD} https://${SPLUNK_HOST}:8089/services/saved/searches/Dashboard%20Registry%20-%20Auto%20Update/dispatch -d trigger_actions=1 -X POST
323+
echo "Registry Update Dispatched."
324+
sleep 5
325+
326+
echo "=== 2. Generating Traffic (Views) ==="
327+
DASHBOARDS="dashboard_leaderboard poop_deck caca_admin dashboard_details"
328+
for dash in $DASHBOARDS; do
329+
echo "Viewing $dash..."
330+
for i in 1 2 3; do
331+
curl -s -u admin:${SPLUNK_PASSWORD} -o /dev/null "http://${SPLUNK_HOST}:8000/en-US/app/splunk-content-monitoring-console/$dash"
332+
done
333+
done
334+
335+
echo "=== 3. Simulating Dashboard Edit ==="
336+
# Update description to trigger an edit event
337+
EDIT_URL="https://${SPLUNK_HOST}:8089/servicesNS/admin/splunk-content-monitoring-console/data/ui/views/dashboard_leaderboard"
338+
DESC="Content Activity Checking Application - Monitor all dashboard usage, health, and activity (Automated Test Edit)"
339+
curl -k -u admin:${SPLUNK_PASSWORD} $EDIT_URL -d "description=$DESC"
340+
echo "Dashboard Edited."
341+
342+
echo "=== 4. Running Metric Collectors ==="
343+
COLLECTORS="Dashboard%20Views%20-%20Metrics%20Collector Dashboard%20Edits%20-%20Metrics%20Collector Dashboard%20Health%20-%20Metrics%20Collector Dashboard%20Performance%20-%20Metrics%20Collector"
344+
for collector in $COLLECTORS; do
345+
echo "Running $collector..."
346+
curl -k -u admin:${SPLUNK_PASSWORD} https://${SPLUNK_HOST}:8089/services/saved/searches/$collector/dispatch -d trigger_actions=1 -X POST
347+
done
348+
349+
echo "=== Test Automation Complete ==="

0 commit comments

Comments
 (0)